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 (September 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 18 Sep 2006 20:11:57 -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: Sas Question (Re-organizing dataset)

Here's a simplistic alternative. It provides the indicated ordering of the variables.

data need(keep = name code amount); set code(rename = (code1=code) ); output; code = code2; output; code = code3; output; run;

On Mon, 18 Sep 2006 19:43:46 -0400, data _null_; <datanull@GMAIL.COM> wrote:

>Perhaps this can be adapted to your needs. You may want to rename >COL1 and drop _NAME_. > >data work.code; > input name:$8. (code1-code3)(:$3.) amount:comma8.; > format amount dollar8.0; > cards; >Leroy X13 H42 G91 $4,900 >Mary D14 X42 X41 $8,100 >Lynn C45 X41 H99 $3,000 >;;;; > run; >proc print; > run; >proc transpose data=work.code out=work.codeT; > by name notsorted amount; > var code1-code3; > run; >proc print; > run; > >On 9/18/06, wardnine@hotmail.com <wardnine@hotmail.com> wrote: >> Suppose I have a dataset with the variables name, code1, code2, code3, >> and amount. The dataset is thousands of lines long, but here is a >> 3-line sample (the order of the 5 variables of data is the same as the >> order of the variables I list in the first sentence of the post)... >> >> Leroy X13 H42 G91 $4,900 >> Mary D14 X42 X41 $8,100 >> Lynn C45 X41 H99 $3,000 >> >> I need to re-arrange the data so that the name and each code on each >> row is assigned the amount on that row and for each variable and >> corresponding amount to appear on a separate line. So, I would need the >> following dataset: >> >> Leroy X13 $4,900 >> Leroy H42 $4,900 >> Leroy G91 $4,900 >> Mary D14 $8,100 >> Mary X42 $8,100 >> Mary X41 $8,100 >> Lynn C45 $3,000 >> Lynn X41 $3,000 >> Lynn H99 $3,000 >> >> Is it possible to do this? >> >> Julie >>


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