Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: SPHDIST, creating pairs
From
"Tomeka Davis" <[email protected]>
To
<[email protected]>
Subject
st: SPHDIST, creating pairs
Date
Thu, 25 Feb 2010 16:26:54 -0500
Hello -
I am trying to calculate distance between two points using longitude and latitude data. I have come across 2 different Stata commands to do this - SPHDIST and VICENTY. I have not been able to install the VICENTY command. It appears from previous StataList posts that there might be problems associated with it and therefore it is temporarily unavailable (right?).
Although I have longitude and latitude data, I am not sure how to create the pairs necessary to calculate distance with SPHDIST. I would like to calculate distance from a each public school in a district to all the other private schools in the same district. My data SHOULD look like this:
District ID Public School ID Private School ID Public Longitude Public Latitude Private Latitude Private Longitude
1 A 1
1 A 2
1 B 1
1 B 2
1 B 3
1 B 4
2 C 1
2 C 2
2 C 3
2 D 1
2 D 2
I initially had two separate files; one with public school data and one with private school data. I appended the public school file and tacked on the private school data.
NOW the data looks something like this
Distric ID School ID Public School Private School Latitude Longitude
1 A Y N
1 A Y N
1 B Y N
1 B Y N
1 B Y N
1 B Y N
2 C N Y
2 C N Y
2 C N Y
2 D N Y
2 D N Y
But I want to pair each public school with each private school.
So far, I have figured out how to produce a data set pairing ALL schools within each district; this would pair public schools within a district with other public schools in the same district (using a an FAQ page from 2005 written by Nick Cox titled "Expanding datasets to all possible pairs"). However, I don't want this. I only want to pair each public school with each private school in the same district.
How do I accomplish this?
I would appreciate any help anyone could offer. Also, any suggestions about the best distance command would be appreciated.
Thank you.
*
* 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/