BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nrjn7
Fluorite | Level 6
IDEventScore1Score2Score3Score5Score5
1A12   
1B  33 
1C    4
2A34   
2B  56 
2C    8
3A34   

 

I'm working with a much bigger file bu his is the general flow.

How do I transform this to one row by ID?

Please suggest. 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input ID	Event $	Score1	Score2	Score3	Score4	Score5;
cards;
1	A	1	2	. . . 	 	 
1	B	. 	. 	3	3	. 
1	C	. . . . 	 	 	 	4
2	A	3	4	. . . 	 	 
2	B	. . 	 	5	6	. 
2	C	. . . . 	 	 	 	8
3	A	3	4	. . . 	 	 
;


data want;
 update have(obs=0) have;
 by id;
 drop event;
run;
/*OR*/
proc summary data=have nway;
 class id;
 var score:;
 output out=want(drop=_:) max=;
run;

Hi @Nrjn7  Please use one of the above. 1st one though needs your dataset to be sorted by ID whereas 2nd one doesn't

View solution in original post

3 REPLIES 3
ballardw
Super User

You need to show exactly what you expect the result to look like. The value of EVENT is going to play a role somewhere but you have not described what that role would be. You may have to address exactly how many possible values of Event there are in the entire data set when specifying your rules.

Nrjn7
Fluorite | Level 6

Thanks for you reply. 

What I'm looking for is something like this

IDScore1Score2Score3Score4Score5
112334
234566
334...

 

I'm having hard time understanding how it works and how do I account for "Event" variable.

novinosrin
Tourmaline | Level 20
data have;
input ID	Event $	Score1	Score2	Score3	Score4	Score5;
cards;
1	A	1	2	. . . 	 	 
1	B	. 	. 	3	3	. 
1	C	. . . . 	 	 	 	4
2	A	3	4	. . . 	 	 
2	B	. . 	 	5	6	. 
2	C	. . . . 	 	 	 	8
3	A	3	4	. . . 	 	 
;


data want;
 update have(obs=0) have;
 by id;
 drop event;
run;
/*OR*/
proc summary data=have nway;
 class id;
 var score:;
 output out=want(drop=_:) max=;
run;

Hi @Nrjn7  Please use one of the above. 1st one though needs your dataset to be sorted by ID whereas 2nd one doesn't

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 559 views
  • 1 like
  • 3 in conversation