I have a question about efficiently calculating rates using panel data. Specifically, I have a dataset that looks like the one below. Here, AW denotes a credit applied to a person's (denoted by id) account, SP denotes when a credit is used, and EX denotes if that credit is expired.

I am interested in calculating the rate that credits get used within 3 and 12 months of receipt. That is, what fraction of people earning a credit on a date, use a credit within 3 months and 12 months of that date?

I am using Stata 14.2. Thanks in advance for the help.

MDC

Code:
clear
input double id str9 trans_date str2 status_code float amount
186 "03JAN2019" "EX" 20
186 "03OCT2019" "AW" 20
186 "17JAN2009" "AW" 20
186 "26MAY2009" "SP" 20
186 "10MAY2009" "AW" 20
186 "23APR2011" "SP" 20
010 "23NOV2009" "AW" 20
010 "30OCT2010" "AW" 20
010 "08OCT2011" "AW" 20
652 "30NOV2018" "SP" 20
652 "30OCT2018" "AW" 20
652 "02MAY2018" "AW" 20
652 "03DEC2016" "EX" 20
652 "04FEB2019" "AW" 20
652 "05APR2015" "SP" 20 
652 "19JUL2016" "AW" 20
123 "11OCT2013" "SP" 20
123 "16JUN2013" "AW" 20
123 "17FEB2012" "SP" 20
123 "19MAR2011" "EX" 20
123 "09JAN2010" "AW" 20
123 "25MAR2015" "SP" 20
123 "02OCT2007" "AW" 20
123 "05APR2008" "AW" 20
123 "24MAY2008" "AW" 20
540 "08OCT2011" "AW" 20
540 "30DEC2016" "SP" 20
540 "05OCT2007" "AW" 20
end