Transpose macro
Compiled by Ajish K Mani
%macro trans(dsn=, outdsn=, vartran=, idtran=, bytran=, copytran=);
proc transpose data=&dsn out=&outdsn let;
var &vartran;
by &bytran;
%if ©tran ne %then %do;
copy ©tran;
%end;
%if &idtran ne %then %do;
id &idtran;
%end;
run;
%mend trans;
data input
input patno 1 sex $ 3 visit 5 weight 7-8 height 10-12;
datalines;
1 m 1 80 150
2 f 1 65 160
3 f 1 70 165
4 f 1 60 170
5 m 1 68 168
;
run;
proc sort data=input out=output;
by patno;
run;
%trans (dsn=output, outdsn=transpose(rename=(col1=Result)), vartran=weight height, bytran=patno);
data transpose;
set transpose;
label _name_ ="Parameter" ;
rename _name_=Parameter;
run;
No comments:
Post a Comment