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

Hello,

 

I have a dataset: 

 

ID_1 Value
A1
A2
A3
B4
B5
B6
C7
C8

 

I want to make ID_1 unique and create new columns for all the values. So I want: 

 

ID_1Value_1Value_2Value_3
A123
B456
C78 

 

Hope someone can help me. Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data have;
input ID_1 $	Value;
cards;
A	1
A	2
A	3
B	4
B	5
B	6
C	7
C	8
;

proc transpose data=have out=want prefix=value;
by id_1;
var value;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

data have;
input ID_1 $	Value;
cards;
A	1
A	2
A	3
B	4
B	5
B	6
C	7
C	8
;

proc transpose data=have out=want prefix=value;
by id_1;
var value;
run;
PeterClemmensen
Tourmaline | Level 20

Do like this

 

data have;
input ID_1 $ Value;
datalines;
A 1
A 2
A 3
B 4
B 5
B 6
C 7
C 8
;

proc transpose data=have out=want(drop=_NAME_) prefix=value_;
    by ID_1 ;
    var Value;
run;

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
  • 2 replies
  • 715 views
  • 2 likes
  • 3 in conversation