Hi, I am very much confused by how Mata treats missing
values in logical expression. Long time ago, I learned
that "." used in logical expressions evaluates to TRUE
in Stata. However, look at this:
. mata
: if (.) 1
> else 2
1
: if (!.) 1
> else 2
1
: end
This behavior does not make sense to me. Furthermore,
it is in contrast to -help m2_op_logical-: "!a, when
a is a scalar, evaluates to 1 if a is not equal to
zero and 1 otherwise." Clearly, "." is not zero.
Note, that in Stata code, the expression evaluates as
expected:
. if . di 1
1
. else di 2
. if !. di 1
. else di 2
2
What could be the reason for this inconsitency?
ben
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/