Hi,
I have a panel which observes firms over a 7 year period from 2015 to 2021.
I want to create a new variable (EmployeeChange) which is the difference between that period and the last.
To give an example of what I want
My code is as follows:
However it doesn't do anything.
Any help much appreciated.
I have a panel which observes firms over a 7 year period from 2015 to 2021.
I want to create a new variable (EmployeeChange) which is the difference between that period and the last.
To give an example of what I want
Serial | Year | NumEmployee | EmployeeChange |
1 | 2015 | 5 | . |
1 | 2016 | 10 | 5 |
1 | 2017 | 12 | 2 |
etc. |
My code is as follows:
Code:
xtset Serial Year bys Serial Year: gen EmployeeChange = NumEmployee[_n]-NumEmployee[_n-1]
Any help much appreciated.
Comment