Using the vcolumn and proc sql tables to create a macro variable macro:
proc sql noprint;
select trim(compress(name))
into :drop_vars separated by ' '
from sashelp.vcolumn
where libname = upcase('lib1')
and
memname = upcase('table1')
and
upcase(name) like '%LABEL%'
;
quit;
%put &drop_vars.;
data table2;
set table1;
drop &drop_vars.;
run;
proc sql will create a list of all the variables from table1 in the library 'lib1', containing labelanywhere in the name, and place it in the macro variable drop_vars. (upper scale is used to reduce the likelihood of a problem)
The data step then uses the operator dropand variable drop_varsto remove all the variables in the list.
Note. Make sure you check the output %put statementto make sure you are not dropping the variables you want to keep
scott source
share