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

st: Distance matrix


From   Daniel Egan <degan.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Distance matrix
Date   Mon, 13 Jun 2005 14:03:03 -0400

hello all, 

I am attempting to create a dataset consisting of the distance between
two points.. Currently, the dataset is in a wide format consisting of
latitude and longitude in the form xx.xxxxxxxxxx

id     x     y
a     2     5
b     4     9
c     9     4
.........



I would like to end up with a dataset consisting of the Euclid distance. 

pair     dist
a-b     4.5...
a-c     7.01...

I believe the formula is:
distance=arcos( (cos(rlat1)*cos(rlat2)*cos(rlon1-rlon2)) +(sin(rlat1)*sin
(rlat2)) )*3963

I have tried 
mds latitude longitude, id(pid)
 and returned "too many macros". I do have aroun 43k observations. 

Any guidance or assistance would be greatly appreciated. 


Cheers ,
Dan Egan

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