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 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 9 Dec 2008 14:47:57 -0500
Reply-To:   msz03@albany.edu
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mike Zdeb <msz03@ALBANY.EDU>
Subject:   Re: a more efficient approach than using array?
Content-Type:   text/plain;charset=iso-8859-1

hi ... another approach, CAT+FIND

I've tried similar approaches with ~2.5 million obs data sets CAT+FIND was same elapsed time as ARRAY+LOOP, but only about 50% of the CPU time so, efficiency choice is up to you

by the way, this assumes those PR and DX codes are length 4 character variables if they are length 5+, this approach needs a tweak to select the correct observations

data med; set meds1 (keep=id dgns_cd1-dgns_cd10 PRCDR_CD1-PRCDR_CD6); length apd_sx apd_dx p_apd_sx p_apd_dx apd p_apd 3;

pr = catx(',' of PRCDR_CD1-PRCDR_CD6); dx = catx(',',of dgns_cd1-dgns_cd10);

apd_sx1 = (find(pr,'4701') ne 0 or find(pr,'4709') ne 0 or find(pr,'4711') ne 0 or find(pr,'4719') ne 0 or find(pr,'4720') ne 0); p_apd_sx = (find(pr,'4720') ne 0);

apd_dx1 = (find(dx,'5400') ne 0 or find(dx,'5401') ne 0 or find(dx,'5409') ne 0 or find(dx,'5410') ne 0 or find(dx,'5420') ne 0); p_apd_dx = (find(dx,'5400') ne 0 or find(dx,'5401') ne 0);

apd = (apd_sx eq 1 or apd_dx eq 1); p_apd = (p_apd_sx eq 1 or p_apd_dx eq 1);

if apd or p_apd;

label apd="appendicitis / appendectomy indicator (Yes=1)" p_apd="perforated appendicitis indicator (Yes=1)" ;

drop pr dx; run;

-- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> Hi, > > As shown in my codes below, I use the array approach to select the > observations when any of these 6 variables (PRCDR_CD1 - PRCDR_CD6) has the > value '4701','4709','4711','4719','4720', and flag it > > I also use the array approach to select the observations when any of these > 10 variables (dgns_cd1 - dgns_cd10) has the value > '5400','5401','5409','5410','5420', and flag it > > The codes worked, but I feel there may be a more efficient way than array > apporach I'm using to achieve the same purpose. > > Any input is greatly appreciated. > > Jerry > > /**********************************************************/ > data med (drop=_dx _sx); > > set meds1 > (keep=id dgns_cd1-dgns_cd10 PRCDR_CD1-PRCDR_CD6); > > length apd_sx apd_dx p_apd_sx p_apd_dx apd p_apd 3; > > array sxicd {*} $ PRCDR_CD1-PRCDR_CD6; > array dxicd {*} $ dgns_cd1-dgns_cd10; > > do _sx = 1 to dim(sxicd); > > if sxicd(_sx) in ('4701','4709','4711','4719','4720') > then do; > apd_sx=1; > if sxicd(_sx)='4720' then p_apd_sx=1; > end; > end; > > do _dx = 1 to dim(dxicd); > if dxicd(_dx) in ('5400','5401','5409','5410','5420') > then do; > apd_dx=1; > if dxicd(_dx) in ('5400', '5401') then p_apd_dx=1; > end; > end; > > if apd_sx=1 or apd_dx=1 then apd=1; > if p_apd_sx=1 or p_apd_dx=1 then p_apd=1; > > if apd=1 or p_apd=1; > > label > apd="appendicitis / appendectomy indicator (Yes=1)" > p_apd="perforated appendicitis indicator (Yes=1)" > ; > run; > /**********************************************************/ > >


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