问题
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