Announcement

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

  • Define all negative values as missings

    Hello, I trying to define all values under 0 of a variable as a missing. I tried:

    . mvdecode tf_job_school , mv (-1:-10000=.a)
    -1:-10000 is not a valid numlist

    . mvdecode tf_job_school , mv (range(<0)=.a)
    range(<0) is not a valid numlist

    Many thanks!

  • #2
    Code:
    replace tf_job_school = . if tf_job_school < 0

    Comment


    • #3
      Michael Rochnia Clyde has solved your problem, but you might still wonder where you went wrong on your mvdecode command. If you look at help mvdecode and click on the numlist in the description of the mv option, you'll be taken to Stata's discussion of numlist syntax, where you can see how you might have specified a list of numbers to be replaced by the missing value. I mention this because numlists are everywhere in Stata, so you will be well served by understanding their syntax.

      Clyde's answer remains the most general solution for your problem, rather than using mvdecode, because if tf_job_school were to take on non integer values, then mvdecode would not be able to handle recoding arbitrary fractional negative values.
      Last edited by William Lisowski; 23 Apr 2015, 13:21.

      Comment


      • #4
        Many thanks!

        Comment

        Working...
        X