please try
data have;
input Id Dateofjoining :date9.;
diff=coalesce(dif(Dateofjoining),0);
if not (diff<0);
cards;
101 21Aug2018
102 22Aug2018
103 17Aug2018
104 25Aug2018
105 27Aug2018
106 18Aug2018
107 30Aug2018
;
data have;
input Id Date : date9.;
format date date9.;
cards;
101 21Aug2018
102 22Aug2018
103 17Aug2018
104 25Aug2018
;
data want;
set have;
retain temp;
if temp<date then temp=date;
else flag=1;
drop temp;
run;
temp hold the max date when go through the table.
101 21Aug2018
102 22Aug2018
103 17Aug2018
100 18Aug2018
104 25Aug2018
;
103 and 100 is you want removed ?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.