data VS;
input PT VISITNO HEIGHT WEIGHT PULSE SBP;
cards;
101 1 156 78 102 120
101 2 156 78 103 121
101 3 156 78 102 120
102 1 150 70 100 121
;
run;
data VS;
input PT VISITNO HEIGHT WEIGHT PULSE SBP;
cards;
101 1 156 78 102 120
101 2 156 78 103 121
101 3 156 78 102 120
102 1 150 70 100 121
;
run;
proc transpose data=vs out=w;
by pt visitno;
var height--sbp;
run;
proc sort data=w out=want;
by pt _name_;
run;
Rename/add labels to your convenience/needs
data VS;
input PT VISITNO HEIGHT WEIGHT PULSE SBP;
cards;
101 1 156 78 102 120
101 2 156 78 103 121
101 3 156 78 102 120
102 1 150 70 100 121
;
run;
data w;
set vs;
n=0;
array t height--sbp;
do over t;
v_name=vname(t);
ORRES=t;
n+1;
output;
end;
keep pt visitno v_name orres n;
run;
proc sort data=w out=want(drop=n);
by pt n;
run;
And something fancy
data VS;
input PT VISITNO HEIGHT WEIGHT PULSE SBP;
cards;
101 1 156 78 102 120
101 2 156 78 103 121
101 3 156 78 102 120
102 1 150 70 100 121
;
run;
data _null_;
if _n_=1 then do;
dcl hash H (ordered: "A",multidata:'y') ;
h.definekey ("PT",'n') ;
h.definedata ("PT", "VISITNO", "V_NAME","ORRES") ;
h.definedone () ;
end;
set vs end=lr;
n=0;
array t height--sbp;
do over t;
v_name=vname(t);
ORRES=t;
n+1;
h.add();
end;
if lr then h.output(dataset:'want');
run;
@Aliya-begum If the questions has been answered, you could mark as answered choosing one of the given solutions that you prefer.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.