Bookmark and Share

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]

Re: st: SPHDIST, creating pairs


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: SPHDIST, creating pairs
Date   Thu, 25 Feb 2010 17:07:57 -0500

This was sent in plain text but seems in the archive to have gotten
cut off after 3 lines, for some reason.

On Thu, Feb 25, 2010 at 4:39 PM, Austin Nichols <[email protected]> wrote:
> Tomeka Davis <[email protected]> :
> This works fine for me:
> ssc inst vincenty
>
> From what Statalist post do you infer problems?
>
> Do you actually want to match all those pairs, or do you want to
> compute some statistic based on the distances?  The latter does not
> require making a crossed file; see e.g.
> http://www.stata.com/statalist/archive/2009-09/msg00493.html
>
> On Thu, Feb 25, 2010 at 4:26 PM, Tomeka Davis <[email protected]> wrote:
>> 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.
>>
>>
>

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index