I believe you're overthinking the problem - if you sort your data by accountno and month then, in a data step, use the lag function to look back one, two and three periods by accountno then you'll find it much easier. I suspect your solution would run into multiple complexities with a rolling three month span.
One thing to be careful of with lag() though is - "don't use it inside conditional statements" or you'll get incorrect results.
If you post a datastep to create some sample data and some desired output we can give you a more detailed answer.
... View more