Dear Stata Experts,
I wish to create a dummy variable to capture a situation where the variable co-option does not change in at least two consecutive years. the data is given below for your reference. Please guide me for this estimation.
Thank you so much
dataex gvkey fyear co-option
----------------------- copy starting from the next line -----------------------
I wish to create a dummy variable to capture a situation where the variable co-option does not change in at least two consecutive years. the data is given below for your reference. Please guide me for this estimation.
Thank you so much
dataex gvkey fyear co-option
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(gvkey fyear) float co-option 1004 1996 1 1004 1997 0 1004 1998 0 1004 1999 0 1004 2000 0 1004 2001 .25 1004 2002 .3333333 1004 2003 .5 1004 2004 .625 1004 2005 .8571429 1004 2006 .8888889 1004 2007 .9090909 1013 1996 .3 1013 1997 .3636364 1013 1998 .3636364 1013 1999 .3333333 1013 2000 .7 1013 2001 .625 1013 2002 .3 1013 2003 .3636364 1013 2004 0 1013 2005 .3076923 1013 2006 .3333333 1013 2007 .4 1013 2008 .4 1034 1997 0 1034 1998 .22222222 1034 1999 .22222222 1034 2000 .11111111 1034 2001 .11111111 1034 2002 .3 1034 2003 .6666667 1034 2004 .6666667 1034 2005 .7 1034 2006 .5 1034 2007 .5 1045 1996 .7 1045 1997 .7 1045 1998 .75 1045 1999 .0909091 1045 2000 .2 1045 2001 .3 1045 2002 .4166667 1072 2000 .5 1072 2001 .5 1078 1996 .1818182 1078 1997 .2 1078 1998 .4375 1078 1999 .07692308 1078 2000 .08333334 1078 2001 .23076923 1078 2002 .2857143 1078 2003 .3076923 1078 2004 .3076923 1078 2005 .3571429 1078 2006 .3846154 1078 2007 .4615385 1078 2008 .4615385 1111 2003 1 1111 2004 1 1111 2005 1 1111 2006 1 1111 2007 1 1115 1996 .2 1115 1997 .3333333 1115 1998 0 1115 1999 .14285715 1164 1996 .625 1164 1997 .6666667 1164 1998 .7272727 1164 1999 .8235294 1164 2000 .7857143 1164 2001 .75 1203 1996 .375 1203 1997 .375 1203 1998 .375 1209 1996 .5555556 1209 1997 .6363636 1209 1998 .6666667 1209 1999 .7692308 1209 2000 .7692308 1209 2001 .9090909 1209 2002 .1818182 1209 2003 .27272728 1209 2004 .4 1209 2005 .54545456 1209 2006 .54545456 1209 2007 .625 1209 2008 0 1213 1996 .625 1213 1997 .6666667 1213 1998 .6666667 1213 1999 .6666667 1213 2000 .6666667 1213 2001 .7 1213 2002 .875 1230 1996 0 1230 1997 .11111111 1230 1998 .11111111 1230 1999 .22222222 end

Comment