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 42.7.1 shows that the time slice of November 1, 2004, to December 31, 2004, is narrowed further by the DATE test in the WHERE statement to stop at December 1, 2004.
Output 42.7.1: Defining a Range Using the WHERE Statement, START=20041101, and END=20041231
Haver Analytics Database, Frequency=daily, infile=haverd.dat |
Define a range inside the data range for OUT= dataset |
Using the START=20041101 END=20041231 LIBNAME options. |
Subset further: where date between 01nov2004 and 31dec2004. |
Obs | DATE | FCM10 | FCM1M | FFED | FFP1D | FXAUS | TCC |
---|---|---|---|---|---|---|---|
1 | 01NOV2004 | 4.11 | 1.79 | 1.83 | 1.80 | 0.7460 | 35111 |
2 | 02NOV2004 | 4.10 | 1.86 | 1.74 | 1.74 | 0.7447 | 34091 |
3 | 03NOV2004 | 4.09 | 1.83 | 1.73 | 1.73 | 0.7539 | 14862 |
4 | 04NOV2004 | 4.10 | 1.85 | 1.77 | 1.75 | 0.7585 | 23304 |
5 | 05NOV2004 | 4.21 | 1.86 | 1.76 | 1.75 | 0.7620 | 19872 |
6 | 08NOV2004 | 4.22 | 1.88 | 1.80 | 1.84 | 0.7578 | 21095 |
7 | 09NOV2004 | 4.22 | 1.89 | 1.79 | 1.81 | 0.7618 | 16390 |
8 | 10NOV2004 | 4.25 | 1.88 | 1.92 | 1.85 | 0.7592 | 12872 |
9 | 11NOV2004 | . | . | 1.92 | . | . | 12872 |
10 | 12NOV2004 | 4.20 | 1.91 | 2.02 | 1.96 | 0.7685 | 28926 |
11 | 15NOV2004 | 4.20 | 1.92 | 2.06 | 2.03 | 0.7719 | 10480 |
12 | 16NOV2004 | 4.21 | 1.93 | 1.98 | 1.95 | 0.7728 | 13417 |
13 | 17NOV2004 | 4.14 | 1.90 | 1.99 | 1.93 | 0.7833 | 10506 |
14 | 18NOV2004 | 4.12 | 1.91 | 1.99 | 1.94 | 0.7786 | 6293 |
15 | 19NOV2004 | 4.20 | 1.98 | 1.99 | 1.93 | 0.7852 | 5100 |
16 | 22NOV2004 | 4.18 | 1.98 | 2.01 | 1.96 | 0.7839 | 6045 |
17 | 23NOV2004 | 4.19 | 1.99 | 2.00 | 1.95 | 0.7860 | 18135 |
18 | 24NOV2004 | 4.20 | 1.98 | 2.02 | 1.89 | 0.7863 | 14109 |
19 | 25NOV2004 | . | . | 2.02 | . | . | 14109 |
20 | 26NOV2004 | 4.24 | 2.01 | 2.01 | 1.97 | 0.7903 | 20588 |
21 | 29NOV2004 | 4.34 | 2.02 | 2.03 | 2.00 | 0.7852 | 24322 |
22 | 30NOV2004 | 4.36 | 2.07 | 2.02 | 2.04 | 0.7723 | 18033 |
23 | 01DEC2004 | 4.38 | 2.06 | 2.04 | 2.01 | 0.7754 | 7564 |