As Arthur and Patrick did, You can get whatever order you want by using SQL. DATA VAR;
INPUT Subject $ VISIT1 VISIT3 VISIT2_01 VISIT2 VISIT3_02 VISIT3_01;
DATALINES;
A0001 5 6 2 3 54 2
B0001 2 4 6 5 4 5
C0001 2 4 36 5 4 2
;
run;
proc sql noprint;
select name into :SortedVarList separated by ' '
from dictionary.columns
where libname='WORK' and memname='VAR' and upcase(name) like 'VISIT%'
order by input(scan(name,1,'VISIT_'),best8.),input(scan(name,2,'VISIT_'),best8.)
;
quit;
%put &SortedVarList ;
data VAR;
retain Subject &SortedVarList;
set var;
run;
Ksharp
... View more