I want to remove columns/variables from a large SAS dataset, call it 'data'. I have all of the column names that I want to drop stored in another SAS dataset - let's call it 'var', it has a single column with header column. How do I drop all of the variables contained in 'var' from my original dataset 'data' with the drop function?
Thanks!
You can use the "into" clause of proc sql to copy the column of variable names from the "vars" data set into a macro variable that you then pass to the drop=
statement in a data step. See below:
proc sql noprint;
select <name_of_column> into: vars_to_drop separated by " "
from var;
quit;
data data;
set data (drop= &vars_to_drop);
run;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With