1
votes

Suppose you have a data set such as the following:

FSA1 SSA1 SBW1
1     2    3

Is there a way in a data step to filter columns that do not contain 'SA'? I don't want to use a drop or a keep statement as the real dataset has hundreds of variables.

1

1 Answers

6
votes

Something like this:

proc sql;
   select name into: dropnames
   separated by " "
   from dictionary.columns 
   where libname='SASHELP' and memname='CLASS' 
   having name contains 'He';
   quit;

   data class;
   set sashelp.class;
   drop &dropnames;
   run;