LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 28 Jun 2006 16:19:32 -0400
Reply-To:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:   Re: Single row into multiple columns

On Wed, 28 Jun 2006 11:16:21 -0400, Jim Groeneveld <jim2stat@YAHOO.CO.UK> wrote:

>Hi, > >See for a similar problem and a solution: >http://listserv.uga.edu/cgi-bin/wa?A2=ind0606B&L=sas-l&P=R21295 > >Regards - Jim. >-- >Jim Groeneveld, Netherlands >Statistician, SAS consultant >home.hccnet.nl/jim.groeneveld > > >On Wed, 28 Jun 2006 07:38:51 -0700, Apsteinberg <apsteinberg@HOTMAIL.COM> >wrote: > >>Here is my issue...I have a table with 60K records. There are multiple >>individual IDs for one site id. The data looks something like this: >>Site_ID Individual_ID >>1 1 >>1 2 >>1 55 >>3 8416 >>5 4568 >>9 46 >>13 88 >>13 959

These appear to be character variables, as in:

data have; input Site_ID $ Individual_ID $; cards; 1 1 1 2 1 55 3 8416 5 4568 9 46 13 88 13 959 ;

>> >>I need the data to be listed like this: >> >>Site_ID Individual_ID >>1 1, 2, 55 >>3 8416 >>5 4568 >>9 46 >>13 88, 959

Try

data want1(keep = Site_ID Individual_IDs); do until (last.site_id); set have; by site_id notsorted; length Individual_IDs $ 40; Individual_IDs = catx(', ',Individual_IDs,Individual_ID); end; length Individual_IDs $ 40; run;

Then use PROC PRINT;

>> >>Or like this: >>Site_ID Individual_ID Individual_ID Individual_ID >>1 1 2 55 >>3 8416 >>5 4568 >>9 46 >>13 88 959

Try

proc transpose data=have out=want2(drop=_name_) prefix=Individual_ID; by site_id notsorted; var Individual_ID; run;

and, again, PROC PRINT.

>> >>I need to get it so that only one site id is listed per column >>corresponding to every individual id for the site id. Right now I have >>it so that if I have more than one individual id it is a new column. >>Please help. Thanks

PROC REPORT might be a one-step possibility.


Back to: Top of message | Previous page | Main SAS-L page