Statalist The Stata Listserver


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

Re: st: RE: coding for failure year


From   M Hollis <m73hollis_stata@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: coding for failure year
Date   Fri, 24 Mar 2006 08:07:28 -0800 (PST)

I must admit that I'm still a little puzzled about
what you're trying to do. You seem to be throwing out
failyr data and your new failure criteria is
disappearance from the data.  

Regardless, I think there is an easier version of your
solution.  If you're using unbalanced panel data the
by and bysort commands will save you a lot of
headaches:

bysort orgnr (year): gen failure=_n==_N

and if you don't want observations marked as failures
if the year is 2002 or if there is no reason for
failure, use instead:

bysort orgnr (year): gen failure=_n==_N & year~=2002 &
failreas~=.


--- "Bradley, Steven W" <swb@indiana.edu> wrote:

> OK.  I realize it is not Friday!  I told you I was
> tired but I am now
> answering my own question.
> 
> gen failure=0
> replace failure=1 if orgnr[_n+1] != orgnr[_n]
> 
> note: to correct for those that did not fail and
> should be right
> censored  
> note: failreas is variable that tells reason for
> firm failure
> replace failure=0 if failreas==.
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On
> Behalf Of Bradley,
> Steven W
> Sent: Thursday, March 23, 2006 3:04 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: coding for failure year
> 
> Statalisters,
> 
> A Friday (my brain is dead question).
> 
> I am trying to dummy code failure year.  
> 
> I have repeated observations for companies and
> listed failures but the
> reported failure year typically doesn't match the
> last year of company
> data so I can't dummy code if year=failureyr.  My
> data runs from 1994 to
> 2002 so most firms are right censored but I want to
> code a failure for
> the last year of data for the firms that fail
> earlier than 2002.
> 
> orgnr	      year		startyr	failyr
> 21		1994		1994		2001
> 21		1995		1994		2001
> 25		1994		1994		1999
> 25		1995		1994		1999
> 25		1996		1994		1999
> 
> I was thinking about using the transition by
> organization number (orgnr)
> Something like if orgnr(_n-1)!=orgnr(_n) then.... 
> 
> Thanks for your help,
> 
> Steve  
> 
> 
> *
> *   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/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index