I have a table as below
| Year | Month | Income |
----------------------------------------
| 2020 | 1 | 50 |
| 2020 | 4 | 70 |
| 2021 | 2 | 80 |
| 2021 | 11 | 70 |
| 2022 | 9 | 50 |
| 2022 | 11 | 54 |
| 2022 | 12 | 90 |
| 2023 | 2 | 70 |
| 2023 | 4 | 50 |
| 2023 | 6 | 40 |
| 2023 | 10 | 30 |
--------------------------------------
I would like to create a table from the have where year is the most recent year and the previous year. I do not want to use "where year in (2022, 2023)" because the year may change.
I tried in two different ways,
Data want; set have;
where year ge last.year-1;
run;
Data want; set have;
where year ge max.year-1;
run;
Thanks for your help