The RANGE statement is used to control the time range of observations included in the output data set. Figure 12.2 shows an example extracting the foreign exchange rates from September 1985 to February 1987, you can use the following statements:
/*-- Controlling the Time Range of Data - The RANGE Statement --*/ filename citifile "%sysget(DATASRC_DATA)citiaf.dat" RECFM=F LRECL=80; proc datasource filetype=dribasic infile=citifile interval=month out=dataset; keep exrjan exrsw exruk; range from 1985:9 to 1987:2; run; title1 'Printout of the OUT= Data Set'; proc print data=dataset; run;
Figure 12.2: Subset Obtained by KEEP and RANGE Statements
Printout of the OUT= Data Set |
Obs | DATE | EXRJAN | EXRSW | EXRUK |
---|---|---|---|---|
1 | SEP1985 | 236.530 | 2.37490 | 136.420 |
2 | OCT1985 | 214.680 | 2.16920 | 142.150 |
3 | NOV1985 | 204.070 | 2.13060 | 143.960 |
4 | DEC1985 | 202.790 | 2.10420 | 144.470 |
5 | JAN1986 | 199.890 | 2.06600 | 142.440 |
6 | FEB1986 | 184.850 | 1.95470 | 142.970 |
7 | MAR1986 | 178.690 | 1.91500 | 146.740 |
8 | APR1986 | 175.090 | 1.90160 | 149.850 |
9 | MAY1986 | 167.030 | 1.85380 | 152.110 |
10 | JUN1986 | 167.540 | 1.84060 | 150.850 |
11 | JUL1986 | 158.610 | 1.74450 | 150.710 |
12 | AUG1986 | 154.180 | 1.66160 | 148.610 |
13 | SEP1986 | 154.730 | 1.65370 | 146.980 |
14 | OCT1986 | 156.470 | 1.64330 | 142.640 |
15 | NOV1986 | 162.850 | 1.68580 | 142.380 |
16 | DEC1986 | 162.050 | 1.66470 | 143.930 |
17 | JAN1987 | 154.830 | 1.56160 | 150.540 |
18 | FEB1987 | 153.410 | 1.54030 | 152.800 |