Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cleaning the "n.a" in my dataset using Stata

    To replace the missing values "n.a" to "", I used the following code:

    Code:
    ds, has(type string)
    quietly foreach v in `r(varlist)'{
    replace `v' = "" if inlist(`v', "n.a")
    }
    However, after using such code, the numbers are still in red/string format. How can I change all string variables to numeric variables so that Stata can understand them?
    Note: I have a lot of variables with different names (e.g. age, number of qualifications).

  • #2
    Code:
    help destring

    Comment


    • #3
      In addition to Nick's helpful advice, if you simply wish to covert strings of numeric values to numbers, and convert anything with text into a missing value, then you can do the following.

      Code:
      gen double new_var = real(var)

      Comment


      • #4
        Thanks.

        Comment

        Working...
        X