DATA Step, Macro, Functions and more

condensation of data fragmented across variables into one row

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

condensation of data fragmented across variables into one row

Sample problem: 

 

ID----------var1----------var2

123                              50

123          Ace               .

 

I would like one row of complete data for each unique ID.

 

I could make a table for each of the variables and join them back, but I'm thinking there has to be an easier way?     

 

 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 21,546

Re: condensation of data fragmented across variables into one row

Posted in reply to tellmeaboutityo

 

data want;
update have(obs=0) have;
by ID;
run;

 

You can use the update trick, as above.

 


tellmeaboutityo wrote:

Sample problem: 

 

ID----------var1----------var2

123                              50

123          Ace               .

 

I would like one row of complete data for each unique ID.

 

I could make a table for each of the variables and join them back, but I'm thinking there has to be an easier way?     

 

 



 

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Posts: 21,546

Re: condensation of data fragmented across variables into one row

Posted in reply to tellmeaboutityo

 

data want;
update have(obs=0) have;
by ID;
run;

 

You can use the update trick, as above.

 


tellmeaboutityo wrote:

Sample problem: 

 

ID----------var1----------var2

123                              50

123          Ace               .

 

I would like one row of complete data for each unique ID.

 

I could make a table for each of the variables and join them back, but I'm thinking there has to be an easier way?     

 

 



 

Highlighted
Occasional Contributor
Posts: 7

Re: condensation of data fragmented across variables into one row

Thanks Reeza, you're the best!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 56 views
  • 0 likes
  • 2 in conversation