BookmarkSubscribeRSS Feed
112211
Obsidian | Level 7

data v ;
input id vstestcd $ vsorres vsorresu $ ;
cards ;
101 sbp 120 mmhg
101 dbp 90 mmhg
101 hr 78 permin
101 pr 85 permin
102 sbp 120 mmhg
102 dbp 90 mmhg
102 hr 78 permin
102 pr 85 permin
;
i need the below output using the array/transpose from the above data 
ID    SBP   DBP HR     PR    V1             v2             v3             v4
101  120     90    78      85  mmhg    mmhg    permin   permin
102  120     90    78      85  mmhg    mmhg    permin   permin

2 REPLIES 2
Tom
Super User Tom
Super User

Assuming there is only one set of values per ID you could use two PROC TRANSPOSE steps and then merge the results.

proc transpose data=v out=numbers;
  by id;
  id vstestcd ;
  var vsorres;
run;
proc transpose data=v out=characters suffix=_units;
  by id;
  id vstestcd ;
  var vsorresu ;
run;

data want ;
  merge numbers characters;
  by id;
  drop _name_;
run;

Tom_0-1702741833841.png

 

Kurt_Bremser
Super User

Isn't this a report?

proc report data=v;
column id (vsorres vsorresu),vstestcd;
define id / group;
define vsorres / "Value" analysis;
define vsorresu / "Unit" display;
define vstestcd / "" across;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 775 views
  • 3 likes
  • 3 in conversation