Previous Page | Next Page

The SASEFAME Interface Engine

Example 34.4 Limiting the Time Range of Data

You can also limit the time range of the data in the SAS data set by using the RANGE= option in the LIBNAME statement or the WHERE statement in the DATA step to process the time ID variable DATE only when it falls in the range you are interested in.

All data for 1988, 1989, and 1990 are included in the SAS data set generated by using the RANGE=’01JAN1988’D - ’31DEC1990’D option or the WHERE DATE BETWEEN ’01JAN88’D AND ’31DEC90’D statement. The difference is that the range option uses less space in your FAME WORK database. If you have a very large database and want to use less space in your FAME WORK database while you are processing the oecd1 database, you should instead use the RANGE= option as shown in Output 34.4.1.

   options validvarname=any;
   
   %let FAME=%sysget(FAME);
   %put(&FAME);
   %let FAMETEMP=%sysget(FAME_TEMP);
   %put(&FAMETEMP);
   
   libname famedir SASEFAME "%sysget(FAME_DATA)"
           convert=(freq=annual technique=constant)
           range='01jan1988'd - '31dec1990'd;
   
   libname mydir "%sysget(FAME_TEMP)";
   
   data mydir.a;  /* add data set to mydir */
      set famedir.oecd1;
      /* range on the libref restricts the dates *
       * read from famedir's oecd1 database      */
   run;
   
   proc print data=mydir.a;
   run;

Output 34.4.1 Listing of OUT=MYDIR.A of the OECD1 FAME Data Using RANGE= Option
 
OECD1: TECH=constant, FREQ=annual
keep statement using n-literals
rename statement using n-literals

Obs DATE AUS.DIRDES AUS.HERD AUT.DIRDES AUT.HERD BEL.DIRDES BEL.HERD CAN.DIRDES CAN.HERD CHE.DIRDES CHE.HERD DEU.DIRDES DEU.HERD DNK.DIRDES DNK.HERD ESP.DIRDES ESP.HERD FIN.DIRDES FIN.HERD FRA.DIRDES FRA.HERD GBR.DIRDES GBR.HERD GRC.DIRDES GRC.HERD IRL.DIRDES IRL.HERD ISL.DIRDES ISL.HERD ITA.DIRDES ITA.HERD JPN.DIRDES JPN.HERD NLD.DIRDES NLD.HERD NOR.DIRDES NOR.HERD NZL.DIRDES NZL.HERD PRT.DIRDES PRT.HERD SWE.DIRDES SWE.HERD TUR.DIRDES TUR.HERD USA.DIRDES USA.HERD YUG.DIRDES YUG.HERD
1 1988 750 1072.90 . . 374 16572.70 1589.60 2006 632.100 1532 3538.60 8780.00 258.100 2662 508.200 55365.5 247.700 1602.0 2573.50 19272.00 2627.00 1592.00 60.600 6674.50 49.6000 37.0730 . . 1861.5 2699927 9657.20 2014073 883 2105 . . . . 111.5 10158.20 . . 174.400 74474 20246.20 20246.20 233.000 29.81
2 1989 . . . . . 18310.70 1737.00 2214 . 1648 3777.20 9226.60 284.800 2951 623.600 69270.5 259.700 1725.5 2856.50 21347.80 2844.10 1774.20 119.800 14485.20 50.2000 39.0130 10.3000 786.762 1968.0 2923504 10405.90 2129372 945 2202 308.900 2771.40 78.7000 143.800 . . 1076 11104 212.300 143951 22159.50 22159.50 205.100 375.22
3 1990 . . . . . 18874.20 1859.20 2347 . . 2953.30 9700.00 . . 723.600 78848.0 271.000 1839.0 3005.20 22240.00 . . . . 51.7000 . 11.0000 902.498 2075.0 3183071 . 2296992 . . . . . . . . . . . . 23556.10 23556.10 . 2588.50

The WHERE statement can be used in the DATA step to process the time ID variable DATE only when it falls in the range you are interested in. In Output 34.4.2, you can see that the result from the WHERE statement is the same as the result in Output 34.4.1 using the RANGE= option.

   options validvarname=any;
   
   %let FAME=%sysget(FAME);
   %put(&FAME);
   %let FAMETEMP=%sysget(FAME_TEMP);
   %put(&FAMETEMP);
   
   libname famedir SASEFAME "%sysget(FAME_DATA)"
           convert=(freq=annual technique=constant);
   
   libname mydir "%sysget(FAME_TEMP)";
   
   data mydir.a;  /* add data set to mydir */
      set famedir.oecd1;
      /* where only  */
      where date between '01jan88'd and '31dec90'd;
   run;
   
   proc print data=mydir.a;
   run;

Output 34.4.2 Listing of OUT=MYDIR.A of the OECD1 FAME Data Using WHERE Statement
 
OECD1: TECH=constant, FREQ=annual
keep statement using n-literals
rename statement using n-literals

Obs DATE AUS.DIRDES AUS.HERD AUT.DIRDES AUT.HERD BEL.DIRDES BEL.HERD CAN.DIRDES CAN.HERD CHE.DIRDES CHE.HERD DEU.DIRDES DEU.HERD DNK.DIRDES DNK.HERD ESP.DIRDES ESP.HERD FIN.DIRDES FIN.HERD FRA.DIRDES FRA.HERD GBR.DIRDES GBR.HERD GRC.DIRDES GRC.HERD IRL.DIRDES IRL.HERD ISL.DIRDES ISL.HERD ITA.DIRDES ITA.HERD JPN.DIRDES JPN.HERD NLD.DIRDES NLD.HERD NOR.DIRDES NOR.HERD NZL.DIRDES NZL.HERD PRT.DIRDES PRT.HERD SWE.DIRDES SWE.HERD TUR.DIRDES TUR.HERD USA.DIRDES USA.HERD YUG.DIRDES YUG.HERD
1 1988 750 1072.90 . . 374 16572.70 1589.60 2006 632.100 1532 3538.60 8780.00 258.100 2662 508.200 55365.5 247.700 1602.0 2573.50 19272.00 2627.00 1592.00 60.600 6674.50 49.6000 37.0730 . . 1861.5 2699927 9657.20 2014073 883 2105 . . . . 111.5 10158.20 . . 174.400 74474 20246.20 20246.20 233.000 29.81
2 1989 . . . . . 18310.70 1737.00 2214 . 1648 3777.20 9226.60 284.800 2951 623.600 69270.5 259.700 1725.5 2856.50 21347.80 2844.10 1774.20 119.800 14485.20 50.2000 39.0130 10.3000 786.762 1968.0 2923504 10405.90 2129372 945 2202 308.900 2771.40 78.7000 143.800 . . 1076 11104 212.300 143951 22159.50 22159.50 205.100 375.22
3 1990 . . . . . 18874.20 1859.20 2347 . . 2953.30 9700.00 . . 723.600 78848.0 271.000 1839.0 3005.20 22240.00 . . . . 51.7000 . 11.0000 902.498 2075.0 3183071 . 2296992 . . . . . . . . . . . . 23556.10 23556.10 . 2588.50

Refer to the SAS Language Reference: Concepts for more information on KEEP, DROP, RENAME, and WHERE statements.

Previous Page | Next Page | Top of Page