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;
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!
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.