Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Missing values in logical expressions in Mata


From   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: Missing values in logical expressions in Mata
Date   Tue, 20 Sep 2005 08:39:16 -0500

Ben Jann <[email protected]> has found a bug in Mata (he called 
it an inconsistency):

	. mata
	: if (.) 1
	> else 2
	  1
	
	: if (!.) 1
	> else 2
	  1                                <-- Mata should display 2
	
	: end

Logical operators in Mata should work the same way they do in Stata:
0 means false and all other values (including missing) mean true.
Hence, the expression (!.) should evaluate to 0.  Instead, it is 
evaluating to missing value.

I checked out the other logical operators (& and |) and they worked as 
intended.  It is just ! that has the problem.

We will fix it in the next executable update. 

-- Bill
[email protected]
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index