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 (January 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 24 Jan 2006 09:57:57 -0600
Reply-To:     Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Subject:      Re: Proc Transpose Assistance
Comments: To: jhayward1@BABSON.EDU
Content-Type: text/plain; charset=US-ASCII

Jon:

Here is an approach not using PROC TRANSPOSE. Output follows the code.

data long1 ; input id group $ amount value ; cards ; 1 A 100 1000 1 B 200 2000 2 A 300 3000 2 B 400 4000 ; run;

PROC SORT DATA=LONG1; BY ID GROUP; RUN;

DATA RESULT(DROP=AMOUNT VALUE GROUP); RETAIN ID A_AMOUNT A_VALUE B_AMOUNT B_VALUE; SET LONG1; BY ID; IF FIRST.ID THEN DO; A_AMOUNT=AMOUNT; A_VALUE=VALUE; END; IF LAST.ID THEN DO; B_AMOUNT=AMOUNT; B_VALUE=VALUE; OUTPUT; END; RUN;

PROC PRINT; RUN;

***** Output ***** The SAS System 07:27 Tuesday, January 24, 2006 32

Obs ID A_AMOUNT A_VALUE B_AMOUNT B_VALUE

1 1 100 1000 200 2000 2 2 300 3000 400 4000

J S Huang 1-515-557-3987 fax 1-515-557-2422

>>> Jon Hayward <jhayward1@BABSON.EDU> 1/24/2006 9:30:16 AM >>> Hi - Thanks in advance for any help that you can provide. I am trying to tranpose data from long format to wide as follows below. I have tried many combinations of options and read the online documentation and searched for similar examples to no avail. Thank you! Jon

BEFORE data long1 ; input id group $ amount value ; cards ; 1 A 100 1000 1 B 200 2000 2 A 300 3000 2 B 400 4000 ; run;

AFTER id A_amount A_value B_amount B_value 1 100 1000 200 2000 2 300 3000 400 4000


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