BookmarkSubscribeRSS Feed
Aliya-begum
Calcite | Level 5

 

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;

 

 



 

 

6 REPLIES 6
novinosrin
Tourmaline | Level 20
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

novinosrin
Tourmaline | Level 20
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;
novinosrin
Tourmaline | Level 20

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;
Andygray
Quartz | Level 8

@Aliya-begum  If the questions has been answered, you could mark as answered choosing one of the given solutions that you prefer.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 6 replies
  • 945 views
  • 2 likes
  • 4 in conversation