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

RE: Missing as true - Was: Re: st: RE: Another Stata feature


From   Richard Williams <[email protected]>
To   [email protected]
Subject   RE: Missing as true - Was: Re: st: RE: Another Stata feature
Date   Thu, 08 Jan 2004 08:23:01 -0500

At 11:50 AM 1/8/2004 +0000, Nick Cox wrote:
Now suppose you want two conditions, in
some combination,

. list if myvar > 0 & yourvar > 0

. list if myvar > 0 | myvar > 0

Now please, for this only slightly
more complicated situation,

1. fill in truth tables

&                 true  false irrelevant
true
false
irrelevant

|                 true  false irrelevant
true
false
irrelevant
This is a toughie, and no matter what you do it will be confusing and error prone. For what it is worth, what the rebel forces seem to be calling for is basically what SPSS does. SPSS's way seems logical to me and if I ruled the world this is how Stata would work. But, having gone down a different path, you don't change things lightly, so perhaps some additional functions or a variation of the if parameter (if2?) would be desirable. Anyway, here are some excerpts from SPSS's documentation on the IF command, which includes a filled in truth table:

"The logical expression is evaluated as true, false, or missing. The assignment is executed only if the logical expression is true... When two or more relations are joined by logical operators AND or OR, the program always returns a missing value if all of the relations in the expression are missing. However, if any one of the relations can be determined, the program interprets the expression as true or false according to the logical outcomes shown in Table 1. The asterisk flags expressions where the program can evaluate the outcome with incomplete information.

Table 1 Logical outcome

true AND true = true
true OR true = true
true AND false = false
true OR false = true
false AND false = false
false OR false = false
true AND missing = missing
true OR missing = true*
missing AND missing = missing
missing OR missing = missing
false AND missing = false*
false OR missing = missing

*
* 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