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

st: RE: Another Stata feature


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Another Stata feature
Date   Wed, 7 Jan 2004 19:29:39 -0000

I have a problem decoding this, even setting
aside an example of Allan's puckish sense of humour.

One can certainly be bit by forgetting that

	<expression evaluating to numeric missing>

qualifies as true. This may not be what you want,
but the point is very well documented.

However, if -x- is a string variable,
then I suspect that Stata will only allow conditions of
the form

	if <strexp> <op> x

where <strexp> is a string expression
and <op> is an appropriate operator. Other
stuff will just be rejected as illegal syntax.

What is a bug in such circumstances
would seem to boil down to whether
the programmer has correctly codified
what they want, on which Stata is totally
clueless.

I suspect here we need a real example, not a
joke one.

Nick
[email protected]

Allan Reese

> Something which is definitely a feature, being a logical
> consequence of
> the language and documented, is that a missing value for a logical
> expression is treated as "true".  However, I tripped over
> on it and that
> made me wonder if it is a dangerous feature - the
> implication is that any
> program must guard against the possibility.  Consider, for
> example the
> consequences of missing data in code such as:
>
>    if wmd invade x
>
> where x is a string variable.
>
> One approach is a self-imposed discipline to make a rigorous logical
> variable and test:
>
>    if wmd==1 ...
>

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