Announcement

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

  • Generate variables

    Hello everybody

    I am trying to generate a new var GROWTH which is equal to Assets in year t - Assets in year (t-1). Is there someone who could help with the command needed ?

    Thank you in advance

  • #2
    You should tsset or xtset your data and then use time series operators.

    Code:
    help tsset 
    help varlist

    Comment


    • #3
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(year assets)
      2000 10
      2001 12
      2002 16
      2003 22
      2004 30
      2005 40
      end
      
      tsset year
      gen wanted = assets - L.assets
      
      list, clean
      
             year   assets   wanted  
        1.   2000       10        .  
        2.   2001       12        2  
        3.   2002       16        4  
        4.   2003       22        6  
        5.   2004       30        8  
        6.   2005       40       10
      Last edited by Øyvind Snilsberg; 06 May 2022, 02:12. Reason: crossed with #2

      Comment

      Working...
      X