How to convert text to numeric in Stata?
Stata: Data Analysis and Statistical Software
If you have a string variable and want to convert it to a numeric variable, you can use the encode command. If you have a string variable that has only numbers in it, then you can alternatively use the real() function.