Date: Fri, 4 Apr 2003 12:45:53 -0800
Reply-To: "Huang, Ya" <yhuang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Huang, Ya" <yhuang@AMYLIN.COM>
Subject: Re: restructuring data
Content-Type: text/plain; charset="iso-8859-1"
This question comes up once a while. Here is my proc transpose
based solution.
data xx;
input id income age school;
cards;
1 200 20 2
1 300 25 4
1 560 44 4
2 899 55 2
3 300 25 4
3 200 68 3
;
data xx (keep=id frm val);
set xx;
by id;
if first.id then idv=0;
idv+1;
array vv income age school;
do over vv;
frm=vname(vv)||left(put(idv,best.));
val=vv;
output;
end;
run;
proc transpose data=xx out=yy (drop=_name_);
by id;
var val;
id frm;
run;
options nocenter;
proc print noobs heading=v;
run;
-------------
i s i s i s
n c n c n c
c h c h c h
o a o o a o o a o
m g o m g o m g o
i e e l e e l e e l
d 1 1 1 2 2 2 3 3 3
1 200 20 2 300 25 4 560 44 4
2 899 55 2 . . . . . .
3 300 25 4 200 68 3 . . .
Kind regards,
Ya Huang
-----Original Message-----
From: L F [mailto:tyroc7@HOTMAIL.COM]
Sent: Friday, April 04, 2003 12:24 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: restructuring data
I have data in the form:
id income age school
1 200 20 2
1 300 25 4
1 560 44 4
2 899 55 2
3 300 25 4
3 200 68 3
and would like to restructure it to:
id income age school income2 age2 school2 income3 age3 school3
1 200 20 4 300 25 4 560 44 4
2 899 55 2 . . . . . .
3 300 25 4 200 68 3 . . .
Could someone provide suggestions?
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail