Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: SPHDIST, creating pairs


From   TA Stat <tastat@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: SPHDIST, creating pairs
Date   Fri, 26 Feb 2010 17:15:28 +0700

starting from 2 separate files, public and private schools.  sort by
District ID, then using joinby command and using unmatched and merge
option. it will run all pairwise combinations from master file
(publicschool) with using file (privateschool) and keep all those
variables from both files.

use "C:\publicschool.dta", clear
joinby DistrictID using "C:\privateschool.dta", unmatched(both) _merge(merge)

then  you can use replace command to replace those missing data.

hope this help

tastat

On Fri, Feb 26, 2010 at 4:26 AM, Tomeka Davis <soctmd@langate.gsu.edu> 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.
>
>
> 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/
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index