Date: Wed, 6 Nov 2002 11:54:17 -0700
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: More problems with distances between cities
Content-Type: text/plain; charset=US-ASCII
It would be useful to have a Haversine distance function built into the
base SAS product. If that's something you want, send a note to
email@example.com. I've suggested it, but didn't get the impression
that SAS Institute thinks anyone but me wants it.
Manager, Technical Development
METRICS Department, First Health
West Sacramento, California USA
>>> "Peter Flom" <flom@NDRI.ORG> 11/06/2002 10:27 AM >>>
Regarding distances, a purely Euclidean approach isn't exactly right,
because the Earth is round. It doesn't make much difference since the
continental US is not a large part of the Earth, but since the person
am working with is a geographer, it should be right, for form's sake.
This can be corrected using the Haversine formula, but that's not too
problematic, I just need to write the code (it's a messy formula, with
lots of versions, but do-able).
Regarding the matrix of all distances......no doubt a macro is
possible, but my skills aren't up to it.....I think the approach I am
using will work, but am not sure of the modification that is needed.
>>> Frank Lui <firstname.lastname@example.org> 11/06/02 12:45PM >>>
Just wondering (I did not follow your earlier question and answers). I
not read your codes but just some ideas.
If you have x and y coord, why can't you calculate distance between
points directly? I was thinking of:
The Distance = Squareroot((square(x2-x1)+square(y2-y1)).
Correct me if I made mistakes.
As for the calculation of all distances cross all cities, you may need
write a macro. In each macro step, you can build a new data set by
one city from your data base, renaming x, y coord as different
names and merging back with your original. Then you can calculate the
distances between this city to all cities (will be zero when it comes
itself). Rename (or automatically) the distance to distance_city_one
other you'd like). For the second city, merge it with data with
calculated for the first city. Continue this pattern for the third
so on. You would build a matrix of distance.