My code was wrong. I had
bysort firm personid (year): gen left = _n == _N
bysort firm year : replace left = 0 if year == year[_N]
by firm year: egen number_left = total(left)
tabdisp firm year, c(number_left)
but it should have been
bysort firm personid (year): gen left = _n == _N
bysort firm (year) : replace left = 0 if year == year[_N]
by firm year: egen number_left = total(left)
tabdisp firm year, c(number_left)
Sorry about that.
As flagged earlier, this counts those who leave even
if they return later in the panel.
Nick
[email protected]
Wanli Zhao
> Nick & David,
> Thank you so much for your help. I tried both solutions. I
> think I got what
> I want from David's code. I just need to reshape the data. I
> really like
> Nick's solution because the simpler, the better. But, I got
> the result of
> all 0 from Nick's solution and I do not know what's wrong.
> I'd like to learn
> more please.
*
* 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/