I am trying to convert a string variable (type str2, format %9s) into an indicator variable in Stata.
However, I keep receiving the following error:
type mismatch r(109)
I am using the 2016 ANES set and I am essentially trying to group states into open primary and closed primary/caucus states.
I have attempted the following code:
gen oprim= (state=="AL" & "AK" & "CO" & "GA" &...)
gen oprim=1 if state=="AL" & "AK" & "CO" & "GA" &...
I have had trouble converting this variable before. for example, I tried generating the new indicator variable without putting quotations around the state codes.
I have also tried to destring the variable, but I am receiving the following output:
destring state, generate(statenum) float
state: contains nonnumeric characters; no **generate**
Any help anyone could offer would be much appreciated.
dataex. Read here for more information. - user8682794