Not sure if you wanted to keep a variable indicating order but, regardless, the %untranspose macro can easily do what you want. e.g.:
data have;
input studyid age bmi (adm_dt1-adm_dt3) (:yymmdd8.) (adm_dx1-adm_dx3) (:8.)
(adm_tx1-adm_tx3) (:8.);
format adm_dt1-adm_dt3 yymmdd10.;
datalines;
1 23 28.9 20180908 20181120 20190210 1 1 1 0 1 1
2 34 26.9 20170103 20171230 20180522 4 2 3 1 1 1
;
run;
filename ut url 'http://tiny.cc/untranspose_macro';
%include ut ;
%untranspose(data=have, out=want (drop=order), by=studyid age bmi,
id=order, var=adm_dt adm_dx adm_tx)
Art, CEO, AnalystFinder.com
... View more