Rearranging variables in a sas dataset- alphabetical order

我怕爱的太早我们不能终老 提交于 2019-12-24 03:26:12

问题


I have like 500 columns of dataset, and I want to rearrange all the variables in an alphabetical order. How can I do that in any other way than using retain statement before set statement?


回答1:


You can generate the list of variable names dynamically, and create a new dataset using PROC SQL.

proc sql ;
  select name into :VARLIST separated by ', '
  from dictionary.columns
  where libname = 'SASHELP'
    and memname = 'CLASS' 
  order by name ;
quit ;

proc sql ;
  create table ordered as
  select &VARLIST
  from sashelp.class ;
quit ;


来源:https://stackoverflow.com/questions/24783698/rearranging-variables-in-a-sas-dataset-alphabetical-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!