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

st: Re: by & nearest


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: by & nearest
Date   Fri, 22 Aug 2003 21:35:44 -0500

----- Original Message ----- 
From: "Benoit Dulong" <[email protected]>
To: "statalist" <[email protected]>
Sent: Friday, August 22, 2003 10:54 AM
Subject: st: by & nearest


> Is it possible (change the program) to get nearest to work with by ?
>
> I can not find the answer in my NC151 notes.
>
> Thank you
>
> Benoit Dulong.
>

Beniot,

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')
      }


Scott


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