Date: Sat, 31 May 2008 14:53:51 -0400
Reply-To: Hari Nath <hari_s_nath@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Hari Nath <hari_s_nath@YAHOO.COM>
Subject: Re: Proc Transpose Problem
You can try something like this....
data mydata ;
input place_id Year Race X Y Z ;
cards ;
1 1950 1 1 2 3
1 1950 2 1 2 4
;
run ;
proc sort data=mydata ; by place_id Year ;
run ;
data need (drop=race x y z);
array _c_ (2) x1 x2 ;
array _d_ (2) y1 y2 ;
array _e_ (2) z1 z2 ;
do until( last.place_id ) ;
set mydata ;
by place_id ;
_c_(race)=x;
_d_(race)=y;
_e_(race)=z ;
end ;
run ;
proc print ;
run ;
On Sat, 31 May 2008 12:59:09 -0500, sudip chatterjee
<sudip.memphis@GMAIL.COM> wrote:
>My data set has place_ ID , Race , and several variables like X,Y,Z during
>1950 - 1990.
>
> like
>place_ id Year Race X Y Z
> 1 1950 1 1 1 1
> 1 1950 2 1 1 1
>
>
> Now what I want is
>
> Place_id Year X_1 X_2 Y_1 Y_2 Z_1 Z_2
>
>I got these by using
>
>proc transpose data=mydata out=new(drop=_name_) prefix=
>X;
>
> by place_id year
>;
>
> var X ;
>run;
>
>*** But this is only for 1 variable ******
>
>My problem : IF I want to do the same for all the variables (X,Y,Z) in
the
>same table at once
>
> then how ?
|