PROC EXPORT drops variables specified in the WHERE= data set option even though those variables are not specified in the DROP= data set option


The EXPORT procedure drops the variables that are specified in the WHERE= data set option even though the variables are not specified in the DROP= data set option.   

Here is an example of code that can cause this issue. The expectation is that the HEIGHT variable is dropped and that the SEX and AGE variables appear in the file. However, the SEX and AGE variables are dropped along with HEIGHT, and only the NAME and WEIGHT variables are written to the class.csv file:

proc export data=sashelp.class(drop=height where=(sex='F' and age=15))
outfile='c:\temp\class.csv' dbms=csv replace;
run; 

 

The workaround is to use one of the data set options, WHERE= or DROP=, in a DATA step prior to PROC EXPORT. Then use PROC EXPORT with the other option, WHERE= or DROP=, to create an external file.

In the following example, the WHERE= data set option is used in the DATA step and the DROP= data set option is used with PROC EXPORT:

data class;
   set sashelp.class (where=(sex='F' and age=15));
run;

proc export data=class(drop=height)
outfile='c:\temp\class.csv' dbms=csv replace;
run;