Date: Thu, 14 Dec 2006 16:15:20 -0800
Reply-To: "Mogens A. Krogh" <MKROGH@DSR.KVL.DK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Mogens A. Krogh" <MKROGH@DSR.KVL.DK>
Organization: http://groups.google.com
Subject: Re: reorganizing dataset
Content-Type: text/plain; charset="us-ascii"
Dear Siddharth,
I seriously think you should consider doing this very carefully as
David have already pointed out. But anyways -here is a possible
solution.
Regards
Mogens A. Krogh
Phd-student, DVM
www.kvl.dk
data have;
input custid id1-id3 col4 $ col5 $ col6 $;
cards;
1 1 . . a1 a2 a3 a4
1 2 . . a1 a2 a3 a4
1 3 . . a1 a2 a3 a4
1 . 21 . b1 b2 b3 b4
1 . 22 . b1 b2 b3 b4
1 . . 31 c1 c2 c3 c4
1 . . 32 c1 c2 c3 c4
1 . . 33 c1 c2 c3 c4
;
run;
data inbetween;
set have;
if id1 then id='A';
if id2 then id='B';
if id3 then id='C';
run;
data want;
set inbetween (rename=(id1=_id1 id2=_id2 id3=_id3));
retain tempID;
by Custid id notsorted;
if first.id then TempID=put(sum(_id1,_id2,_id3),10.);
else TempID=compress(TempID||'|'||put(sum(_id1,_id2,_id3),10.));
if last.ID then do;
if ID='A' then ID1=TempID;
if ID='B' then ID2=TempID;
if ID='C' then ID3=TempID;
output;
end;
drop _: ID tempID;
run;
|