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.
The 2025 SAS Hackathon has begun!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.