Hello, I have a hospital dataset and I want to be able to flag rows that are duplicates but meeting different conditions. I need to have four flags each meeting a different condition of duplicates. The dataset that I have has the clients ID, hospital ID, date of service, a service code and a procedure code. The four flags I need are By clients 1. If the hospital ID, date of service, service code and procedure codes have duplicate rows then flag (flag1) 2. If the hospital ID is different but date of service, service code and procedure codes have duplicate rows then have another flag (flag2) 3. If the hospital ID and procedure codes are different but date of service and service code have duplicate rows then have another flag (flag3) 4. If the hospital ID and service codes are different but date of service and procedure code have duplicate rows then have another flag (flag4) I have the below code as a sample. NOTE the 1, 2,3 and 4 in the data set cards are examples of flags that meet the above 4 criteria. Ideally I would need four columns for each criteria and flagging 1 or 0 that meet each criteria. one would have to remove the numbers at the end to run the data step below. data have; input client_ID $ HospitalID $ Date : yymmdd10. Service_cd procedure_cd $; format date yymmdd10.; cards; C001 hsp001 2015/06/03 1568 ABDC C001 hsp001 2015/06/08 1400 ASDF 1 C001 hsp002 2015/06/08 1400 ASDF 1 C001 hsp002 2015/06/08 1568 SEWE C002 hsp002 2015/06/08 1568 RWRW C002 hsp002 2015/06/08 1567 EWRE C002 hsp001 2015/06/08 1567 RRRR 3 C002 hsp003 2015/06/08 1568 RRRR 3 C003 hsp001 2015/06/08 1567 RRRR C003 hsp001 2015/06/08 1567 RRRR 2 C003 hsp003 2015/06/08 1567 EWRE 2 C004 hsp001 2015/06/29 1567 RRRR 4 C004 hsp001 2015/06/29 1567 RRRR 4 C005 hsp001 2015/06/29 1567 RRRR C005 hsp001 2015/06/30 1567 RRRR C005 hsp002 2015/06/30 1567 RRRR ; run; Update below with what I would like to see the output as: This is how I would like to see the output. Each flag column should correspond to each point above. Client_id Hosp_its Date service_code Procdure_code Flag1 flag2 flag3 flag4 C001 hsp001 6/3/2015 1568 ABDC 0 0 0 0 C001 hsp001 6/8/2015 1400 ASDF 1 0 0 0 C001 hsp002 6/8/2015 1400 ASDF 1 0 0 0 C001 hsp002 6/8/2015 1568 SEWE 0 0 0 0 C002 hsp002 6/8/2015 1568 RWRW 0 0 0 0 C002 hsp002 6/8/2015 1567 EWRE 0 0 1 0 C002 hsp001 6/8/2015 1567 RRRR 0 0 1 1 C002 hsp003 6/8/2015 1568 RRRR 0 0 0 1 C003 hsp001 6/8/2015 1567 RRRR 1 0 0 0 C003 hsp001 6/8/2015 1567 RRRR 1 1 0 0 C003 hsp003 6/8/2015 1567 EWRE 0 1 0 0 C004 hsp001 6/29/2015 1567 RRRR 1 0 0 0 C004 hsp001 6/29/2015 1567 RRRR 1 0 0 0 C005 hsp001 6/29/2015 1567 RRRR 0 0 0 0 C005 hsp001 6/30/2015 1567 RRRR 0 1 0 0 C005 hsp002 6/30/2015 1567 RRRR 0 1 0 0 Any assistance would be greatly appreciated!!!
... View more