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

From |
Graeme Inglis <Graeme.Inglis@cancervic.org.au> |

To |
"Stata List (E-mail)" <statalist@hsphsun2.harvard.edu> |

Subject |
st: Calculating distance |

Date |
Wed, 16 Apr 2003 09:04:38 +1000 |

Hi I would like some help from the StataList with a problem calculating the distance between a patients residential post code and the postcode of the nearest treatment centre. I have assembled a two data files. The first file contains the patients postcodes and the X & Y (px, py) coordinates of these post codes. The second file has the radiotherapy centres with their post codes and the X & Y (rdx, rdy) coordinates of their post codes. By subtracting the X's and the Y's and applying pythagoras's theorem the distance in km can be calculated, but the difficulty is to select the shortest distance and write the location and shortest distance into a new variable for each patient. Now I envisage the shortest distance would be determined by taking the first patient and calculating the distance to each treatment centre (13 centres in this case), then selecting the shortest distance among the centres then writing this distance and the centres post code into two new variables 'pradpc' and 'praddist' for that patient in the patient dataset. So that the patient data set would progressively have values written into the post code 'pradpc' of the nearest centre and the distance 'praddist' to this centre. I can calculate the distance OK but I can't get an iterative process working that calculates then writes the values for 'pradpc' and 'praddist'. I have attached two sample files for the patient data and the treatment centre data to assist. <<stata_qp_140403.dta>> <<stata_qrad_140403.dta>> Now the process may be simplified by considering those patients who live in the same post code as a treatment centre in which case pradpc=patpc and the distance would be zero. In addition if the patient file is sorted by post code duplicate values of the same post code would have the same pradpc and distance. I will be very grateful for help in this problem. I'm still using Stata 7. Thankyou in anticipation Cheers Graeme Inglis. Research Officer. Cancer Control Research Institute. Centre for Behavioural Research in Cancer. The Cancer Council of Victoria. Telephone: 61(0)3 9635 5203. Graeme Inglis. Research Officer. Cancer Control Research Institute. Centre for Behavioural Research in Cancer. The Cancer Council of Victoria. Telephone: 61(0)3 9635 5203.

**Attachment:
stata_qp_140403.dta**

**Attachment:
stata_qrad_140403.dta**

**Follow-Ups**:**st: Re: Calculating distance***From:*"Michael Blasnik" <michael.blasnik@verizon.net>

- Prev by Date:
**st: Re: menu changes** - Next by Date:
**Re: st: estimates commands in Stata 8** - Previous by thread:
**st: estimates command** - Next by thread:
**st: Re: Calculating distance** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |