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]
Re: st: RE: RE: if qualifier
From
Richard Williams <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: RE: if qualifier
Date
Wed, 10 Jul 2013 17:01:52 -0400
Also, my rule of thumb is to explicitly specify & or | whenever more than 1 test is being made. When I try to take a shortcut, as in the original command below, it often doesn't work the way I expect it to. I understand now why the original command did what it did but that isn't what my intuition would have led me to expect. And since my intuition is so often wrong I just write a more detailed command that (I think) will work right.
Sent from my iPad
On Jul 10, 2013, at 4:29 PM, "Cohen, Elan" <[email protected]> wrote:
> A few more examples that helped me through this:
>
> . di 0<1<2
> 1
> // 0 is less than 1 which evaluates to true, or 1
> // 1 is less than 2 which evaluates to 1
>
> . di -4<-3<0
> 0
> // -4 is less than -3 which evaluates to true, or 1
> // 1 is not less than 0 which evaluates to 0
>
>
> Thanks for your help.
>
> - Elan
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Sarah Edgington
> Sent: Wednesday, July 10, 2013 16:16
> To: [email protected]
> Subject: st: RE: if qualifier
>
> Elan,
> It appears to be just ignoring the <20.
> That is, it's that same result as -count if 10<mpg-
> I'm also surprised it doesn't give an error (I'd expect "invalid <20").
> -S
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Cohen, Elan
> Sent: Wednesday, July 10, 2013 12:24 PM
> To: [email protected]
> Subject: st: if qualifier
>
> All,
>
> 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?
>
> - Elan
>
>
> --
> Elan D Cohen, MS
> Center for Research on Health Care Data Center University of Pittsburgh
>
>
>
> *
> * 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/
>
> *
> * 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/
>
>
> *
> * 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/
*
* 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/