I am surprised this has not been suggested yet. Or I couldn't find it.
Some databases allow subsetting a table by taking the first n rows of each subgroups with a data set, sorted by a chosen criterion.
The query usually looks similar to this:
select row_number() over (partition by ID order by DATE desc) RANK from table
Even more useful (luxurious even!) would be to support row-limiting clauses in this new language feature, like:
row_number() over (partition by ID order by DATE desc) fetch first 5 rows only
or fetch first 10 percent with ties
I am aware that the very useful first. and last. operators allow something similar in a data step. That is not the point. 🙂