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 (March 2006, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 30 Mar 2006 22:48:52 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: horizontal data into vertical
Comments: To: rushi.b.patel@GMAIL.COM
In-Reply-To:  <e92ea7520603301426u306efd73jf679e31fa52b9de0@mail.gmail.com>
Content-Type: text/plain; format=flowed

Rushi ,

data one ; infile cards ; input id a1992 b1992 $ a1993 b1993 $ a1994 b1994 $ ; cards ; 1 10 VR 10 VR 20 RV 2 20 VR 25 RV 30 XX ; run ;

proc transpose data = one out = two ; by id ; var a: b: ; run ;

data two ( drop = _Name_ ) ; set two ; Year = Substr(_Name_ , 2 ) ; run ;

proc sort data = two ; by Id Year ; run ;

proc transpose data = two out = three ( drop = _Name_ rename = ( Col1 = A Col2 = B ) ) ; by id Year ; var COl1 ; run ;

proc print data = three ; run ;

Toby Dunn

From: Rushi Patel <rushi.b.patel@GMAIL.COM> Reply-To: Rushi Patel <rushi.b.patel@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: horizontal data into vertical Date: Thu, 30 Mar 2006 17:26:58 -0500

SAS-L,

I an interested in transforming the following horizontal data into vertical..

id a1992 b1992 a1993 b1993 a1994 b1994 1 10 VR 10 VR 20 RV 2 20 VR 25 RV 30 XX ....

into

id year a b 1 1992 10 VR 1 1993 10 VR 1 1994 20 RV 2 1992 20 VR 2 1993 25 RV 2 1994 30 XX

I tried

PROC TRANSPOSE data = dat1 out = out1; by id; var a1992 - a1994 b1992 - b1994; run;

but this would give both a and b under one column.

Thanks,

Rushi


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