Dear Peter, thanks for your prompt response, it seems working using your data. I am not exactly sure what the code is doing. What if I change the rules now, say instead of at least past two consecutive year, I am now requiring past three consecutive year (t-3, t-2, t-1) has div = 0, and current year (t) div = 1, and at least next two consecutive year (t+1, t+2) has div = 1. I will have to explore other rules, but helping with this change will help me to understand what your code is doing, thank you.
... View more