Announcement

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

  • How to calculate variables with one year lag

    Dear members
    I’m trying to creat new variable_ sales growth calculated as ( current year sales - last year sales)/ last year sales.

    kindly, can anyone provide me with the code in calculating the above wanted variable?

    thanks in advance

  • #2
    Saleh:
    you may want to try something along the following lines:
    Code:
    . use "https://www.stata-press.com/data/r17/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . tsset idcode year
    
    Panel variable: idcode (unbalanced)
     Time variable: year, 68 to 88, but with gaps
             Delta: 1 unit
    
    . g wanted=L1.ln_wage
    
    . list ln_wage wanted year if idcode==1
    
           +----------------------------+
           |  ln_wage     wanted   year |
           |----------------------------|
        1. | 1.451214          .     70 |
        2. |  1.02862   1.451214     71 |
        3. | 1.589977    1.02862     72 |
        4. | 1.780273   1.589977     73 |
        5. | 1.777012          .     75 |
           |----------------------------|
        6. | 1.778681          .     77 |
        7. | 2.493976   1.778681     78 |
        8. | 2.551715          .     80 |
        9. | 2.420261          .     83 |
       10. | 2.614172          .     85 |
           |----------------------------|
       11. | 2.536374          .     87 |
       12. | 2.462927   2.536374     88 |
           +----------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Triplicate post also answered at https://www.statalist.org/forums/for...ons-with-a-lag

      Comment

      Working...
      X