Hi I wasn't able to find anything on the archives adressing this issue.
My data is structured as follows
year state county employment
1 1 1 10
2 1 1 20
1 2 1 15
2 2 1 30
...
for 6 years, 50 states, and some counties in each state. I have 1.5
million observations.
I want to construct a variable that is the difference in employment by
year in each state and county.
I tried
by year state county, sort: gen newvar = employment-employment[_n-1] but that didn't work.