Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Average earnings over 5 subsequent years

    Hi everyone,

    I would like to calculate the average earnings per firm over 5 subsequent years. My sample consists of the earnings information from the years 1975 to 2003. Does anyone know how to generate this new variable: average earnings over 5 subsequent years?

    I hope someone can help! Thank you in advance!

  • #2
    rangestat from SSC offers one solution. That is a good search term to find hundreds of mentions here. Or you could follow https://www.statalist.org/forums/help#stata and give a data example. Or this analogue could be enough:


    Code:
    .   webuse grunfeld, clear
    
    . 
    . rangestat (count)  invest (mean) invest, int(year 1 5) by(company)
    
    
    .  l invest* year if company == 1
    
         +--------------------------------------+
         | invest   invest~t   invest_~n   year |
         |--------------------------------------|
      1. |  317.6          5      370.42   1935 |
      2. |  391.8          5      394.46   1936 |
      3. |  410.6          5      401.94   1937 |
      4. |  257.7          5      450.32   1938 |
      5. |  330.8          5      493.66   1939 |
         |--------------------------------------|
      6. |  461.2          5      513.66   1940 |
      7. |    512          5      548.88   1941 |
      8. |    448          5      573.06   1942 |
      9. |  499.6          5      578.98   1943 |
     10. |  547.5          5       580.5   1944 |
         |--------------------------------------|
     11. |  561.2          5      596.84   1945 |
     12. |  688.1          5   610.40001   1946 |
     13. |  568.9          5   674.86001   1947 |
     14. |  529.2          5   829.90001   1948 |
     15. |  555.1          5     1016.22   1949 |
         |--------------------------------------|
     16. |  642.9          4     1109.55   1950 |
     17. |  755.9          3   1227.4333   1951 |
     18. |  891.2          2     1395.55   1952 |
     19. | 1304.4          1      1486.7   1953 |
     20. | 1486.7          .           .   1954 |
         +--------------------------------------+

    Comment

    Working...
    X