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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.