I have data like below :
| ID | visit | m1 | m2 | m3 | m4 |
| 1 | week1 | 10 | |||
| 1 | week1 | 13 | |||
| 1 | week1 | 15 | |||
| 1 | week1 | 14 | |||
| 2 | week2 | 12 | |||
| 2 | week2 | 11 | |||
| 2 | week2 | 14 | |||
| 2 | week2 | 13 | |||
| 3 | week3 | 13 | |||
| 3 | week3 | 10 | |||
| 3 | week3 | 11 | |||
| 3 | week3 | 12 |
And I want to have data like :
| ID | visit | m1 | m2 | m3 | m4 |
| 1 | week1 | 10 | 13 | 15 | 14 |
| 2 | week2 | 12 | 11 | 14 | 13 |
| 3 | week3 | 13 | 10 | 11 | 12 |
One way is to output 4 data for m1, m2, m3 and m4 and then merge.
I wonder if there is a simpler way to do it? Thanks
Use SQL and take max of each column per id
use update trick
data want;
Update have (obs=0) have;
by id visit;
run;
Use SQL and take max of each column per id
use update trick
data want;
Update have (obs=0) have;
by id visit;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.