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 (May 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 May 2008 10:05:32 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: transpose problem
Comments: To: Jerry L Diebal <jdiebal@gmail.com>
In-Reply-To:  <3cf9f5a80805220747u5f862365ld1643707277c26e5@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I don't know if I understand the criteria for linenum slotting but this might work.

data have; infile datalines dsd; input item $ linenum ddmonth $ ; datalines; 11111111, 1411, 08jul08 11111111, 1412, 08jul08 11111111, 1413, 08jul08 99999999, 1414, 08jul08 99999999, 1415, 08jul08 99999999, 1416, 08jul08 ;;;; run; data haveV / view=haveV; set have; by ddmonth notsorted; if first.ddmonth then id = 0; id + 1; run; proc transpose out=need(drop=_name_) prefix=linenum; by item ddmonth; var linenum; id id; run; proc print; run;

On 5/22/08, Jerry L Diebal <jdiebal@gmail.com> wrote: > Mark and Author - I apologize for the bad example. I was in a hurry and > didn't realize that this wasn't what I should have put in. > > This one shows what I have and want. The linenum have to be individual > variables like in the 'need' dataset below. Thanks for looking at this. > > data have; > infile datalines dsd; > input item $ linenum ddmonth $ ; > datalines; > 11111111, 1411, 08jul08 > 11111111, 1412, 08jul08 > 11111111, 1413, 08jul08 > 99999999, 1414, 08jul08 > 99999999, 1415, 08jul08 > 99999999, 1416, 08jul08 > > ; > > data need; > infile datalines dsd; > input item $ ddmonth $ linenum1 linenum2 linenum3 linenum4 linenum5 > linenum6; > datalines; > 11111111, 08jul08, 1411, 1412, 1413, , , > 99999999, 08jul08, , , ,1414 ,1415 ,1416 > ; > > > > > > > > > > > On Wed, May 21, 2008 at 4:58 PM, Arthur Tabachneck <art297@netscape.net> > wrote: > > > Jerry, > > > > Assuming that your example is wrong, is the following what you are hoping > > to accomplish?: > > > > data have; > > infile datalines delimiter=','; > > input item $12. linenum ddmonth $; > > datalines; > > 112U0900-923, 1416, 08jul08 > > 112U0900-923, 1418, 08jul08 > > 112U0900-923, 1420, 08jul08 > > 112U0900-999, 1410, 08jul08 > > 112U0900-999, 1411, 08jul08 > > 112U0900-999, 1412, 08jul08 > > ; > > > > proc transpose data=have out=want (drop=_name_) prefix=linenum; > > var linenum; > > by item ddmonth; > > run; > > > > HTH, > > Art > > ---------- > > On Wed, 21 May 2008 16:41:26 -0600, Jerry L Diebal <jdiebal@GMAIL.COM> > > wrote: > > > > >Can someone show me how a proc transpose can be used to turn the 'have' > > >dataset into the 'need' dataset? There will be a max of 3 observations per > > >item. The possible 'linenum' values range from 1406 to 1426. thank you. > > > > > > > > > > > >data have; > > >infile datalines dsd; > > >input item $ linenum ddmonth $ ; > > > datalines; > > >112U0900-923, 1416, 08jul08 > > >112U0900-923, 1418, 08jul08 > > >112U0900-923, 1420, 08jul08 > > >112U0900-999, 1410, 08jul08 > > >112U0900-999, 1411, 08jul08 > > >112U0900-999, 1412, 08jul08 > > > > > >; > > > > > >data need; > > >infile datalines dsd; > > >input item $ ddmonth $ linenum1 linenum2 linenum3 linenum4 linenum5 > > >linenum6; > > > datalines; > > >112U0900-923, 08jul08, 1416, 1418, 1420, 1410, 1411, 1412 > > >; > > >


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