Announcement

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

  • Creating a subsample with missing value restrictions

    Dear all
    From the entire sample list ,I would like to create a sub-sample based on certain condtions.Say, I have 3 variables,assets,profits&sales.I want to create a subsample by imposing certain conditions on the specified variables and here is what I did.

    gen estsample = 1 if assets>=0&profits>100&sales<200000.
    It turns out that wherever the values are missing for all of these, estample 1 is created. I want stata to keep it as missing ,if either of these variables are missing.How to do this
    Thanks in advance

  • #2
    Right afterward
    Code:
    replace estsample = . if missing(assets, profits, sales)
    Or change the line to
    Code:
    generate byte estsample = 1 if assets >= 0 & !mi(assets) & profits > 100 & !mi(profits) & sales < 200000
    It's a little unusual to want a flag variable to be one or missing. It's easier to use, to refer to, when it's zero (false) or one (true).

    Comment


    • #3
      Thank you very much, Joseph

      Comment

      Working...
      X