Saving / Deleting Variables in SAS

I want to remove columns / variables from a large SAS dataset, call it "data". I have all the column names that I want to delete stored in another SAS dataset - let it "var", it has one column with a header column. How to reset all variables contained in 'var' from my source data 'data' with drop function?

Thanks!

+4
source share
1 answer

You can use the "in" proc sql clause to copy the column of variable names from the "vars" dataset into a macro variable, which is then passed to the drop= statement in the 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; 
+11
source

All Articles