The SASEHAVR Interface Engine |
Example 35.7 Using the WHERE Statement to Subset Time Series from a HAVER Database
Using a WHERE statement in the DATA step can be useful for further subsetting.
libname lib1 sasehavr "%sysget(HAVER_DATA)"
freq=daily start=20041101 end=20041231;
data hwoutd;
set lib1.haverd;
where date between '01nov2004'd and '01dec2004'd;
run;
title1 'Haver Analytics Database, Frequency=daily, infile=haverd.dat';
title2 ' Define a range inside the data range for OUT= dataset';
title3 ' Using the START=20041101 END=20041231 LIBNAME options.';
title4 'Subset further: where date between 01nov2004 and 31dec2004.';
proc print data=hwoutd;
run;
Output 35.7.1 shows that the time slice of November 1, 2004, to December 31, 2004, is narrowed further by the DATE test on the WHERE statement to stop at December 1, 2004.
Output 35.7.1
Defining a Range Using START=20041101 END=20041231 along with the WHERE statement
01NOV2004 |
4.11 |
1.79 |
1.83 |
1.80 |
0.7460 |
35111 |
02NOV2004 |
4.10 |
1.86 |
1.74 |
1.74 |
0.7447 |
34091 |
03NOV2004 |
4.09 |
1.83 |
1.73 |
1.73 |
0.7539 |
14862 |
04NOV2004 |
4.10 |
1.85 |
1.77 |
1.75 |
0.7585 |
23304 |
05NOV2004 |
4.21 |
1.86 |
1.76 |
1.75 |
0.7620 |
19872 |
08NOV2004 |
4.22 |
1.88 |
1.80 |
1.84 |
0.7578 |
21095 |
09NOV2004 |
4.22 |
1.89 |
1.79 |
1.81 |
0.7618 |
16390 |
10NOV2004 |
4.25 |
1.88 |
1.92 |
1.85 |
0.7592 |
12872 |
11NOV2004 |
. |
. |
1.92 |
. |
. |
12872 |
12NOV2004 |
4.20 |
1.91 |
2.02 |
1.96 |
0.7685 |
28926 |
15NOV2004 |
4.20 |
1.92 |
2.06 |
2.03 |
0.7719 |
10480 |
16NOV2004 |
4.21 |
1.93 |
1.98 |
1.95 |
0.7728 |
13417 |
17NOV2004 |
4.14 |
1.90 |
1.99 |
1.93 |
0.7833 |
10506 |
18NOV2004 |
4.12 |
1.91 |
1.99 |
1.94 |
0.7786 |
6293 |
19NOV2004 |
4.20 |
1.98 |
1.99 |
1.93 |
0.7852 |
5100 |
22NOV2004 |
4.18 |
1.98 |
2.01 |
1.96 |
0.7839 |
6045 |
23NOV2004 |
4.19 |
1.99 |
2.00 |
1.95 |
0.7860 |
18135 |
24NOV2004 |
4.20 |
1.98 |
2.02 |
1.89 |
0.7863 |
14109 |
25NOV2004 |
. |
. |
2.02 |
. |
. |
14109 |
26NOV2004 |
4.24 |
2.01 |
2.01 |
1.97 |
0.7903 |
20588 |
29NOV2004 |
4.34 |
2.02 |
2.03 |
2.00 |
0.7852 |
24322 |
30NOV2004 |
4.36 |
2.07 |
2.02 |
2.04 |
0.7723 |
18033 |
01DEC2004 |
4.38 |
2.06 |
2.04 |
2.01 |
0.7754 |
7564 |