DATA Step, Macro, Functions and more

Exclude all claim entries from a specific enrolid-year combination of dx codes appear after index da

Reply
Contributor
Posts: 46

Exclude all claim entries from a specific enrolid-year combination of dx codes appear after index da

I have a list of inpatient claims ("compiled_ip_index_1") where all enrolids are confirmed to be continuously eligible. Dataset also includes the following vars: 

 

  • enrolid: identifies a patient 
  • year: year the data is from (2010 - 2014) 
  • index_dt: date when the first diagnosis of a specified disease happens, given to each unique enrolid-year combination
  • dx1: primary diagnosis for which the claim was submitted for
  • dtstart: start date of claim

 How do I exclude all claim entries from a specific enrolid-year combination if a series of exclusionary codes happen to that enrolid-year after index date? 

 

I'm thinking of something like the following. Haven't tested it out -- is there any way to make this more elegant? Is the below syntax OK? 

 

%let excl_code = '123', '12345', '4567', '1859', '9084'

data excluded_enrolid_year;
	set compiled_ip;
	keep enrolid year;
	where dx1 in &excl_code and dtstart >= index_dt;
run;

data final_compiled_ip;
	set compiled_ip_index_1;
	drop select distinct enrolid, year from excluded_enrolid_year;
def2=1 run;

Thank you so much! (the last part def2=1 I just want to flag that these entries qualify under "def 2") 

 

Esteemed Advisor
Posts: 5,523

Re: Exclude all claim entries from a specific enrolid-year combination of dx codes appear after inde

Why haven't you tried your code? That would be the logical thing to do before posting to this forum.

 

From my partial understanding of your requirements, your code should be:

 

%let excl_code = ('123' '12345' '4567' '1859' '9084');

data excluded_enrolid_year;
	set compiled_ip;
	keep enrolid year;
	where dx1 in &excl_code. and dtstart >= index_dt;
run;

proc sql;
create table final_compiled_ip as
select * 
from compiled_ip_index_1 as a
where not exists (select * from excluded_enrolid_year where enrolId=a.enrolId and year=a.year);
quit;

(untested)

 

Could also be done with a merge operation in a data step, I guess.

PG
Contributor
Posts: 46

Re: Exclude all claim entries from a specific enrolid-year combination of dx codes appear after inde

My system is down and I’ve been trying to work around that! But thank you! I’ll try this ASAP
Ask a Question
Discussion stats
  • 2 replies
  • 185 views
  • 1 like
  • 2 in conversation