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/