Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: number of missing from previous year


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: number of missing from previous year
Date   Tue, 15 Aug 2006 22:41:45 +0100

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index