Good morning everyone,
Please how to get 5 year intervals difference of variables from panel in stata?.
Ps:difference not average
Please how to get 5 year intervals difference of variables from panel in stata?.
Ps:difference not average
* Example generated by -dataex-. To install: ssc install dataex clear input float(id year) int x 1 2001 54 1 2002 29 1 2003 46 1 2004 71 1 2005 27 1 2006 72 1 2007 56 1 2008 70 1 2009 33 1 2010 56 2 2001 74 2 2002 41 2 2003 35 2 2004 72 2 2005 71 2 2006 41 2 2007 72 2 2008 69 2 2009 38 2 2010 27 end xtset id year generate x5 = x - L5.x list, sepby(id)
. xtset id year panel variable: id (strongly balanced) time variable: year, 2001 to 2010 delta: 1 unit . generate x5 = x - L5.x (10 missing values generated) . list, sepby(id) +----------------------+ | id year x x5 | |----------------------| 1. | 1 2001 54 . | 2. | 1 2002 29 . | 3. | 1 2003 46 . | 4. | 1 2004 71 . | 5. | 1 2005 27 . | 6. | 1 2006 72 18 | 7. | 1 2007 56 27 | 8. | 1 2008 70 24 | 9. | 1 2009 33 -38 | 10. | 1 2010 56 29 | |----------------------| 11. | 2 2001 74 . | 12. | 2 2002 41 . | 13. | 2 2003 35 . | 14. | 2 2004 72 . | 15. | 2 2005 71 . | 16. | 2 2006 41 -33 | 17. | 2 2007 72 31 | 18. | 2 2008 69 34 | 19. | 2 2009 38 -34 | 20. | 2 2010 27 -44 | +----------------------+
Comment