BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Student77
Obsidian | Level 7

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:

Student77_0-1640494491940.png

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

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.

Student77
Obsidian | Level 7
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;
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller
Student77
Obsidian | Level 7

whoa, that's it?! I was trying to do a do loop with an indicator for each month prior and proc sql -_-

 

Thanks!!

PaigeMiller
Diamond | Level 26

@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?

--
Paige Miller
PaigeMiller
Diamond | Level 26

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/

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1655 views
  • 2 likes
  • 3 in conversation