Announcement

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

  • unable to replace string variable with string variable, r(109)

    hello all,

    I'm trying to replace a string variable with a string variable so that ultimately i can just convert it all to a numeric variable and do some data analysis, but i'm stuck on the first step.

    . describe dm_int

    Variable Storage Display Value
    name type format label Variable label
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    dm_int str5 %9s


    . replace dm_int = "4" if dm_int ="<4.0"
    type mismatch
    r(109);

    I'm very confused as to why this type mismatch is showing up.

    Any advice?

  • #2
    Yes, that's not a helpful error message. The problem is that you need to have two equal signs when you're trying to evaluate a condition:
    Code:
    replace dm_int = "4" if dm_int == "<4.0"

    Comment


    • #3
      great thanks so much!

      Comment

      Working...
      X