Dear Stata users:
I have a question regarding generating dummy variables for whether the events still continue. I have a panel dataset shown below. The variable "time" means how long this event continues. For instance, the first row denotes the event that happened to id==1 in 2000 and continues for 3 years.
year id time dummy
2000 1 3 1
2001 1
2002 1
2003 1
2004 1
2005 1 2 1
2006 1
2007 1
2008 1
2009 1
2010 1
2000 2
2001 2
2002 2 5 1
2003 2
2004 2
2005 2
2006 2
2007 2
2008 2
2009 2
2010 2
I want to generate a dummy to denote whether this event still continues to this year on this id. So, I want to replace the dummy variable with the following:
year id time dummy
2000 1 3 1
2001 1 1
2002 1 1
2003 1
2004 1
2005 1 2 1
2006 1 1
2007 1
2008 1
2009 1
2010 1
2000 2
2001 2
2002 2 5 1
2003 2 1
2004 2 1
2005 2 1
2006 2 1
2007 2
2008 2
2009 2
2010 2
How to code this please?
I have a question regarding generating dummy variables for whether the events still continue. I have a panel dataset shown below. The variable "time" means how long this event continues. For instance, the first row denotes the event that happened to id==1 in 2000 and continues for 3 years.
year id time dummy
2000 1 3 1
2001 1
2002 1
2003 1
2004 1
2005 1 2 1
2006 1
2007 1
2008 1
2009 1
2010 1
2000 2
2001 2
2002 2 5 1
2003 2
2004 2
2005 2
2006 2
2007 2
2008 2
2009 2
2010 2
I want to generate a dummy to denote whether this event still continues to this year on this id. So, I want to replace the dummy variable with the following:
year id time dummy
2000 1 3 1
2001 1 1
2002 1 1
2003 1
2004 1
2005 1 2 1
2006 1 1
2007 1
2008 1
2009 1
2010 1
2000 2
2001 2
2002 2 5 1
2003 2 1
2004 2 1
2005 2 1
2006 2 1
2007 2
2008 2
2009 2
2010 2
How to code this please?
Comment