I was asked recently in a Q&A, "how to select the last 5 years worth of data from a table in SAS?" One way of doing it is by selecting the data with a Proc SQL query similar to the following, and something similar could also be done in a data step:

  create table mywindow as
  select ...myvariables...
    from mylib.mytable
    where year(mydate) between year(today())-5 and year(today());

Caveat emptor, this is really only going to include the last 4 complete years and whatever portion of the current year is in the dataset. This is because year() truncates out the month and day of the date.

Of course, this is just one way to do it. By using the intnx function, more advanced intervals can be done.

SAS Documentation: