New Contributor
Posts: 3

# Determining continuous enrollment for 6 months

[ Edited ]

I have a dataset that looks similar to this

MemberID   StartDate1   EndDate1    Startdate2     Enddate2 StartDate3 EndDate3...StartDate20 Enddate20

XXXXXX     01Jun2013  30Jul2015

XXXXXX     01Aug2015 31Dec2016   01Feb2017    01Sep2017

XXXXXX     15Jan2012  15Dec2017

XXXXXX     01Jan2014  01May2014  15June2014  15Aug2016

I have to determine 6 months of continuous enrollment with an allowable gap of 45 days during a two year measure period, lets say Jan 01 2015-Dec 31, 2017. There is no anchor date. So essentially, I want to check all enrollment dates between Jan 01 2015 and December 31st 2017 and see if they have at least 6 months of continuous enrollment. I'm not sure how to approach this when there are multiple start and end dates. Does anyone have any suggestions?

Super User
Posts: 23,724

## Re: Determining continuous enrollment for 6 months

Post some more example data and the corresponding expected output.

If you search on here, it's been answered multiple times, but with a different data structure, a long rather than wide data set.

PROC Star
Posts: 265

## Re: Determining continuous enrollment for 6 months

Something like this may work (not tested):

```data want;
set have;
array startdates startdate1-startdate20;
array enddates enddate1-enddate20;  enrolled=0;
do _N_=1 to dim(startdates); /* find first enrollment within interval */    if '01jan2015'd<=enddates(_N_)<='31dec2017'd or       '01jan2015'd<=startdates(_N_)<='31dec2017'd       then do;
enroll_from=max(startdates(_N_),'01jan2015'd);      enroll_to=min(enddates(_N_),'31dec2017'd);      enrolled=intck('month',enroll_from,enroll_to,'C')>=6;      leave;      end;    end;  do _N_=_N_+1 to dim(startdates) while(not enrolled);    if startdates(_N_)>'31dec20017'd then      leave;    if startdates(_N_)-enroll_to>45 then      enroll_from=startdates(_N_);    enroll_to=min(enddates(_N_),'31dec2017'd);    enrolled=intck('month',enroll_from,enroll_to,'C')>=6;    end;  drop enroll_from enroll_to;run;```
Discussion stats
• 2 replies
• 339 views
• 0 likes
• 3 in conversation