Dear community,
I have an unbalance panel data where I want to create the following variables with some conditions:
Thanks
* Example generated by -dataex-. To install: ssc install dataex
clear
input double fyear float firm_id int ceo_id byte gender
1994 1004 1369 1
1995 1004 1369 1
1996 1004 4832 1
1997 1004 4832 1
1998 1004 4832 1
1999 1004 4832 1
2000 1004 4832 1
2001 1004 4832 1
2002 1004 4832 1
2003 1004 4832 1
2004 1004 4832 1
2005 1004 4832 1
2006 1004 4832 1
2007 1004 4832 1
1993 1013 663 1
1994 1013 663 1
1995 1013 663 1
1996 1013 663 1
1997 1013 663 1
1998 1013 663 1
1999 1013 663 1
2000 1013 663 1
2001 1013 4242 1
2002 1013 4242 1
2004 1013 4900 1
2005 1013 4900 1
2006 1013 4900 1
2007 1013 4900 1
2008 1013 4900 1
1994 1034 4612 1
1995 1034 4612 1
1996 1034 4612 1
1997 1034 4612 1
1998 1034 4612 1
1999 1034 3551 1
2000 1034 5325 0
2001 1034 5325 0
2002 1034 5325 0
2003 1034 5325 0
2004 1034 5325 0
2005 1034 5325 0
2006 1034 3433 1
2007 1034 3433 1
1993 1045 1012 1
1994 1045 1012 1
1995 1045 1012 1
1996 1045 1012 1
1997 1045 1012 1
1998 1045 749 1
1999 1045 749 1
2000 1045 749 1
2001 1045 749 1
2002 1045 749 1
2003 1045 145 1
2004 1045 145 1
2005 1045 145 1
2006 1045 145 1
2007 1045 145 1
2008 1045 145 1
1993 1055 4039 1
1994 1055 4039 1
1995 1055 4039 1
1996 1055 1218 1
1999 1056 407 1
2000 1056 407 1
2001 1056 407 1
2002 1056 407 1
2003 1056 407 1
2004 1056 407 1
2005 1056 407 1
2006 1056 407 1
2000 1072 4247 1
2001 1072 1789 1
2002 1072 1789 1
2003 1072 1789 1
2004 1072 1789 1
2005 1072 1789 1
2006 1072 1789 1
2007 1072 1789 1
1993 1075 4692 1
1994 1075 4692 1
1995 1075 4692 1
1996 1075 4692 1
1997 1075 4692 1
1998 1075 4692 1
1999 1075 3974 1
2000 1075 3974 1
2001 1075 3974 1
2002 1075 3974 1
2003 1075 3974 1
2004 1075 3974 1
2005 1075 3974 1
2006 1075 3974 1
2007 1075 3974 1
2008 1075 3974 1
1998 1076 3026 1
1999 1076 3026 1
2000 1076 3026 1
2001 1076 3026 1
2002 1076 3026 1
end
I have an unbalance panel data where I want to create the following variables with some conditions:
- Dummy variable for the changes in CEO.
- Dummies for Transitions of CEOs from female to male and male to female.
- Both pre-and post-transition CEOs are in the data (office) consecutively for at least three years excluding the transition year.
- A dummy variable that equals 1 if a firm-year is after a (female to male) CEO transition, and 0 if a firm-year is before a CEO transition.
Thanks
* Example generated by -dataex-. To install: ssc install dataex
clear
input double fyear float firm_id int ceo_id byte gender
1994 1004 1369 1
1995 1004 1369 1
1996 1004 4832 1
1997 1004 4832 1
1998 1004 4832 1
1999 1004 4832 1
2000 1004 4832 1
2001 1004 4832 1
2002 1004 4832 1
2003 1004 4832 1
2004 1004 4832 1
2005 1004 4832 1
2006 1004 4832 1
2007 1004 4832 1
1993 1013 663 1
1994 1013 663 1
1995 1013 663 1
1996 1013 663 1
1997 1013 663 1
1998 1013 663 1
1999 1013 663 1
2000 1013 663 1
2001 1013 4242 1
2002 1013 4242 1
2004 1013 4900 1
2005 1013 4900 1
2006 1013 4900 1
2007 1013 4900 1
2008 1013 4900 1
1994 1034 4612 1
1995 1034 4612 1
1996 1034 4612 1
1997 1034 4612 1
1998 1034 4612 1
1999 1034 3551 1
2000 1034 5325 0
2001 1034 5325 0
2002 1034 5325 0
2003 1034 5325 0
2004 1034 5325 0
2005 1034 5325 0
2006 1034 3433 1
2007 1034 3433 1
1993 1045 1012 1
1994 1045 1012 1
1995 1045 1012 1
1996 1045 1012 1
1997 1045 1012 1
1998 1045 749 1
1999 1045 749 1
2000 1045 749 1
2001 1045 749 1
2002 1045 749 1
2003 1045 145 1
2004 1045 145 1
2005 1045 145 1
2006 1045 145 1
2007 1045 145 1
2008 1045 145 1
1993 1055 4039 1
1994 1055 4039 1
1995 1055 4039 1
1996 1055 1218 1
1999 1056 407 1
2000 1056 407 1
2001 1056 407 1
2002 1056 407 1
2003 1056 407 1
2004 1056 407 1
2005 1056 407 1
2006 1056 407 1
2000 1072 4247 1
2001 1072 1789 1
2002 1072 1789 1
2003 1072 1789 1
2004 1072 1789 1
2005 1072 1789 1
2006 1072 1789 1
2007 1072 1789 1
1993 1075 4692 1
1994 1075 4692 1
1995 1075 4692 1
1996 1075 4692 1
1997 1075 4692 1
1998 1075 4692 1
1999 1075 3974 1
2000 1075 3974 1
2001 1075 3974 1
2002 1075 3974 1
2003 1075 3974 1
2004 1075 3974 1
2005 1075 3974 1
2006 1075 3974 1
2007 1075 3974 1
2008 1075 3974 1
1998 1076 3026 1
1999 1076 3026 1
2000 1076 3026 1
2001 1076 3026 1
2002 1076 3026 1
end
Comment