Dear Statalist users,
I have a panel dataset from 1974-2014 set to xtreg on Stata 14. I have created a dummy variable ("suffrage_dummy") that takes the value 1 for the year of the introduction of universal suffrage (between this period 1974-2014). I have generated another dummy variable ("suffrage_dummy2") that takes the same value as "suffrage_dummy". I want to replace the values of this "suffrage_dummy2" variable with value 1 conditional on two criteria:
1. if the year is higher than the establishment of universal suffrage AND
2. if the average in range (for those years higher than the one when the suffrage is introduced) is equal to 1.
For example,
In this example, Palestine introduced universal suffrage in 1996 (look at the value of "v2x_suffr"), which remained until 2014, the last year of observation in my dataset. Since the years 1997-2014 are higher than 1996 (condition 1 above fulfilled) and the average value of suffrage in this period is equal to 1 (condition 2 fulfilled), the value of "suffrage_dummy2" would take the value of 1.
In this other illustration below, Bhutan introduced universal suffrage (look at the value of "v2x_suffr") in 2007 but in 2014, reduced it to 0.98. Therefore, the value for "suffrage_dummy2" should take on the value of 0 for the years 2008-2014 since the average suffrage in those years are less than 1 (owing to the value of 0.98 in 2014):
The trick is that not all countries who gave universal suffrage in this period 1974-2014 introduced universal suffrage at the same time. I have been looking at these two sites for inspiration but I am unable to crack it as yet:
Any help will be much appreciated.
Ashvinder
I have a panel dataset from 1974-2014 set to xtreg on Stata 14. I have created a dummy variable ("suffrage_dummy") that takes the value 1 for the year of the introduction of universal suffrage (between this period 1974-2014). I have generated another dummy variable ("suffrage_dummy2") that takes the same value as "suffrage_dummy". I want to replace the values of this "suffrage_dummy2" variable with value 1 conditional on two criteria:
1. if the year is higher than the establishment of universal suffrage AND
2. if the average in range (for those years higher than the one when the suffrage is introduced) is equal to 1.
For example,
Code:
year country v2x_suffr suffrage_dummy suffrage_dummy2 1994 Palestine/West Bank 0 0 0 1995 Palestine/West Bank 0 0 0 1996 Palestine/West Bank 1 1 1 1997 Palestine/West Bank 1 0 0 1998 Palestine/West Bank 1 0 0 1999 Palestine/West Bank 1 0 0 2000 Palestine/West Bank 1 0 0 2001 Palestine/West Bank 1 0 0 2002 Palestine/West Bank 1 0 0 2003 Palestine/West Bank 1 0 0 2004 Palestine/West Bank 1 0 0 2005 Palestine/West Bank 1 0 0 2006 Palestine/West Bank 1 0 0 2007 Palestine/West Bank 1 0 0 2008 Palestine/West Bank 1 0 0 2009 Palestine/West Bank 1 0 0 2010 Palestine/West Bank 1 0 0 2011 Palestine/West Bank 1 0 0 2012 Palestine/West Bank 1 0 0 2013 Palestine/West Bank 1 0 0 2014 Palestine/West Bank 1 0 0
In this other illustration below, Bhutan introduced universal suffrage (look at the value of "v2x_suffr") in 2007 but in 2014, reduced it to 0.98. Therefore, the value for "suffrage_dummy2" should take on the value of 0 for the years 2008-2014 since the average suffrage in those years are less than 1 (owing to the value of 0.98 in 2014):
Code:
year country v2x_suffr suffrage_dummy suffrage_dummy2 2006 Bhutan 0 0 0 2007 Bhutan 0 0 0 2008 Bhutan 1 1 1 2009 Bhutan 1 0 0 2010 Bhutan 1 0 0 2011 Bhutan 1 0 0 2012 Bhutan 1 0 0 2013 Bhutan 1 0 0 2014 Bhutan .98 0 0
HTML Code:
https://www.stata.com/statalist/archive/2004-02/msg00759.html#
HTML Code:
https://stats.idre.ucla.edu/stata/modules/creating-and-recoding-variables/
Ashvinder
Comment