Strings to Numbers in Stata

  EDS > Stata Numberic Conversion
printer friendly version Print
Page

If you have acquired a dataset where an obviously numeric value is saved as a string, e.g., age_wed, you can convert it to a number with the destring command:
      destring age_wed
destring without a variable list will "destring" the whole dataset. If you happend to have a few non-numeric entries, e.g., a typo like "*)", you can force the conversion with the force option. Non-numeric codes will become missing values. Important Safety Measure: check your codebook and/or run some tabulations before you destring the whole file at once, just in case some of those non-numeric codes are real.