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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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