Hello,
I have a data like this:
DATA mydata1;
input id code1 code2 code3;
DATALINES;
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
;
run;
Then, I want to re-organize the data such that a new data set looks like this:
id code
1 5
1 9
1 13
2 6
2 10
2 14
3 7
3 11
3 15
4 8
4 12
4 16
Is it possible to do this? If so, how can I re-organize my data?
Thank you!
Yoko
DATA mydata1;
input id code1 code2 code3;
DATALINES;
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
;
run;
proc transpose data=mydata1 out=want(rename=(COL1=code) drop=_NAME_);
by id;
var code1-code3;
run;
DATA mydata1;
input id code1 code2 code3;
DATALINES;
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
;
run;
proc transpose data=mydata1 out=want(rename=(COL1=code) drop=_NAME_);
by id;
var code1-code3;
run;
It worked, thank you!
No problem. Glad to help 🙂
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.