Creating new columns from collapsing duplicate records in SAS
Posted: 23 September 2012 05:03 AM   [ Ignore ]
Newbie
Rank
Total Posts:  2
Joined  2012-09-23

I have a problem which I hope someone could help me with. Below is a description of my problem.

I have a dataset which looks like the below:

ID Gender Car
1   F         A
1   F         B
1   F         C
2   M       A
2   M       B

I would like to collapse the dataset above based on the duplicate ID and create new columns for the Car variable. The output dataset I would like to have looks like the below:

ID Gender Car1 Car2 Car3
1   F         A     B       C
2   M       A     B      


I have quite a large number of clients (ie. the ID variable) in my dataset - from memory I think I have about 9000 IDs, so would be good if I have a SAS code which can deal with large numbers if IDs.

Can anyone help me with the SAS codes for the above? Much appreciated in advance! Thanks

Profile
 
 
Posted: 23 September 2012 08:34 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Leockl,

You should be able to do this with proc transpose, see http://www.ats.ucla.edu/stat/sas/modules/ltow_transpose.htm

best regards,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 26 September 2012 09:01 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  2
Joined  2012-09-23

Many thanks for your help on this Joost!

Profile
 
 
Posted: 28 September 2012 11:16 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

I am glad it worked out smile

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile