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:
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")
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.