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

Hi All, below is the data I have. I am trying to delete all rows of observations with proc_cd = 23 or proc_cd = 34. In addition, if a claim_id had a proc_cd = 23 or a proc_cd = 34, I also want to delete all the other rows associated with that claim_id. Below is the data "want". You see that only claim_id = 2 and claim_id = 5 are left since they never had a proc_cd = 23 or proc_cd = 34.

 

data have;
input claim_id proc_cd $ value icd $;
cards;
3 23 34 G5601
3 J20 34 J2
3 J2234 34 G5602
3 J22340 34 G5603
2 123 34 G5603
2 12314 34 C
1 23 64 C
12 23 87 C
4 34 98 G5601
4 35 34 asd
5 35 34 G5602
;
run;

 

 

data want;
input claim_id proc_cd $ value icd $;
cards;
2 123 34 G5603
2 12314 34 C
5 35 34 G5602
;
run;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data have;
input claim_id proc_cd $ value icd $;
cards;
3 23 34 G5601
3 J20 34 J2
3 J2234 34 G5602
3 J22340 34 G5603
2 123 34 G5603
2 12314 34 C
1 23 64 C
12 23 87 C
4 34 98 G5601
4 35 34 asd
5 35 34 G5602
;
run;

proc sql;
create table want as
select *
from have
where claim_id not in
(select distinct claim_id from have where proc_cd in ('23','34'));
quit;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

data have;
input claim_id proc_cd $ value icd $;
cards;
3 23 34 G5601
3 J20 34 J2
3 J2234 34 G5602
3 J22340 34 G5603
2 123 34 G5603
2 12314 34 C
1 23 64 C
12 23 87 C
4 34 98 G5601
4 35 34 asd
5 35 34 G5602
;
run;

proc sql;
create table want as
select *
from have
where claim_id not in
(select distinct claim_id from have where proc_cd in ('23','34'));
quit;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 693 views
  • 1 like
  • 2 in conversation