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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1287 views
  • 3 likes
  • 3 in conversation