Announcement

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

  • "No observations" problem

    Hello,

    I have a problem when generating new variables out of existing one. I have a variable "pclass" having 1310 observations where some have value 1, some value 2 and some value 3.
    My task was to generate pclass1, pclass2 and pclass3. But when I did, the output was "no observations"

    Does anybody know how would they solve this?

    Thanks

  • #2
    Your code probably looked like
    Code:
    generate pclass1 = 1 if pclass==1
    which will generate missing values in all observations where pclass!=1. So when you included pclass1, pclass2, and pclass3 in whatever command you ran, in any observation two of the three were missing, so Stata ignored every observation.

    Your code should have been
    Code:
    generate pclass1 =  pclass==1
    because the expression
    Code:
    pclass==1
    is 1 when pclass==1 and 0 (not missing) when pclass!=1.

    Comment


    • #3
      You are a life saver!!!
      Thank you

      Comment

      Working...
      X