An answer is that Stata has no idea of what is
sensible, misleading, silly, etc. or generally any idea
of meaning or semantics.
It only has rules of syntax. What you wrote is
legal syntax, but not what you mean, given order
of evaluation rules in particular.
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Jan
> Pettersson
> Sent: 12 March 2004 13:54
> To: [email protected]
> Subject: st: Re: Trouble with " if"
>
>
> Shouldn't
>
> if `i'==`j' & `j' ==`k' {
>
> work?
> /Jan
>
> ----- Original Message -----
> From: "Christophe Bontemps" <[email protected]>
> To: <[email protected]>
> Sent: Friday, March 12, 2004 2:45 PM
> Subject: st: Trouble with " if"
>
>
> > Hi Everybody,
> > I find strange the way stata handle a double equality
> condition in "if"
> > statements
> >
> > Running the following trible loop on i, j and k with a
> condition like"
> if
> > `i'==`j'==`k' " gives a wrong answer, no warnings, no errors.
> > Of course i know the solution for this problem but why does
> Stata accept
> > these misleading statements in "if" ?
> > running on Stata 8 SE the following :
> > forvalues i = 1/3 {
> > forvalues j = 1/3 {
> > forvalues k = 1/3 {
> > display in yellow " i=`i' j=`j' k=`k' "
> >
> > if `i'==`j'==`k' {
> > di in green " case 1"
> > }
> > else {
> > di in red "case 2"
> > }
> > }
> > }
> > }
> > Gives
> > i=1 j=1 k=1
> > case 1
> > i=1 j=1 k=2
> > case 2
> > .
> > .
> > i=2 j=2 k=1
> > case 1
> > i=2 j=2 k=2
> > case 2
> > i=2 j=2 k=3
> > .
> > .
> > i=3 j=3 k=1
> > case 1
> > i=3 j=3 k=2
> > case 2
> > i=3 j=3 k=3
> > case 2
> >
> >
> > Thanks
> >
> > *
> > * 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/
> >
>
> *
> * 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/
>
*
* 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/