BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ambadi007
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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;

Ksharp
Super User
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-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 683 views
  • 0 likes
  • 3 in conversation