I have 20 string variables (VAR_1-VAR_20) that show different codes. I need to create an indicator equals to one if one of these variables have a specific string (e.g., A10) and no other strings. I could only write a very tedious code that does that manually for each combination. Something like:
I have no idea how to code a nice loop. Can someone help please?
Code:
gen dummy=0 replace dummy=1 if VAR_1=="A10" & VAR_2=="" & VAR_3=="" & ... & VAR_20=="" replace dummy=1 if VAR_1=="" & VAR_2=="A10" & ... & VAR_20=="" . . . replace dummy=1 if VAR_1=="" & VAR_2=="" & ... & & VAR_20=="A10"
Comment