For the sake of the robust/strong of code, I would like to use this code:
data have;
infile cards expandtabs ;
input id facility $ (amit release) (:date9.);
format amit release date9.;
cards;
1 A 09OCT23 22DEC23
1 B 23JUL24 27AUG24
1 B 27AUG24 30AUG24
1 A 30AUG24 .
2 A 15DEC23 14JAN24
2 B 14JAN24 22JAN24
2 A 22JAN24 08MAR24
;
data temp;
set have;
do date=amit to coalesce(release,date());
output;
end;
keep id facility date;
run;
proc sort data=temp;by id date;run;
data temp2;
set temp;
by id;
if first.id or dif(date)>1 then group+1;
run;
proc sql;
create table want as
select group,id,facility,min(date) as amit format=date9.,ifn(max(date)=date(),.,max(date)) as release format=date9.
from temp2
where facility='A'
group by group,id,facility;
quit;
... View more