10-30-2017 08:09 PM - edited 10-31-2017 12:33 AM
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?
10-30-2017 08:26 PM
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.
11-03-2017 07:15 AM
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
then do; enroll_from=max(startdates(_N_),'01jan2015'd);
do _N_=_N_+1 to dim(startdates) while(not enrolled);
if startdates(_N_)>'31dec20017'd then
if startdates(_N_)-enroll_to>45 then
drop enroll_from enroll_to;