Good afternoon,

To my surprise I learn to today that the e(sample) function when undefined evaluates to 0, and not to missing, as the following example shows:

Code:
. clear all

. sysuse auto
(1978 Automobile Data)

. summ mpg if e(sample)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         mpg |          0

. summ mpg if e(sample)!=.

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         mpg |         74     21.2973    5.785503         12         41

. gen e = e(sample)

. summ e

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
           e |         74           0           0          0          0

. list e in 1/5

     +---+
     | e |
     |---|
  1. | 0 |
  2. | 0 |
  3. | 0 |
  4. | 0 |
  5. | 0 |
     +---+
So to my surprise 1) e(sample) is always defined, even if I have not estimated anything before; 2) e(sample) is equal to 0, and not to missing.

When I tried to find where this is explained in the manual, I am not finding anything. When I type
Code:
. help e(sample)
only the terse description
e(sample)
Description: 1 if the observation is in the estimation sample and 0 otherwise
Range: 0 to 1

appears.

When I follow up on see [U] 18.8 Accessing results calculated by other programs, there are some mentions of e(sample) but does not really explain how this function behaves. In particular I do not see it anywhere explained that 1) e(sample) is always defined, even if I have not estimated anything before; 2) e(sample) is equal to 0, and not to missing in this case when we have not estimated anything before.