Announcement

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

  • Mistake in the Stata FAQs?

    Can anybody explain to me how the following code from a Stata FAQ works. It is confusing to me. This is the FAQ: http://www.stata.com/support/faqs/da...ble-recording/

    And this is the section:

    Second, what if missing values are present? For numeric variables, missing counts as higher than any other numeric value, but egen, max() is smart enough to ignore it. Only if all values in a group are missing will the result variable be missing.

    Occasionally, you may want a strict definition of all—that literally all values in a group must possess the characteristic, with no missing values allowed. Here is one approach


    . egen anymiss = max(sex), by(family)
    . egen allfem = min(sex) if !anymiss, by(family)



    I've played around with it and it doesn't seem to accomplish what the FAQ claims it does, namely, flag families that have all females and no missing sex values.
    Last edited by Tom Rogers; 02 Nov 2016, 11:37.

  • #2
    I think you're right. The code needs to be
    Code:
    egen anymiss = max(missing(sex)), by(family)
    as the max() function ignores missings to the extent possible. Good catch and sorry for the confusion. No excuses, but that seems to have been there as an error since 2003!

    Comment


    • #3
      This is now fixed with thanks to Tom. (StataCorp fixed this within 24 hours of my sending it; the delay was just other stuff on my list.)

      Comment


      • #4
        Don't look now, but an identical error reoccurs a few lines later.

        Comment


        • #5
          Nils Enevoldsen Thanks for your vigilance. We'll get it fixed.

          Comment

          Working...
          X