Hi @shiv999,
Thanks for the additional information. As @novinosrin has said text is better than attachments as some of us are prevented from downloading attachments for security reasons, which is very sensible.
If the data is not always sorted by doj within id then you could use something like the following.
data have;
input
id : 8.
name : $char10.
doj : date9.
dot : date9.
;
format
doj date9.
dot date9.
;
datalines;
11235 Jim 12jul2017 01aug2018
11235 Jim. 12jul2019 01aug2019
11235 Jimcarod 12jan2020 01feb2020
11235 Jimcarod 12jul2020 01aug2020
;
data want(drop = latest:);
length latest_name $ 10;
do until (last.id);
set have;
by id;
latest_doj = max(latest_doj,doj);
latest_name = ifc(latest_doj eq doj,name,latest_name);
end;
do until (last.id);
set have;
by id;
name = latest_name;
output;
end;
run;
Kind regards,
Amir.
... View more