Hi Statalist,

I have a panel dataset (monthly survey responses) which is defined by a firm id variable and a monthly time variable (format example: 2021m1) and has around 30 variables total. One of these variables are current firm sales. I'm looking to generate a new variable that calculates firm yearly sales growth rates from that current sales variables with the firms that have responses that are 12 months apart. For those firms that don't have responses 12 months apart, this variable would just be a dot so that these observations can be dropped later. I've used tsset FIRM_ID mdate to be able to use the time series operators but am not sure where to go from here.

I've used dataex to show a sample of my data below, however the mdate column has been converted to numbers (e.g. 748) but in my data editor it's under the format 2021m1.

input long FIRM_ID float(C_SALE mdate)
38 1.40e+07 748
100 3.50e+08 747
210 2850000 758
337 60000 746
563 3000000 744
799 3.50e+07 754
1258 629927 755
1612 150000 756
1638 75000 751
1936 300 752

Best,
Matt