Hi Everyone,
My data like this:
ID CD
1 3
1 4
1 5
2 6
2 7
2 8
How do I change data like this:
ID CD1 CD2 CD3
1 3 4 5
2 6 7 8
Thanks in Advance.
Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/
https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/
This is called a transpose and you can use PROC TRANSPOSE.
If you want just a report, PROC FREQ or TABULATE will do it.
Hi,
My data like this:
ID CD time treatment
1 3 1 2
1 4 2 2
1 5 3 2
2 6 1 4
2 7 2 4
2 8 3 4
How do I change data like this:
ID CD1 CD2 CD3
1 3 4 5
2 6 7 8
From your link, I wrote my code:
proc transpose data=AIDS out= Output (drop = _NAME_) prefix=CD_;
id time;
var CD;
by ID;
run;
If I add another variable treatment in the data, like this
ID CD1 CD2 CD3 treatment
1 3 4 5 2
2 6 7 8 4
What should I do? I appreciate your help.
Add the variable to the BY statement or a COPY statement.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: