The oldest date and the MAX date are two different things.
I think you want to do this
data have;
input Specimendate_all :mmddyy10. Patient_ID $ Pending $;
format Specimendate_all mmddyy10.;
infile datalines dlm = ',' missover;
datalines;
03/29/22,AB1,NO
03/29/22,AB1,NO
03/29/22,AB1,YES
03/29/22,AB1,NO
04/05/22,AB1,NO
04/05/22,AB1,YES
04/05/22,AB1,YES
04/05/22,AB1,NO
;
proc sql;
create table want as
select *, max(Specimendate_all) as specimenpendingmax format = mmddyy10.
from have
;
quit;
... View more