BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Yoko
Obsidian | Level 7

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
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;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
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;
Yoko
Obsidian | Level 7

It worked, thank you!

PeterClemmensen
Tourmaline | Level 20

No problem. Glad to help 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1074 views
  • 0 likes
  • 2 in conversation