I have a dataset like this:
string_var | var1 | var2 | var3
var2 | 8 | 8 | 4
var3 | 7 | 5 | 7
var2 | 10 | 10 | 5
I need to test whether var1 is equal to either var2 or var3, depending on the string that is contained in string_var. My problem is to convert these strings into variable names to do something like:
gen test=1 if var1==string_var
where, after the ==, I need some kind of conversion function to let Stata read the string e.g. var2 as the following:
gen test=1 if var1==var2