```Date: Thu, 29 May 2003 17:45:03 +0200 Reply-To: Braddock Sender: "SAS(r) Discussion" From: Braddock Organization: Centro Servizi Interbusiness Subject: Re: need efficiency tips or different approach "Sterling Price" wrote in message news:16E0F6604574D311BFE100902745F0A81B005A94@honts330.homeoffice.wal-mart.c om... > Greetings all, > Hi Sterling, try the following code. I have done it without macro variables, because I have experienced the problems arising form massive use of macro var. Anyway, the code is quite simple and even if I haven't tested the speed I am confident it is a bit faster than yours. data risk; length date \$10; input company claim_no payment_type \$ date \$ amount; cards; 1 12345 P 05/01/2003 500 1 12345 P 05/01/2003 500 1 54553 P 05/02/2003 100 1 54553 P 05/02/2003 100 1 55555 P 05/02/2003 300 ; run; data inf; length date \$10; input company claim_no payment_type \$ date \$ amount; cards; 1 12345 P 05/01/2003 500 1 12345 P 05/01/2003 500 1 12345 P 05/01/2003 500 1 78912 P 05/02/2003 200 1 78912 P 05/02/2003 300 1 55555 P 05/02/2003 300 1 55555 P 05/02/2003 300 ; run; data risk; set risk; key = compress(company||claim_no||payment_type||date||amount); run; data inf; set inf; key = compress(company||claim_no||payment_type||date||amount); run; proc sort data=risk; by key; run; proc sort data=inf; by key; run; data risk nrisk; set risk; by key; retain nris; if first.key then nris=1; else nris+1; output risk; if last.key then output nrisk; run; data inf ninf; set inf; by key; retain ninf; if first.key then ninf=1; else ninf+1; output inf; if last.key then output ninf; run; data risk; merge risk nrisk(rename=(nris=nristot)); by key; run; data inf; merge inf ninf(rename=(ninf=ninftot)); by key; run; data both risk_not_inf inf_not_risk; merge risk(in=aa) inf(in=bb); by key; if aa=bb & nris<=min(nristot,ninftot) & ninf<=min(nristot,ninftot) then output both; if aa=1 & bb=0 then output risk_not_inf; if aa=0 & bb=1 then output inf_not_risk; if aa=bb & nris>min(nristot,ninftot) then output risk_not_inf; if aa=bb & ninf>min(nristot,ninftot) then output inf_not_risk; run; proc print data=both; run; proc print data=risk_not_inf; run; proc print data=inf_not_risk; run; Since I have no idea about the running speed, please let me know if it has been helpful for you. Gianluca ```

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