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

RE: st: RE: survey completion "flag"


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: survey completion "flag"
Date   Fri, 18 Feb 2005 17:21:49 -0000

No. And in fact that offers a much cleaner 
solution to the 

missing if any missing 

problem. 

gen max = <safe value>
foreach v of local varlist {
	replace max = cond(`v' > max, `v', max)
}

Nick 
n.j.cox@durham.ac.uk 

Nick Winter
 
> Ah yes, I'd forgotten that.
> 
> So max(a, b) is NOT the same as cond(a>b,a,b).

> At 05:01 PM 2/18/2005 +0000, you wrote:
> >The second problem is well identified.
> >Thanks.
> >
> >The first problem is no problem.
> >
> >max(42, .) is 42, so initialising to
> >missing is safe.
> >
> >This perhaps surprising feature can
> >be rationalised as follows. Given
> >arguments of
> >
> >-1, 0, 1, 2.71828, 3.14159, 42, .
> >
> >would you really want a -max()- function
> >to return missing? It depends on the problem,
> >but it can be forced the other way:
> >
> >gen max = <safe value>
> >foreach v of local varlist {
> >         replace max = cond(`v' == ., ., max(`v', `max')) if !mi(max)
> >}
> >
> >Nick
> >n.j.cox@durham.ac.uk

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index