Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Re: if qualifier
From
"Joseph Coveney" <[email protected]>
To
<[email protected]>
Subject
st: Re: if qualifier
Date
Thu, 11 Jul 2013 04:56:03 +0900
Elan Cohen wrote:
I'm not sure what to make of the following:
sysuse auto
count if 10<mpg<20
A SAS-using colleague of mine typed this into Stata. Much to her astonishment,
it returned a valid yet incorrect answer. Much to my astonishment, it did not
return an error.
What is Stata doing here? Is this behavior documented anywhere?
--------------------------------------------------------------------------------
There is no error for Stata to report, and yes the precedence rules for
expression evaluation are documented.
Here, the operators are the same and therefore of the same precedence, and so
the order of expression evaluation is left-to-right: first "10<mpg", which is
true, that is, "1". And then (continuing), it's "1<20", which is also true.
Thus, the expression evaluates as "count if true".
Joseph Coveney
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/