Here was the code that ended up working for this. Essentially had to make a new ID for each stay and then sort by min start date and max end date based on those IDs. Also a step to account for the missing value. Thanks for the assistance! data want1;
set have;
retain ConsecID 0;
ConsecID= ifn(lag(fullname)^=fullname or lag(location)^=location, ConsecID+1, ConsecID);
run;
PROC SQL;
CREATE TABLE want2 AS
SELECT DISTINCT
FULLNAME
, min(start) as STARTDATE format=date9.
, case when (max(coalesce(end, '01JAN2099'd)))='01JAN2099'd
then .
else (max(end))
end as NEWEND format=date9.
, location
FROM WORK.want1 AS A
group by consecID
order by fullname
;quit;
... View more