Date: Thu, 31 Oct 2002 10:54:06 -0500 SAlbert@AOL.COM "SAS(r) Discussion" Steve Albert Re: Figuring nearness between points on an ongoing basis text/plain; charset=iso-8859-1

Peter,

Sarah Leonard provided the code to calculate distances, and Charles Patridge gave a reference that will probably also be helpful.

I had a similar problem years ago (working in SPSS and Fortran) -- finding the distance to the nearest retail outlet of a chain, to see how it affected mail order sales.

Since there are only 48 cities, I'd suggest you create a dataset with these columns: city; coordinates (lat and long); coordinates of each of the 48 cities (lat1-48 and long1-48). Then create a series of distance variables (dist1-48), giving distance from CITY to each of the 48 (which will be 0 for itself, giving you a zero diagonal).

Now that you have the distances, create an indicator dataset for presence of exchange center for each city, coded 0/1; index by time period as needed. Merge on the distances; create a new set of variables (NOW1-48) giving distance to each city with a center at the time (and missing otherwise and for itself). The min function will let you find the closest other center, and some similar manipulation will let you count centers within 100 miles or any other arbitrary distance.

A few other thoughts:

1. If you're looking at exchange behavior, 100 miles may be too far to consider. If you're looking at political effects, then maybe not -- though it might be interesting to know whether they're in the same state. 2. Consider possible lags in effects. 3. Do any of the cities have multiple centers? Does this matter for your purpose? 4. What about cities within 100 miles without a center; do they have an effect also? Perhaps something like "percent of large cities within 100 miles with a center" might be intersting, as well as a count of cities with a center. 5. Is geographic distance the only relevant distance metric for political effects? I already mentioned same/different state, but there might be others. (Massachusetts and New Hampshire are close geographically but I think not politically, and I'm sure there are lots of other examples.)

Steve Albert Director of Biostatistics Spectrum Pharmaceutical Research Corp. San Antonio, TX SAlbert at SpectrumCRO dot com

Back to: Top of message | Previous page | Main SAS-L page