I have a question concerning an efficient way to create an indicator for the date at which an event occurs as a function of a rolling sum. My dataset looks like the one below. Here, AW denotes a credit applied to a person's (denoted by id) account.

I am interested in creating an indicator that indicates the date at which the person reaches five credits in their account. In other words, person 186 has 12 credits in their account. I want to create an indicator for the date at which 186 reaches the fifth and tenth credit, whereas person 010 would only have one indicator because they only have 6 credits.


I am using Stata 14.2. Thanks in advance for any assistance.

MDC

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double id str9 trans_date str2 status_code 
186 "03JAN2019" "AW"
186 "03OCT2019" "AW" 
186 "17JAN2009" "AW" 
186 "26MAY2009" "AW" 
186 "10MAY2009" "AW" 
186 "23APR2011" "AW" 
186 "03JAN2019" "AW" 
186 "03OCT2019" "AW" 
186 "17JAN2009" "AW" 
186 "26MAY2009" "AW" 
186 "10MAY2009" "AW" 
186 "23APR2011" "AW" 
010 "23NOV2009" "AW" 
010 "30OCT2010" "AW" 
010 "08OCT2011" "AW" 
010 "23NOV2009" "AW" 
010 "30OCT2010" "AW" 
010 "08OCT2011" "AW" 
end