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 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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