Its quite hard to see what your after from that, test data in the form of a datastep and what you want out will help. Can you not sort the data, then use lag()? SQL can simply merge these too. If its an agregate then a where might be better.
2025 SAS Hackathon: There is still time!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!