Hello,
I saw a previous post that suggested to do this with proc sql, and for the past couple hours I try, and I end up with freezing, and restarting SAS. UGH.
In another post, I read that when using proc sql join for larger data, it can take much longer than just data/proc steps.
So I am trying to figure out how to pull patient IDs (patid) for those patients who had continuous insurance enrollment for the full 365 days prior (no breaks), to an index date (fst_dt).
Where I am having difficulty is that a patid may have multiple records, with multiple insurance start/end dates (eligeff and eligend, respectively, and these may have breaks in them.
(all dates YYMMDD10.)
See snip of data below:
for ex. row 26-31 are for the same patid.
#26 the index date is 7-17-2018 , and insurance started 10-1-17 and ended 12-31-2019.
so if the indicator for a person having enrollment 365 days prior is called "eligible", here it would be 0. because insurance started in october the previous year instead of july. So this one doesn't count.
#27 however, does qualify because the insurance start date (10-01-2017) was 365 days before the index, (fst_dt=10-01-2018).
If you look at lines #3 and #4 though, it's not as clear cut--there's a gap between insurance start/end dates between observations for the same patient.
I hope this makes sense. I appreciate any help.
If I am understanding the requirements properly:
data want;
set enrolled;
if eligeff<=fst_dt-365 and eligend>=fst_dt then flag=1;
else flag=0;
run;
Please post your data in usable form. Pictures are not usable.
Post a working data step with datalines that recreates your data into a code box opened with the "little running man" button.
data enrolled;
input patid fst_dt :YYMMDD10. eligeff :YYMMDD10. eligend :YYMMDD10.;
format fst_dt YYMMDD10. eligeff YYMMDD10. eligend YYMMDD10.;
cards;
123 2017-12-13 2017-07-01 2019-05-31
123 2019-02-06 2017-07-01 2019-05-31
212 2018-07-17 2017-10-01 2019-12-31
212 2018-10-01 2017-10-01 2019-12-31
212 2019-02-15 2017-10-01 2019-12-31
212 2019-06-10 2017-10-01 2019-12-31
212 2019-09-11 2017-10-01 2019-12-31
540 2019-05-21 2017-12-01 2019-12-31
;
proc print;
run;
*need to create an indicator variable "eligible" if, a record (each observation line) has continuous enrollment 365 days prior
to index. so (fst_date)-365 =all those date should be included between eligeff and eligend
obs#3 would Not be eligible,
obs#4 would be eligible;
If I am understanding the requirements properly:
data want;
set enrolled;
if eligeff<=fst_dt-365 and eligend>=fst_dt then flag=1;
else flag=0;
run;
whoa, that's it?! I was trying to do a do loop with an indicator for each month prior and proc sql -_-
Thanks!!
@Student77 wrote:
whoa, that's it?! I was trying to do a do loop with an indicator for each month prior and proc sql -_-
Isn't that the logic? Compare the effective date to 365 days before fst_dt and the eligibility end date to fst_dt?
You were asked in your previous thread to provide data in a usable form. Please don't make us ask every time you have a question. We're trying to help you, but you have to help us as well.
Instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.