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

st: RE: Re: by & nearest

From   "Nick Cox" <>
To   <>
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 

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


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index