As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Sorting of variables by name inside a data set

From sasCommunity
Jump to: navigation, search

You can arrange the variables in a dataset by their name using PROC SQL. In this example, WORK.SAMPLE is the data set created to show the result.

data work.sample;
    x=1; m=2; c=3; b=4; aa=1; k=2; cd='A';
run;
 
proc sql noprint;
    select strip(name) into :vars separated by ' '
    from dictionary.columns
    where libname = upcase("work") and memname = upcase("sample")
    order by 1;
quit;
 
data work.sample;
    retain &vars.;
    set work.sample;
run;

Submitted by P.Balasubramanyam. Contact me at my Discussion Page.