Skip to content

Instantly share code, notes, and snippets.

@t-student
Created November 2, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-student/36ac3179d469cf28c447 to your computer and use it in GitHub Desktop.
Save t-student/36ac3179d469cf28c447 to your computer and use it in GitHub Desktop.
* Sort the table columns alphabetically ;
proc contents data=Newcoach1t1 out=col_names noprint; run;
proc contents data=Newcoach1t1 out=col_names(keep=name ) noprint; run;
proc sort data=col_names; by name; run;
data _null_;
set col_names;
by name;
retain sorted_cols;
length sorted_cols $2500.;
if _n_ = 1 then sorted_cols = name;
else sorted_cols = catx(' ', sorted_cols, name);
call symput('sorted_cols', sorted_cols);
run;
data Newcoach1t1;
retain &sorted_cols;
set Newcoach1t1;
run;
data Newcoach1t1b;
set Newcoach1t1;
run;
proc datasets lib=work;
modify Newcoach1t1b;
attrib _all_ label='';
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment