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 (December 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: sas-l@uga.edu
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;


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