如何将SAS数据集的字符型变量提取出出来,并生成新的数据集

谗孩肆垢攫佩脑 |浏览447次
2019/01/01 17:01
如何将SAS数据集的字符型变量提取出出来,并生成新的数据集
收藏关注

满意回答

2019/01/15 18:02

%macro keepCharcter(libname,dataname,newdata);

  proc sql;

    select count(*) into :cnt from sashelp.vcolumn where upper(libname)=upper("&libname") and upper(memname)=upper("&dataname") and type="char";

  quit;

  %let cnt=&cnt;

  proc sql;

    select name into :name1-:name&cnt  from sashelp.vcolumn where upper(libname)=upper("&libname") and upper(memname)=upper("&dataname") and type="char";

  quit;

  data &newdata;

  set &libname..&dataname;

  keep %do i=1 %to &cnt; &&name&i %end;;

  run;

%mend;

%keepCharcter(sashelp,class,new1);

%keepCharcter(sashelp,iris,new2);


glmswufe

其他回答(0)    我来补答
0人关注该问题
+1
 加载中...