The same as PG's .
data have;
input ID DOS :mmddyy. Category $;
format dos mmddyy10.;
datalines;
111 1/2/2015 PT/OT
111 1/3/2015 PT/OT
111 3/5/2016 Chiro
111 2/6/2017 PT/OT
222 5/6/2015 Chiro
222 7/8/2016 Chiro
222 8/10/2016 PT/OT
222 9/10/2016 Chiro
222 9/10/2017 PT/OT
222 10/11/2017 Chiro
;
data want;
set have;
by id ;
retain temp;
if first.id then do;temp=dos;output;end;
else if intnx('year',temp,1,'s')=<dos then do;temp=dos;output;end;
drop temp;
run;
... View more