开发者

Keeping/Dropping Variables in SAS

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 an开发者_Python百科other 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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜