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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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