Thanks a lot! Your code helps me almost get there. One scenario somehow got dropped although I expect that to be kept. I just added Person_ID 66666 to HAVE data, where I expected the first four records (1/14/2018-2/12/2018) to be kept because there was no records within 30 days to have Eligible=0.
data have;
infile datalines truncover dsd;
input Person_ID $ Begin_Date :mmddyy10. End_Date :mmddyy10. Eligible Eligible_30_day Final_Eligible;
format Begin_Date End_Date mmddyy10.;
datalines;
111111,3/13/2018,3/15/2018,0,.,0
111111,4/24/2018,4/26/2018,0,0,0
111111,7/13/2018,7/14/2018,0,0,0
111111,7/14/2018,7/19/2018,1,1,1
111111,7/26/2018,7/30/2018,1,1,1
111111,11/17/2018,11/26/2018,1,0,1
222222,5/1/2018,5/4/2018,0,.,0
222222,5/17/2018,5/19/2018,1,1,1
333333,3/8/2018,3/9/2018,0,.,0
333333,4/17/2018,4/26/2018,0,0,0
333333,6/16/2018,6/20/2018,0,0,0
333333,7/3/2018,7/4/2018,0,1,0
333333,7/23/2018,7/24/2018,0,1,0
333333,8/9/2018,8/10/2018,0,1,0
333333,9/8/2018,9/11/2018,1,1,0
333333,9/11/2018,9/14/2018,1,1,0
333333,9/23/2018,9/26/2018,0,1,0
444444,7/5/2018,7/7/2018,0,.,0
444444,12/21/2018,12/28/2018,1,0,1
555555,4/28/2018,5/3/2018,1,.,1
555555,5/6/2018,5/10/2018,1,1,1
555555,11/26/2018,11/29/2018,1,0,1
666666,1/14/2018,1/24/2018,1,.,1
666666,1/29/2018,1/31/2018,1,1,1
666666,2/4/2018,2/5/2018,1,1,1
666666,2/7/2018,2/12/2018,1,1,1
666666,8/18/2018,8/23/2018,1,0,0
666666,8/24/2018,8/25/2018,1,1,0
666666,8/28/2018,9/3/2018,1,1,0
666666,9/6/2018,9/11/2018,1,1,0
666666,9/13/2018,9/16/2018,1,1,0
666666,9/22/2018,9/23/2018,0,1,0
666666,10/3/2018,10/16/2018,1,1,0
666666,11/4/2018,11/5/2018,1,1,0
666666,11/5/2018,11/12/2018,1,1,0
666666,12/25/2018,12/28/2018,1,0,0
666666,12/30/2018,12/31/2018,0,1,0
;
run;
... View more