Hi @Dhuang0925, No problem, I really like this question. Basically, I do not care about the order it which months are. If I sum the “1”s for all months and see that there are fewer of them than my index month from which I look backwards, then I know for sure a person discontinued enrollment. Hence, this statement: If months_enrolled < index_month then continuous_enrol = 0; Otherwise, I do not want the sum for all months_enrolled, because there could be some “1”s behind and some ahead of my observation point (index_month), and I would not know. Instead what I do is sum enrols up until my month Sum(enrol[1]:enrol[index_month]) Now if the sum is less than my month number, I would know there was a break and continuous_enrol = 0. Maybe I can just do this last step and not care about total months. Please let me know if you have more questions. Best wishes.
... View more