Good Afternoon everyone!
So, I have this claims table at line level where I need to find all those records with different claim id's where date of service, member id, provider id and line level procedure code are same so that we can identify duplicate claim id's. I'm doing a simple self join but getting too many extra records where each claim line is joining itself with all claim lines of other claim id where all those 4 parameters match- something like a cross join. I have banged my head so much but still cant find a solution to this seemingly regular problem.
Some of the line level procedure code field values are blank, not sure if that is causing the problem. Here is my code in proc sql-
Proc sql;
SELECT DISTINCT c1.clm_nbr, c1.mbr_nbr, c1.CLM_LN_PROC_CD,
c1.CLM_DT_OF_SRVC, c1.clm_rcvd_dt, c1.clm_ln_nbr, c1.clm_ln_stat_cd , c1.RVNU_CD, c1.ln_item_sbmtd_chrg_amt
, c1.pd_amt,
c2.clm_nbr as clm_nbr_, c2.clm_rcvd_dt as clm_rcvd_dt_,
c2.clm_ln_nbr as clm_ln_nbr_, c2.clm_ln_stat_cd as clm_ln_stat_cd_, c2.rvnu_cd as rvnu_cd_, c2.ln_item_sbmtd_chrg_amt
as ln_item_sbmtd_chrg_amt_, c2.pd_amt as pd_amt_
into final_
FROM NW_ALL_3 AS c1, NW_ALL_3 AS c2
WHERE c1.MBR_NBR = c2.MBR_NBR and left(c1.CLM_LN_PROC_CD, 5) = left(c2.CLM_LN_PROC_CD,5)
and c1.CLM_DT_OF_SRVC = c2.CLM_DT_OF_SRVC and c1.SVCG_PRACTNR_ID = c2.SVCG_PRACTNR_ID
AND left(c1.Clm_nbr, 10) < left(c2.CLM_NBR, 10) ;
quit;
... View more