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

RE: Missing as true - Was: Re: st: RE: Another Stata feature


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: Missing as true - Was: Re: st: RE: Another Stata feature
Date   Thu, 8 Jan 2004 10:22:27 -0000

This is an issue that comes up repeatedly, and with 
very good reason. We should blame Aristotle, Aquinas, 
Leibniz, Boole and various others, no doubt. 

However, it is, I guess, far too late to allow what 
Bill wants to be done. 

Or, what amounts to the same thing, it is too 
radical. 

Suppose in version 9, <snafu> is treated as true if 
<snafu> is non-zero and non-missing, while the previous 
syntax (non-zero is sufficient) is allowed under 
version control. I suspect that this woould in turn be 
a source of confusion, _especially_ for 
longstanding Stata users. 

Pandora's brother opened the box long ago 
and it cannot now be shut. 

What I think is a bit more likely is 
some other syntactical way of doing this. 

What about some functions 

pos() 

nonzero() 

pos() would return 1 if its argument was positive
and non-missing and 0 otherwise. 

nonzero() would return 1 if its argument
was non-zero and non-missing and 0 otherwise.

if pos(snafu) 

would then be 

a way of writing 

if snafu > 0 & snafu < . 

Nick 
[email protected] 

Bill Rising
 
> >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.
> 
> It is well documented, and I suspect that there is a good 
> internal coding 
> reason for it, since C assumes that non-zero (i.e. any bit 
> non-zero) is 
> true, and missing values have non-zero bits. Still, it 
> would make Stata 
> code easier to read and less prone to error if people could 
> code the 
> incorrect
> 
> regress foo bar if snafu
> 
> instead of the correct
> 
> regress foo bar if snafu & snafu < .
> 
> for snafu being some sort of indicator which could be missing. 
> 
> I've used Stata long enough that the latter comes natural 
> to me. Still, 
> I'd hate to see how many analyses have been found invalid 
> because of 
> folks forgetting the extra 'less than missing' clause.

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