Alternatively, you may try:
data have;
input member case start_date :mmddyy10. end_date :mmddyy10.;
format start_date end_date yymmdd10.;
datalines;
1 1 01/01/2019 01/31/2019
1 2 01/03/2019 01/04/2019
1 3 01/14/2019 01/18/2019
1 4 02/15/2019 02/20/2019
1 5 02/18/2019 02/22/2019
;
proc sql;
select min(start_date)-1, max(end_date)+1
into :d1, :d2
from have;
quit;
data want;
array d_{&d1.:&d2.};
do until(last.member);
set have; by member;
do i = start_date to end_date;
d_{i} = case;
end;
end;
do i = &d1.+1 to &d2-1;
if missing(d_{i-1}) and d_{i} then do;
start_case = d_{i};
start_date = i;
end;
if d_{i} and missing(d_{i+1}) then do;
end_case = d_{i};
end_date = i;
output;
end;
end;
drop d_: i case;
run;
proc print data=want noobs; run;
variable case is replaced by first_case and end_case which my differ in some overlap situations.
... View more