So you have to (1) look back to see if the current obs is a new id, or follows a gap that is too large, and (2) look forward to see if the current obs is the last for a given id, or precedes a gap that is too large.
Untested, in the absence of sample data in the form of a working DATA step:
%let max_gap=2; /* Maximum allowable "hole" size */
data want (drop=_:);
merge have
have (firstobs=2 keep=id start_date rename=(id=_nxt_id start_date=_nxt_start));
retain _initial_start;
if id^=lag(id) or start-&max_gap > lag(stop_date) then _initial_start=start_date;
if (id^=_nxt_id) or (_nxt_start > stop_date+&max_gap) ; /*Subsetting IF*/
start_date=_initial_start;
run;
This code assumes that the data are grouped by ID, and are sorted chronologically within ID.
... View more