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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 1892 views
  • 2 likes
  • 4 in conversation