I am using the replace command to recode a string variable countrycode to a numeric variable ccode.
But the replace command has no effect. Stata gives no error messages, bt just says "0 changes made" after each line.
countrycode is a 3-character string.
This is the syntax:
gen ccode=-9
replace ccode=371 if countrycode=="arm"
replace ccode=900 if countrycode=="aus"
replace ccode=339 if countrycode=="alb"
replace ccode=160 if countrycode=="arg"
How can I convert the data to numeric?
The code was correct, but the string variable was all caps, and I had used lower-case characters. Thanks for the tip!