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 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 23 Nov 2006 20:23:48 -0500
Reply-To:     "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject:      Re: Transpose : Horizontal to vertical ?
Comments: To: sas-l@uga.edu

G wrote: > Hi, > > Question must have been asked before but can't find a suitable > solution in all the posts. > Want to convert data from horizontal into vertical by Name and ID as > illustrated below :- > > NAME ID A1 A2 A3 B1 B2 B3 C1 C2 C3 > > john 1 10 20 30 40 50 60 70 80 90 > david 2 90 80 70 60 50 40 30 20 10 > > desired output; > > NAME ID A B C > > john 1 10 40 70 > john 1 20 50 80 > john 1 30 60 90 > david 2 90 60 30 > david 2 80 50 20 > david 2 70 40 10

Tranpose, possibly, but requires two transposes and an intermediate data transformation to peel the # off the identifier.

Easiest is array. Presuming a1-aN, b1-bN and c1-cN

array aays a:; array bees b:; array cees c:; do id = 1 to dim (aays); a = aays[id]; b = bees[id]; c = cees[id]; output; end; keep name id a b c;

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


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