Dear Statalist,

I have a data sample like this:
Username Event time How many events happened within a month after first one
A 2019-05-03 2
A 2019-05-13
A 2019-05-29
A 2019-09-27
B 2020-10-01 1
B 2020-10-18
B 2020-11-9
I would like to calculate how many events of one user happened within a month after his/her first event. For example, in this sample, for user A, the number of events that happened after 2019-05-03 is 3, but within a month, is 2. I do not know how to calculate the number 3, since my dataset is very large.

Could you give me some advice?

Thanks a lot!

Best,
Iris Ru