You can use AGGREGATE by patient id to create a new variable that computes the last year. Then select only cases with the same year.
First build a random dataset to check the method.
set rng=mc seed=17760704.
new file.
input program.
numeric id (f5) year (f4) some_data (f6.3).
loop #i=1 to 200.
compute #n=trunc(rv.uniform(1,10)).
loop #j=1 to #n.
compute year=trunc(rv.uniform(2000,2010)).
compute some_data=rv.normal(0,1).
compute id=#i.
end case.
end loop.
end loop.
end file.
end input program.
execute.
Two ways to solve the problem with AGGREGATE: either compute the maximum year in each group, or presort by id/year and get the last year in each id group.
aggregate /outfile=* mode=addvariables /break=id /maxyear=max(year).
select if year=maxyear.
execute.
Second method:
sort cases id year.
aggregate /outfile=* mode=addvariables /presorted /break=id /maxyear=last(year).
select if year=maxyear.
execute.
Note that if a patient may have several records with the same year, then the commands above will keep all cases matching the last year.