Thanks, that's a very convenient command!!
I just haven't been able to figure out how to restrict it to search
for the each member of group 0 (1) not the closest one of all but the
closest one only from the respective other group, since -nearest-
doesn't seem to allow if conditions.
I tried to always keep just one member of group 0 ("number" <1000)
with all of group 1 ("number" > 1000) before executing -nearest-, as
in the below, but that would seem rather inelegant to say the least...
forvalues number = 1/246 {
preserve
keep if number2==number | number2>1000
drop partner dist
nearest zkx zky, id(partner) dist(dist)
replace distance = dist
save distance, replace
restore
drop _merge
merge id using distance, sort
}
PS: Sorry for forgetting, when sending my earlier email, about the
norm of not adding attachments to Statalist emails...
2009/11/27 Roy Wada <[email protected]>:
>> distance to each village in region 0 (1), as
>> d=sqrt[ (y_1-y_0)^2 + (x_1-x_0)^2 ],
>
> If you are going to use Euclidean distance take a look at -nearest- from ssc.
>
> Roy
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/