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 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 12 Jun 2009 10:58:01 -0700
Reply-To:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization:   http://groups.google.com
Subject:   Re: Table Transform
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; charset=ISO-8859-1

On Jun 12, 1:06 pm, Emma G <emma.gottesman.h...@googlemail.com> wrote: > I have a dataset with 2 fields, an ID and a part-number, both > character variables. Here's a sample of made-up but representative > data: > ID Part-Num > 1256 789-9867 > 2345 657-8988 > 2345 879-7866 > 3444 666-1234 > 3444 666-1234 > 5678 789-9867 > > I need to transform this to a table that has one row per id and then a > variable containing all the part-numbers for that ID. It should look > something like this: > ID Part-Num List > 1256 789-9867 > 2345 657-8988, 879-786 > 3444 666-1234, 666-1234 > 5678 789-9867 > > There is no maximum number of part-numbers for an ID, it's one or > more.

If the number of parts per id is not excessive, the parts list can be stored in a maximum length character string and the list can be accumulated in a do over group loop.

data IdPartsList / view=IdPartsList; do until (last.id); set IdParts; by ID; length partslist $32767; partslist = catx(', ',partslist,part); end; run;

-- Richard A. DeVenezia http://www.devenezia.com


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