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 (November 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 27 Nov 2001 15:09:00 -0500
Reply-To:     "Xu, Meifen" <meifen_xu@MERCK.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Xu, Meifen" <meifen_xu@MERCK.COM>
Subject:      Re: stacking and transposing
Comments: To: Sundar <sdoraira@VT.EDU>
Content-Type: text/plain; charset=iso-8859-1

You may try:

data one; input color $ col1-col5; cards;

Blue 28 26 31 27 35 Green 34 29 25 31 29 Orange 31 25 27 29 28

;

run;

data expand(drop=col1-col5 i); set one; array num (*) col1-col5;

do i = 1 to dim(num); newcol = num(i); output; end; run;

Meifen Xu * (484) 344 4622 * meifen_xu@merck.com

-----Original Message----- From: Sundar [mailto:sdoraira@VT.EDU] Sent: Tuesday, November 27, 2001 2:46 PM To: SAS-L@LISTSERV.UGA.EDU Subject: stacking and transposing

I have a data set that looks like this: Blue 28 26 31 27 35 Green 34 29 25 31 29 Orange 31 25 27 29 28

What's the easiest way to make it look like this: Blue 28 Blue 26 Blue 31 Blue 27 Blue 35 Green 34 Green 29 Green 25 Green 31 Green 29 Orange 31 Orange 25 Orange 27 Orange 29 Orange 28

I have come up a solution, though it requires 4 data steps and a transpose. There's got to be an easier way. Any answer should allow for any number of groups, not just 3 as suggested in the question.

Thanks in advance.

Sundar


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