I have an unbalanced panel data set in Stata. With observations from 1993 to 2013. I have a variable named bankrupcty year which indicates the year each company went bankrupt. The problem is that my Stata file is missing up to 2 years before each company went bankrupt. That is, a company went bankrupt in 2003, the last observation for the company is in 2002 or 2001. I do however want to create a dummy variable for when the company went bankrupt, but since I am missing that year I am unable to perform the command:
gen bankrupt=0
replace bankrupt=1 if year==bankruptcyyear
What I want to do is add years for each company so that I am able to add the dummy variable to the correct year of bankruptcy.
orgnumber year bankruptcyyear
810037342 2009 0
810037342 2010 0
810037342 2011 0
810037342 2012 0
810044292 1993 2006
810044292 1994 2006
810044292 1995 2006
810044292 1996 2006
810044292 1997 2006
810044292 1998 2006
810044292 1999 2006
810044292 2000 2006
810044292 2001 2006
810044292 2002 2006
810044292 2003 2006
810044292 2004 2006
810044292 2005 2006
810059672 1995 0
810059672 1996 0
810059672 2000 0