Hi all,
I've been reviewing the documentation on Stata to try and figure out how to generate IF NOT statements. Essentially, I have a load of string values for one variable and I want to recode these so that all except a particular value are coded into a 1, and the other value into a 0. I've been using the following code without success, can someone point out where I'm going wrong?
gen newvariable=.
replace newvariable=1 if oldvariable~="N/A"
replace newvariable=0 if oldvariable=="N/A"
Thanks,
Calum
I've been reviewing the documentation on Stata to try and figure out how to generate IF NOT statements. Essentially, I have a load of string values for one variable and I want to recode these so that all except a particular value are coded into a 1, and the other value into a 0. I've been using the following code without success, can someone point out where I'm going wrong?
gen newvariable=.
replace newvariable=1 if oldvariable~="N/A"
replace newvariable=0 if oldvariable=="N/A"
Thanks,
Calum
Comment