Announcement

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

  • replace values: type mismatch

    Dear,

    I am trying to replace all my "n.a." values into zeroes for my variable c20_28. However, when I try to do this, I get a type mismatch. The type of the variable I am trying to change is Double. Could you help me out? this is my code:

    Code:
    replace c20_28 = 0 if c20_28 == "n.a."
    type mismatch
    r(109);
    thank you very much!
    Timea

  • #2
    Your question has the answer: A variable of type "double" is a numeric variable, and cannot be compared to a string value. Your variable c20_28 may have a value *label* of "n.a." but not that actual value. A reasonable guess is that this is a missing value such as .a, .b., .c, ... to which someone has assigned a value label of "n.a.." If you knew what that value was, say .a, you could do, for example:
    Code:
    replace c20_28 = 0 if c20_28 == .a
    You might try to find out about this by browsing missing values of this variable with the display of the value labels suppressed:
    Code:
    browse c20_28 if missing(c20_28), nolabel
    If this is confusing to you, my guess would be that you have not yet learned about missing values and value labels. If so, you could help yourself by reading the PDF manual documentation from:
    -help missing-
    -help label value-
    -help datatype-

    Comment

    Working...
    X