Previous Page | Next Page

The DATASOURCE Procedure

WHERE Statement

WHERE where-expression ;

The WHERE statement specifies conditions that BY variables must satisfy in order for a cross section to be included in the OUT= and OUTEVENT= data sets. By default, all BY groups are selected.

The where-expression must refer only to BY variables defined for the file type you are reading. The Data Elements Reference: DATASOURCE Procedure lists the names of the BY variables for each file type.

For example, DOTS (Direction of Trade Statistics) files, distributed by the International Monetary Fund, have four BY variables: COUNTRY, CSC, PARTNER, and VERSION. Both COUNTRY and PARTNER are three-digit country codes. To select the direction of trade statistics of the United States (COUNTRY=’111’) with Turkey (COUNTRY=’186’), Japan (COUNTRY=’158’), and the oil exporting countries group (COUNTRY=’985’), you should specify

   where country='111' and partner in ('186','158','985');

You can use any SAS language operators and special WHERE expression operators in the WHERE statement condition. Refer to SAS Language Reference: Concepts for a more detailed discussion of WHERE expressions.

If you want to see the names of the BY variables and the values they assume for each cross section, you can first run PROC DATASOURCE with only the OUTBY= option. The information contained in the OUTBY= data set will aid you in selecting the appropriate BY groups for subsequent PROC DATASOURCE steps.

Previous Page | Next Page | Top of Page