Hi,
I've constructed a dataset that includes information about the political party in office for every town between 2002-2014. Elections were held in 2002, 2008 and 2014, so there are 3 election cycles: from 2002-end 2007, 2008-end 2013, and 2014-end 2014 (when my observation period ends). I want to create a variable that indicates whether there was a change in political party for each town between election cycles and how many changes there were total (0, 1 or 2) for the entire observation period.
The variables I have are:
polparty_4: categorical variable labeled as left, center, right, other
code_insee: unique identifier for each town
year: from 2002-2014
I've created the following variables based on the above:
generate party07 = polparty_4 if year==2007
generate party08 = polparty_4 if year==2008
generate party13 = polparty_4 if year==2013
generate party14 = polparty_4 if year==2014
My plan was to create a binary variable coded as 0 if party07=party08 (or party13=party14) for a particular commune, and 1 otherwise.
However, I'm struggling to generate the binary variable grouped by town (code_insee), as well as the count variable for the total number of changes in each town.
Thanks for your help!
I've constructed a dataset that includes information about the political party in office for every town between 2002-2014. Elections were held in 2002, 2008 and 2014, so there are 3 election cycles: from 2002-end 2007, 2008-end 2013, and 2014-end 2014 (when my observation period ends). I want to create a variable that indicates whether there was a change in political party for each town between election cycles and how many changes there were total (0, 1 or 2) for the entire observation period.
The variables I have are:
polparty_4: categorical variable labeled as left, center, right, other
code_insee: unique identifier for each town
year: from 2002-2014
I've created the following variables based on the above:
generate party07 = polparty_4 if year==2007
generate party08 = polparty_4 if year==2008
generate party13 = polparty_4 if year==2013
generate party14 = polparty_4 if year==2014
My plan was to create a binary variable coded as 0 if party07=party08 (or party13=party14) for a particular commune, and 1 otherwise.
However, I'm struggling to generate the binary variable grouped by town (code_insee), as well as the count variable for the total number of changes in each town.
Thanks for your help!
Comment