Announcement

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

  • labmask error

    Hi,
    I am using Stata 14 on Windows. I have tried implementing the labmask command and encountered the following error "x not constant within groups of y". Any work around on this?

    Thanks in advance.

  • #2
    Not in my book, because you would be trying to undermine the logic of labmask.

    labmask (Stata Journal, as you are asked to explain; see FAQ Advice #12.1) asks that users sees the values (or optionally the value labels) of one variable rather than another in output: what you see is thus a "mask" on the face of a variable.

    Consider this:

    Code:
    clear
    input y str4 mask
    1  "frog"
    1  "frog"
    1  "frog"
    1  "toad"
    2  "toad"
    2  "toad"
    end
    labmask y, values(mask)
    labmask fails because there isn't a one-to-one correspondence:

    Code:
     
    1 <-> "frog"
    2 <-> "toad"
    is violated in one observation. You can't program around this because labmask is just a wrapper that defines value labels for you and you can't have different value labels for the same value.

    I see two possibilities:

    1. What you want to do makes sense, but you can't do it this way.

    2. labmask has found an inconsistency in your data.

    http://www.stata-journal.com/sjpdf.h...iclenum=gr0034 may be of interest.

    Comment


    • #3
      Thanks so much Nick Cox I completely agree with you. I have been able to figure out the inconsistency in my data set. Much appreciated.

      Comment


      • #4
        Hi, I am experiencing an error with labmask in Stata 15. I have a banded income variable y01, which I want to generate and mask into income . I am using:

        gen income = y01
        labmask income, val(y01) decode

        However, Stata produces the error message r;(110) - "label income already defined". It has worked fine when tried with other variables. Thanks.

        Comment


        • #5
          Hi Joe,

          You are tyring to generate a label that already exists. Try using a different name like income2.

          Thank you.

          Comment

          Working...
          X