BookmarkSubscribeRSS Feed
cdubs
Quartz | Level 8

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") 

 

2 REPLIES 2
PGStats
Opal | Level 21

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
cdubs
Quartz | Level 8
My system is down and I’ve been trying to work around that! But thank you! I’ll try this ASAP

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 676 views
  • 1 like
  • 2 in conversation