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   wgould@stata.com (William Gould, Stata)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Missing values in logical expressions in Mata
Date   Tue, 20 Sep 2005 08:39:16 -0500

Ben Jann <ben.jann@soz.gess.ethz.ch> 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
wgould@stata.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index