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

st: RE: Re: by & nearest


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: by & nearest
Date   Tue, 26 Aug 2003 11:25:29 +0100

Scott Merryman replied to Benoit Dulong 
 
> > Is it possible (change the program) to get nearest to 
> work with by ?

> Rather than changing the program you could use foreach to 
> call -nearest- for
> each group.
> 
> Example:
> 
> levels id, local(levels)
> foreach l of local levels {
>      nearest x y if idrep == `l' , id(idpoint`l') dist(h`l')
>       }
> 

To expand a bit on Scott's reply: 

You can do it. See help -byable-. 

It's not on my agenda, even though it is  
a minor change. As Michael Blasnik has 
pointed out previously, -nearest- is not nearly 
so fast as a program he wrote himself. 
Therefore, it's that program which should 
be improved (if it doesn't support this 
already).  

Meanwhile, as Scott indicated, -foreach- 
with -levels- is one way to -by:-it-yourself. 

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