This worked like a charm.
Thank you so much to everyone who answered.
Kit Baum wrote:
When you have panel data, you should take advantage of the fact. The
solution proposed below can get into trouble with unbalanced panels
if that should ever arise. Once the data have been tsset, you can use
Stata's time series operators, which are easier to use than explicit
subscripting.
sort state county
egen stcounty = group(state county)
sort stcounty year
tsset stcounty year
gen employdiff = D.employment
Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
Begin forwarded message:
You were close but your generate (gen) statement wasn't quite right.
. bysort year state county: gen employdiff = employment - employment
[_n - 1]
(2 missing values generated)
. l, noobs
+---------------------------------------------+
| year state county employ~ employ~f |
|---------------------------------------------|
| 1 1 1 10 . |
| 1 1 1 15 5 |
| 2 2 1 20 . |
| 2 2 1 30 10 |
+---------------------------------------------+
Eric
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/