I have a data set and it contains Claim sfx and amount , I need to remove the duplicates claim , but the problem here is there could be different sfx in the same claim , if its different for the same claim then I need to keep that claim
Claim sfx amount
100 23 897
100 23 897
101 25 789
101 89 463 Need to keep this Claim because of different sfx
102 56 789
102 56 789 Need to delete this becase of same sfx
data have;
input Claim sfx amount ;
cards;
100 23 897
100 23 897
101 25 789
101 89 463
102 56 789
102 56 789
;
run;
proc sql;
create table want as
select *
from have
group by claim
having count(distinct sfx) ne 1;
quit;
SAS can do this fairly easily:
proc sort data=have nodupkey;
by claim sfx;
run;
However, you should also consider what is the right outcome when CLAIM is the same, SFX is the same, but AMOUNT changes. perhaps you should go with:
proc sort data=have nodupkey;
by claim sfx amount;
run;
data have;
input Claim sfx amount ;
cards;
100 23 897
100 23 897
101 25 789
101 89 463
102 56 789
102 56 789
;
run;
proc sql;
create table want as
select *
from have
group by claim
having count(distinct sfx) ne 1;
quit;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.