Dear All:
May I ask how to transform the following have table to the want table right below?
HAVE table:
patient | tcell_[year1] | tcell_[year2] | tcell_[year3] | tcell_[year4] | tcell_[year5] |
---|---|---|---|---|---|
A | 23 | 34 | 213 | 45 | 435 |
C | 132 | 213 | 123 | 345 | 435 |
D | 13 | 123 | 123 | 435 | 123 |
E | 343 | 1231 | 4325 | 435 | 345 |
WANT table:
patient | year | tcell |
---|---|---|
A | 1 | 23 |
A | 2 | 34 |
A | 3 | 213 |
A | 4 | 45 |
A | 5 | 435 |
C | 1 | 132 |
C | 2 | 213 |
C | 3 | 123 |
D | 1 | 13 |
D | 2 | 123 |
D | 3 | 123 |
Use Proc Transpose:
SAS Learning Module: How to reshape data wide to long using proc transpose
Thank you so much, this work!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.