I created year dummy variables for my dataset using the command
tab YearEffective, gen(dummyyear)
however, this way, a dummy variable for each year is created, not respecting the dummy variable trap. Do you have any suggestions apart from manually removing one of the dummy variables to avoid the dummy variable trap in this regard?
Best wishes
Christopher
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERMNO float YearEffective byte(dummyyear1 dummyyear2 dummyyear3 dummyyear4 dummyyear5 dummyyear6 dummyyear7 dummyyear8 dummyyear9) 10078 2002 1 0 0 0 0 0 0 0 0 10078 2003 0 1 0 0 0 0 0 0 0 10078 2004 0 0 1 0 0 0 0 0 0 10078 2005 0 0 0 1 0 0 0 0 0 10078 2006 0 0 0 0 1 0 0 0 0 10078 2007 0 0 0 0 0 1 0 0 0 10078 2008 0 0 0 0 0 0 1 0 0 10078 2009 0 0 0 0 0 0 0 1 0 10078 2010 0 0 0 0 0 0 0 0 1 10104 2002 1 0 0 0 0 0 0 0 0 10104 2003 0 1 0 0 0 0 0 0 0 10104 2004 0 0 1 0 0 0 0 0 0 10104 2005 0 0 0 1 0 0 0 0 0 10104 2006 0 0 0 0 1 0 0 0 0 10104 2007 0 0 0 0 0 1 0 0 0 10104 2008 0 0 0 0 0 0 1 0 0 10104 2009 0 0 0 0 0 0 0 1 0 10104 2010 0 0 0 0 0 0 0 0 1 10107 2002 1 0 0 0 0 0 0 0 0 10107 2003 0 1 0 0 0 0 0 0 0 10107 2004 0 0 1 0 0 0 0 0 0 10107 2005 0 0 0 1 0 0 0 0 0 10107 2006 0 0 0 0 1 0 0 0 0 10107 2007 0 0 0 0 0 1 0 0 0 10107 2008 0 0 0 0 0 0 1 0 0 10107 2009 0 0 0 0 0 0 0 1 0 10107 2010 0 0 0 0 0 0 0 0 1 10147 2002 1 0 0 0 0 0 0 0 0 10147 2003 0 1 0 0 0 0 0 0 0 10147 2004 0 0 1 0 0 0 0 0 0 10147 2005 0 0 0 1 0 0 0 0 0 10147 2006 0 0 0 0 1 0 0 0 0 10147 2007 0 0 0 0 0 1 0 0 0 10147 2008 0 0 0 0 0 0 1 0 0 10147 2009 0 0 0 0 0 0 0 1 0 10147 2010 0 0 0 0 0 0 0 0 1 10302 2002 1 0 0 0 0 0 0 0 0 10302 2003 0 1 0 0 0 0 0 0 0 10302 2004 0 0 1 0 0 0 0 0 0 10302 2005 0 0 0 1 0 0 0 0 0 10302 2006 0 0 0 0 1 0 0 0 0 10302 2007 0 0 0 0 0 1 0 0 0 10302 2008 0 0 0 0 0 0 1 0 0 10302 2009 0 0 0 0 0 0 0 1 0 10302 2010 0 0 0 0 0 0 0 0 1 10696 2002 1 0 0 0 0 0 0 0 0 10696 2003 0 1 0 0 0 0 0 0 0 10696 2004 0 0 1 0 0 0 0 0 0 10696 2005 0 0 0 1 0 0 0 0 0 10696 2006 0 0 0 0 1 0 0 0 0 10696 2007 0 0 0 0 0 1 0 0 0 10696 2008 0 0 0 0 0 0 1 0 0 10696 2009 0 0 0 0 0 0 0 1 0 10696 2010 0 0 0 0 0 0 0 0 1 11403 2002 1 0 0 0 0 0 0 0 0 11403 2003 0 1 0 0 0 0 0 0 0 11403 2004 0 0 1 0 0 0 0 0 0 11403 2005 0 0 0 1 0 0 0 0 0 11403 2006 0 0 0 0 1 0 0 0 0 11403 2007 0 0 0 0 0 1 0 0 0 11403 2008 0 0 0 0 0 0 1 0 0 11403 2009 0 0 0 0 0 0 0 1 0 11403 2010 0 0 0 0 0 0 0 0 1 11531 2002 1 0 0 0 0 0 0 0 0 11531 2003 0 1 0 0 0 0 0 0 0 11531 2004 0 0 1 0 0 0 0 0 0 11531 2005 0 0 0 1 0 0 0 0 0 11531 2006 0 0 0 0 1 0 0 0 0 11531 2007 0 0 0 0 0 1 0 0 0 11531 2008 0 0 0 0 0 0 1 0 0 11531 2009 0 0 0 0 0 0 0 1 0 11531 2010 0 0 0 0 0 0 0 0 1 11552 2002 1 0 0 0 0 0 0 0 0 11552 2003 0 1 0 0 0 0 0 0 0 11552 2004 0 0 1 0 0 0 0 0 0 11552 2005 0 0 0 1 0 0 0 0 0 11552 2006 0 0 0 0 1 0 0 0 0 11552 2007 0 0 0 0 0 1 0 0 0 11552 2008 0 0 0 0 0 0 1 0 0 11552 2009 0 0 0 0 0 0 0 1 0 11552 2010 0 0 0 0 0 0 0 0 1 11976 2002 1 0 0 0 0 0 0 0 0 11976 2003 0 1 0 0 0 0 0 0 0 11976 2004 0 0 1 0 0 0 0 0 0 11976 2005 0 0 0 1 0 0 0 0 0 11976 2006 0 0 0 0 1 0 0 0 0 11976 2007 0 0 0 0 0 1 0 0 0 11976 2008 0 0 0 0 0 0 1 0 0 11976 2009 0 0 0 0 0 0 0 1 0 11976 2010 0 0 0 0 0 0 0 0 1 12067 2002 1 0 0 0 0 0 0 0 0 12067 2003 0 1 0 0 0 0 0 0 0 12067 2004 0 0 1 0 0 0 0 0 0 12067 2005 0 0 0 1 0 0 0 0 0 12067 2006 0 0 0 0 1 0 0 0 0 12067 2007 0 0 0 0 0 1 0 0 0 12067 2008 0 0 0 0 0 0 1 0 0 12067 2009 0 0 0 0 0 0 0 1 0 12067 2010 0 0 0 0 0 0 0 0 1 12490 2002 1 0 0 0 0 0 0 0 0 end
0 Response to Avoiding dummy variable trap using "tab, gen" command
Post a Comment