hi ... some other ideas ... #1 this also uses the ZIPCITYDISTANCE function ... basically Robert's ideas in one use of PROC SQL, though I took out the condition where usa1.zip^=metro_rank.metro_zip; since I think it'd be OK if the closest USA zip to a METRO zip was the same zip, yes/no? the first part cleans up USA1 it replaces spaces in ADDZIP with asterisks then creates a numeric variable UZIP using the 1st five characters of ADDZIP (you get some LOG messages about INVALID strings) it also checks to see if UZIP is in SASHELP.ZIPCODE since ZIPCITYDISTANCE uses that data set the second part grabs the top 50 observations in METRO_RANK the third part computes the distance and grabs the minimum distance between a TIC and a top 50 CITY you get some LOG messages about INVALID strings proc sql; create view usa as select unique tic, input(translate(addzip,'*',' '), 5.) as uzip format=z5. from z.usa1, sashelp.zipcode (keep=zip) as zc having uzip eq zc.zip; create view metro as select city, sum_rank, input(zipcode, 5.) as mzip format=z5. from z.metro_rank (where=(sum_rank between 1 and 50)); create table pairs as select *, zipcitydistance(uzip, mzip) as dist from usa, metro group tic having dist eq min(dist); quit; #2 this would be too big a problem to for the SAS and Google Maps drive distance/time (not really intended for 500K+ calls to Google Maps) #3 the code in the original SGF paper no longer works ... a link to the most recent code canbe found at ... http://www.sascommunity.org/wiki/User:Msz03 (but remember, your problem is TOO BIG) #4 Darrell's comment of "... Google Maps terms of use ..." ... I looked (again) at ... http://www.google.com/help/terms_maps.html and see the two possible sticking points as how one would interpret ... (a) access or use the Products or any Content through any technology or means other than those provided in the Products, or through other explicitly authorized means Google may designate (such as through the Google Maps/Google Earth APIs); and (e) use the Products in a manner that gives you or any other person access to mass downloads or bulk feeds of any Content, including but not limited to numerical latitude or longitude coordinates, imagery, and visible map data; I see at ... http://blog.programmableweb.com/2011/10/27/google-maps-usage-fees-how-many-developers-will-have-to-pay/http://code.google.com/apis/maps/faq.html#usagelimits that folks using Google APIs for map access have a 25,000 free maps/day, after that there's a charge #5 take a look at ... http://www.tandfonline.com/doi/abs/10.1080/00330124.2011.583586#preview Boscoe FP, Henry KA, Zdeb MS. A Nationwide Comparison of Driving Distance Versus Straight Line Distance to Hospitals. Professional Geographer 2012 the conclusion in that paper is that in most instances, the added precision of driving distance over straight line distance isn't worth the effort
... View more