BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
r3570
Obsidian | Level 7

Hi All,

 

I have a dataset as below:

 

r3570_0-1661516782241.png

 I need to transpose the data as below subject wise:

 

r3570_1-1661516953298.png

Any help ?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use PROC TRANSPOSE.

proc transpose data=have out=want(drop=_name_) ;
  by usubjid;
  id vstestcd;
  var vsorres;
run;

Note that if you will collect multiple BP readings per subject then you will probably also need to another variable to in the original dataset you can use in the BY statement so that PROC TRANSPOSE knows which pairs of SYS and DIA readings to keep together on the same output observation.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Use PROC TRANSPOSE.

proc transpose data=have out=want(drop=_name_) ;
  by usubjid;
  id vstestcd;
  var vsorres;
run;

Note that if you will collect multiple BP readings per subject then you will probably also need to another variable to in the original dataset you can use in the BY statement so that PROC TRANSPOSE knows which pairs of SYS and DIA readings to keep together on the same output observation.

r3570
Obsidian | Level 7

Thank you so much ! it worked !

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
  • 857 views
  • 1 like
  • 2 in conversation