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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 418 views
  • 1 like
  • 2 in conversation