Hello everyone,
I am facing an issue with coding. What I want to do is create three groups of string observations (variable "country") based on the strength of voting enforcement: strong, weak and voluntary. I have a group of countries that would correspond to each variable. My idea was to code it as follows:
gen voting_enforcement = ""
replace voting_enforcement = "strong" if country == "Argentina" | country == "Brazil" | country == "Chile" | country == "Bolivia" | country == "Ecuador" | country == "Uruguay" | country == "Peru"
But it says there is a type mismatch, which means that I am combining variables that cannot be combined. I don't understand how I can do it in some other way.
I am facing an issue with coding. What I want to do is create three groups of string observations (variable "country") based on the strength of voting enforcement: strong, weak and voluntary. I have a group of countries that would correspond to each variable. My idea was to code it as follows:
gen voting_enforcement = ""
replace voting_enforcement = "strong" if country == "Argentina" | country == "Brazil" | country == "Chile" | country == "Bolivia" | country == "Ecuador" | country == "Uruguay" | country == "Peru"
But it says there is a type mismatch, which means that I am combining variables that cannot be combined. I don't understand how I can do it in some other way.

Comment