DATASOURCE Procedure

Controlling the Time Range of Data: The RANGE Statement

(View the complete code for this example.)

The RANGE statement is used to control the time range of observations included in the output data set. Figure 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 2: Subset Obtained by KEEP and RANGE Statements

Printout of the OUT= Data Set

ObsDATEEXRJANEXRSWEXRUK
1SEP1985236.5302.37490136.420
2OCT1985214.6802.16920142.150
3NOV1985204.0702.13060143.960
4DEC1985202.7902.10420144.470
5JAN1986199.8902.06600142.440
6FEB1986184.8501.95470142.970
7MAR1986178.6901.91500146.740
8APR1986175.0901.90160149.850
9MAY1986167.0301.85380152.110
10JUN1986167.5401.84060150.850
11JUL1986158.6101.74450150.710
12AUG1986154.1801.66160148.610
13SEP1986154.7301.65370146.980
14OCT1986156.4701.64330142.640
15NOV1986162.8501.68580142.380
16DEC1986162.0501.66470143.930
17JAN1987154.8301.56160150.540
18FEB1987153.4101.54030152.800


Last updated: June 19, 2025