You can possibly "put back" observations removed, by joining the original table (have) with processed one (want) into want1 proc sql; create table want1 as
select a.*, b.baseline_flag
from have a
left join want b
on a.Id = b.id and
a.vsdate = b.vsdate and
a.trtdate = b.trtdate;
quit; sql code which may help proc sql;
create table want as
select * , case
when vsdate eq max(vsdate)
then 'Y'
else ''
end as baseline_flag
from have
where vsdate le trtdate and
vsdate is not missing and
trtdate is not missing
group by id;
quit;
... View more