Hi all,
I am working on a dataset consisting of quarterly company data with multiple companies over the period 2000-2020. In the dataset I have quarterly earnings, which I would like to convert in a 4 period rolling yearly earnings. For example in 19Q3 I would like the sum of 18Q4, 19Q1, 19Q2 and 19Q3. However, this needs to be per company, which implies that the code should stop summing the values of the first company when a new companyid is reached and should continue when 4 values of that company are available.
I have tried many things from rangestat to tsegen, but it did not work. Seems like an easy task but already spend 4 hours trying. Could anyone help me with this?
Thanks a lot!
0 Response to Rolling yearly earnings
Post a Comment