Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re:


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   st: Re:
Date   Wed, 3 Jan 2007 21:35:07 -0500

Kelly--
This comes up just often enough to warrant an FAQ, but I don't know if
there is one.  There is a program that _almost_ does what you want
called -nearest- written by Nick Cox on 10 January 2003 and available
by typing -ssc install nearest- but it does not calculate distance on
a spherical or ellipsoidal model of the Earth.  I assume when you say
x,y you mean you have signed decimal degrees lat and lon.  In that
case, you can calculate distance using the -vincenty- program
vincenty lat1 lon1 lat2 lon2, g(d1) h(d2)
to generate distance variables.

Don't have the -vincenty- program?  Here it is:
net from http://www-personal.umich.edu/~nicholsa/stata
net install vincenty

If you want to calculate distance to each hospital (or each VA and
non-VA hosp), you can merge the hospital data onto the patient data,
and do the calculations inside a loop that executes once for each
patient.  If you're more specific about the structure of your data,
you will likely get more specific advice...


On 1/3/07, Richardson, Kelly K. <[email protected]> wrote:
Dear Statalisters,
I would like to calculate the distance between a patient's home and the
nearest hospital to their home. I have the x,y coordinates for the
patient's home and the x,y coordinates for every hospital in the
country. How do I get the distance to the nearest hospital? I looked at
the globdist command but I can't see how to enter coordinate variables
for both locations. For example, say I have 1000 patients across the
country and 5000 hospitals. How do I get one distance for each patient
that represents the distance to the nearest hospital? I'm not clear on
how my data should be constructed or which command to use. Right now the
data are in separate files, one for patients (n=1000) and one for
hospitals (n=5000). Each file has an x-coordinate and a y-coordinate
identifying the location of either the patient's home or the hospital
address. There is no unique identifier linking the patients to any of
the hospitals. In fact, I have no way of knowing where any patient
actually went. I just need to know where the closest hospital is to
where they live. I am also interested in identifying the nearest VA
Hospital versus the nearest Non-VA hospital. I have an indicator in the
hospital data file (1=VA 0=non-VA). In the end I hope to have 2 distance
measures for each individual. I'm not sure Stata is appropriate for this
task. Any suggestions would be greatly appreciated.
Thank you,
Kelly

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