Hi everyone,
I need help please with turning observations into variables. Here's an example of what I have
ID Date Event Date Return
101 01/01/2020 01/01/2020 0.02
101 02/01/2020 01/01/2020 0.0015
101 03/01/2020 01/01/2020 0.001
102 01/01/2020 01/01/2020 0.0222
102 02/01/2020 01/01/2020 0.001
102 03/01/2020 01/01/2020 0.0015
103 01/01/2020 01/01/2020 0.003
103 02/01/2020 01/01/2020 0.03
103 03/01/2020 01/01/2020 0.035
And here's what I want:
Date Event date 101 102 103
01/01/2020 01/01/2020 0.02 0.0222 0.003
02/01/2020 01/01/2020 0.0015 0.001 0.03
03/01/2020 01/01/2020 0.001 0.0015 0.035
Hope that makes sense and thank you in advance for your help!
You need to do a transpose, but sort it first.
proc sort data=have; by date event_date; run; proc transpose data=have; out=want; by date event_date; /*your group by variables*/ id ID; /*the new variable names*/ var return; /*variable to be "transposed"*/ run; quit;
You need to do a transpose, but sort it first.
proc sort data=have; by date event_date; run; proc transpose data=have; out=want; by date event_date; /*your group by variables*/ id ID; /*the new variable names*/ var return; /*variable to be "transposed"*/ run; quit;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.