Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The DATASOURCE Procedure

Subsetting a Data File Containing Cross Sections

Data files containing cross sections can be subsetted by controlling which cross sections to include in the output data set. Selecting a subset of cross sections is accomplished using the WHERE statement. The WHERE statement gives a condition the BY variables must satisfy for a cross section to be selected. For example, the following statements extract the monthly effective exchange rate (F_X_AM) and exchange rate index (F_X_AF) for the United Kingdom (COUNTRY='112'), Switzerland (COUNTRY='146'), and Japan (COUNTRY='158') for the period from September, 1987 to February, 1988.

   filename ifsfile 'host-specific-file-name' <host-options>;
   proc datasource filetype=imfifsp infile=ifsfile interval=month
                   out=exchange;
      where country in ('112','146','158') and partner=' ';
      keep  f_x_ah f_x_am;
      range from '01sep87'd to '01feb88'd;
   run;
   
   title1 'Printout of the OUT= Data Set';
   proc print data=exchange noobs;
   run;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.