How do I convert string variables to numeric variables in Stata?

47,606

Try destring var, replace in Stata if you want to convert var into numeric

Or,

encode var, generate(var1)
Share:
47,606
Exodia16
Author by

Exodia16

Updated on July 13, 2022

Comments

  • Exodia16
    Exodia16 almost 2 years

    I have two variables in Stata, both numeric variables that have somehow been recorded as string variables. I need them converted to numeric variables so that I can generate a new variable with them.

    When I tried, it said type mismatch I have tried the real and the encode commands, none of which are working.