Date: Wed, 4 Nov 1998 11:04:59 -0500
Reply-To: "Gary M. McQuown" <mcquown@FENIX2.DOL-ESA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Gary M. McQuown" <mcquown@FENIX2.DOL-ESA.GOV>
Subject: Solution to SQL, Mutually Exclusive Codes by ID
Content-Type: text/plain; charset="iso-8859-1"
Many thanks to Chris Lanning for his solution to this problem (below with
very minor adjustments).
/* output cpt codes by case_no from extract where mutually exclusive codes
(me_1 & me_2) were charged */
PROC SQL;
create table excl_id as
select case_no, me_2 as cpt
from extract e, c_edit c
where e.cpt=c.me_1
order by case_no, cpt
;
quit;
proc sort data=extract;
by case_no cpt;
run;
/* keep only those records that are in both data sets */
data final;
merge excl_id (in=x) extract (in=y);
by case_no cpt;
if y=1 & x=1;
run;
|