I am doing a project using firm level dataset (unbalanced panel data). I have around 200,000 firms for 10 years. However, the start and end of each firm period differ: some firms start at 1990 and finish at 2000 and others start at 2005 and finish at 2015. I would like to calculate the investment rate using tangible fixed asset (TFA) which is basically (TFA(t)-TFA(t-1))/TFA(t-1) for each firm in Stata. Would you help me on this issue?
* Example generated by -dataex-. To install: ssc install dataex
clear
input long ID int dec31year double TFA
1 18992 1638309000
1 19358 1430424000
1 19723 2618977000
1 20088 2.799e+09
1 20453 3507431000
1 20819 4219361000
1 21184 4347613000
1 21549 3.9619e+09
1 21914 5100955000
1 22280 5404411000
2 19358 1.5479e+10
2 19723 1.3219e+10
2 20088 1.3387e+10
2 20453 1.4867e+10
2 20819 1.636e+10
2 21184 1.6547e+10
2 21549 1.6146e+10
2 21914 1.4011e+10
2 22280 1.3141e+10
2 22645 1.3311e+10
3 19358 3.201e+09
3 19723 2.945e+09
3 20088 2.955e+09
3 20453 2.630e+09
3 20819 2.375e+09
3 21184 2.233e+09
3 21549 2.166e+09
3 21914 2.177e+09
3 22280 2.015e+09
3 22645 2.122e+09
4 18992 1425000
4 19358 395837000
4 19723 385710000
4 20088 98745000
4 20453 20387000
4 20819 1636000
4 21184 1499000
4 21549 1365000
4 21914 1439000
4 22280 92866000
5 18992 4.5909e+10
5 19358 4.6606e+10
5 19723 4.5531e+10
5 20088 4.5645e+10
5 20453 4.627e+10
5 20819 4.6155e+10
5 21184 4.5847e+10
5 21549 4.5774e+10
5 21914 4.7443e+10
5 22280 4.7853e+10
6 19358 232641000
6 19723 231892000
6 20088 190669000
6 20453 227862000
6 20819 288878000
6 21184 302291000
6 21549 694925000
6 21914 8.190e+08
6 22280 7.730e+08
6 22645 6.480e+08
7 19358 1288758000
7 19723 1217425000
7 20088 1121128000
7 20453 1033546000
7 20819 964263000
7 21184 1020210000
7 21549 1087107000
7 21914 1272572000
7 22280 1310794000
7 22645 1227395000
8 19358 2463088000
8 19723 2630901000
8 20088 2811077000
8 20453 3041447000
8 20819 3257302000
8 21184 4388377000
8 21549 4427479000
8 21914 4741731000
8 22280 4845817000
8 22645 5005846000
9 19083 609320000
9 19448 619372000
9 19813 618904000
9 20178 853070000
9 20544 838932000
9 20909 785931000
9 21274 773765000
9 21639 760809000
9 22005 760693000
9 22370 860146000
10 18992 1617674000
10 19358 1590728000
10 19723 1554051000
10 20088 1445113000
10 20453 1351322000
10 20819 1224924000
10 21184 1081895000
10 21549 133179000
10 21914 114626000
10 22280 110914000
end
format %td dec31year
. * Example generated by -dataex-. To install: ssc install dataex
. clear
. input long ID int dec31year double TFA
ID dec31y~r TFA
1. 44 19389 857299000
2. 44 19754 1230192000
3. 44 20119 1474218000
4. 44 20484 1517779000
5. 44 20850 1542684000
6. 44 21184 1522782000
7. 44 21549 1577352000
8. 44 21914 1642480000
9. 44 22280 1506011000
10. 44 22645 1564853000
11. end
. format %td dec31year