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 (May 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 15 May 2007 14:03:44 -0700
Reply-To:   "irina.spivak@gmail.com" <irina.spivak@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "irina.spivak@gmail.com" <irina.spivak@GMAIL.COM>
Organization:   http://groups.google.com
Subject:   Re: Proc Transpose
Comments:   To: sas-l@uga.edu
In-Reply-To:   <1179243141.759945.75860@k79g2000hse.googlegroups.com>
Content-Type:   text/plain; charset="iso-8859-1"

On May 15, 5:32 pm, jeli0...@hotmail.co.uk wrote: > I have a dataset and I want to transpose by vara so that the vara > becomes the column name ie > > groupcode name vara balance > a1234 aaaaaa 1234 £1,234 > a1234 aaaaaa 5678 £100 > b5332 fewerw 2342 £1,002 > > and I want to turn it into > > groupcode name 1234 5678 2342 > a1234 aaaaaa £1,234 £100 . > b5332 fewerw . . £1,002

Hi,you can't give to variable name 1234, but you can give something like this :_1234. I hope it will be helpful : data test; input a vara balance ; datalines; 1 13 12 2 14 24 3 15 32 4 17 44 55 35 52 77 45 25 ; run;

proc sql noprint; select balance,a ,compress('_'||(put(vara,best12.))) ,compress(put(count(*),best12.)) as counter into :bal separated BY " ", :vara separated BY "+", :counter

from test; quit; %put &vara;

data new(drop=i); set test; array bal(&counter) _TEMPORARY_ (&bal) ; array name (&counter) a1-a&counter;

do i=1 to &counter; if balance = bal(i) then name(i)=bal(i);

end; run;

%macro Rename; data new1; set new;

%let i=1; %do %until (%scan(&vara,&i,+)= ); rename a&i=%scan(&vara,&i,+); %let i=%eval(&i+1); %end; run; %mend Rename; %Rename


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