<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Closest distance to top 50 cities in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43126#M1386</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all useful suggestions,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Based on the article entitled "Driving distance and Time using SAS and Google Maps" (refer:&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/resources/papers/proceedings10/050-2010.pdf"&gt;http://support.sas.com/resources/papers/proceedings10/050-2010.pdf&lt;/A&gt;&lt;SPAN&gt;), I find that I can calculate the driving distance between 2 points. However, the examples provided in the article is a small sample, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I would like to calculate the DRIVE TIME between the firm (identified by tic) and the closest top 50 cities. Note: Using the SAS data files I uploaded.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would be the solution? Is it possible to handle this task efficiently? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MEI SEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Feb 2012 03:24:58 GMT</pubDate>
    <dc:creator>mspak</dc:creator>
    <dc:date>2012-02-03T03:24:58Z</dc:date>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43112#M1372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am searching for the most efficient way to calculate the closest distance to top 50 cities in US. I have all the zipcodes for all the firms (I refer this as x) and top cities (referred as y). If I were to arrange all the y in columes (which requires 50 columes), it will take a long time to compute the results. Then, I will have to get the lowest values among all the distances. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any BETTER way to compute the closest distance between the firm and their respective closest city (among top 50 cities)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sandy &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 05:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43112#M1372</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-01T05:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43113#M1373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope you have SAS 9.2 or better.&lt;/P&gt;&lt;P&gt;You can use the ZIPCITYDISTANCE function to compute the distances: &lt;A href="http://support.sas.com/kb/36/091.html"&gt;http://support.sas.com/kb/36/091.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It shouldn't take too long: for each firm, find the minimum of the distances to the 50 citites. You can do this in a DATA step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 11:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43113#M1373</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-02-01T11:26:28Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43114#M1374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick Wicklin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a user of SAS9.3. I found ways to calculate the distance between only TWO locations. I have a database for the geographic coordinates for all the zipcodes. I have to calculate the distances between the firms with all the top 50 cities, and then identify the closest top city (with distance) of the particular firms. I understand that there is a data step to select the lowest value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does mean that I have to present my longitudes and latitides in 102 columns [(50 cities + the firm) x 2]. Note: Each coordinates to be presented in latitude and longitude in pairs.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there anyway to calculate distance between the firm with all the cities by merely creating one formula, instead of repeating the process for 50 times for each firm, preferably with an option to select the lowest value (shortest distance) among distances between all the 50 cities and the firm. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sandy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 12:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43114#M1374</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-01T12:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43115#M1375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wouldn't want to have 50 separate variables for the 50 cities, but rather make the cities 'values' of the variables. Here's a small sample that demonstrates basically what you want to do (since I don't have your cities list, I'm just grabbing some zipcodes out of the sashelp.zipcode file)...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let myzip=27513;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cities (keep=statecode city zip);&lt;BR /&gt;set sashelp.zipcode (where=(statecode='NC'));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cities; set cities;&lt;BR /&gt;distance=zipcitydistance(&amp;amp;myzip,zip);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=cities out=cities;&lt;BR /&gt;by distance;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cities; set cities (obs=50);&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 13:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43115#M1375</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2012-02-01T13:15:26Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43116#M1376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Use this example that I created:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; Targets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; Target @@; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 14pt;"&gt;/* NYC CHICAGO DALLAS */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;10027 60601 75211&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; Cities;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; City @@; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;96106 49039 01341 13464 40206&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;15281 31515 67859 64465 80234&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;25672 45340 26266 77641 97306&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;92885 57580 36312 95070 29940&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffc0; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;25165 16424 39423 76528 06611&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 14pt;"&gt;/* combine the two tables */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; All &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; Targets, Cities;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; dist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 14pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt; All;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 14pt;"&gt;dist = zipcitydistance(Target, City);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 14pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 13:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43116#M1376</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-02-01T13:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43117#M1377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My suggestion is similar to Robert's but, if you need to calculate the proximities between all of the cities, I would use proc sql.&amp;nbsp; E.g., the following (I only used a 5 city database, but it could just as well as contained 50 or more) does all of the calculations in one simple step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat city $25.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input city &amp;amp; zip;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;Chicago&amp;nbsp; 60626&lt;/P&gt;&lt;P&gt;Albany&amp;nbsp; 12209&lt;/P&gt;&lt;P&gt;Los Angeles&amp;nbsp; 90002&lt;/P&gt;&lt;P&gt;New York&amp;nbsp; 10278&lt;/P&gt;&lt;P&gt;Detroit&amp;nbsp; 48243&lt;/P&gt;&lt;P&gt;San Francisco&amp;nbsp; 94104&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zipcitydistance(zip,zip2) as distance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have,have (rename=(city=city2 zip=zip2))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where city ne city2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by city, distance&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 13:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43117#M1377</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-01T13:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43118#M1378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These seem like reasonable suggestions.&amp;nbsp;&amp;nbsp; The only other suggestion I have is that you could attempt to subset your comparisons by making intelligent choices of cities to compare against.&amp;nbsp; You have the ZIP Codes and the numbers do have meaning.&amp;nbsp; The first digit indicates the region of the country.&amp;nbsp; 2, for example, is DC, Maryland, Virginia, West Virginia, NC, and SC.&amp;nbsp; You might compare zipcodes starting with '2' to the cities in this region and perhaps the next region or so.&amp;nbsp; But skip the regions that are all the way on the west coast.&amp;nbsp; However, I'd probably only do this if you have a very large number of firms/ZIP Codes to compare, are having performance issues and want to try additional tweaks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This link gives some information on the ZIP Code regions:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.zippostalcodes.com/postcodes/us/us-zip-codes-format/"&gt;http://www.zippostalcodes.com/postcodes/us/us-zip-codes-format/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 13:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43118#M1378</guid>
      <dc:creator>Darrell_sas</dc:creator>
      <dc:date>2012-02-01T13:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43119#M1379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I think at this point that MSPAK needs to provide an example of 4 or 5 cities, firms and what the output should look like and definition of "top city".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 22:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43119#M1379</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-02-01T22:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43120#M1380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the helps!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I herewith attached the data as example. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following SAS files attached:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;File 1: usa1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This file contains the company ticker no. (tic), financial year (fyear), address zipcodes (ADDZIP) and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;File2: metro_rank&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This file contains zipcodes with their latitudes, longitudes and the last column is the ranking for the metropolitans. I used this rank for the top cities. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My main task:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have to calculate the distance between the firms (in file 1) with the closest top 50 cities (in file 2). At this point, I still do not have any idea which city is the closest to the firm. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My expected output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I wish to have an additional variable (Column) which included in File 1, namely, the distance (in miles) to the closest city for each firm (which identified by tic). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I have to make my point clearer at this point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again, thank you very much for helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MSPAK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 04:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43120#M1380</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-02T04:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43121#M1381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can only help you through part of your problem.&amp;nbsp; Your USA1 file contains a mixture of zipcodes and postal codes from both Canada and Europe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following will work to solve your problem for just the records that have US zipcodes.&amp;nbsp; However, if you need the match the Canadian and European cities with US cities, you'll have to obtain the grid coordinates for all of the cities and do some modifications to the code.&amp;nbsp; However, the approach should still work, and it only took about 2 minutes to accomplish on a fairly old Windows machine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname thedata "c:\";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data part_usa1 (keep=tic partzip city);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length partzip $5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set thedata.usa1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; partzip=strip(substr(addzip,1,5));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if length(partzip) eq 5 and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; notdigit(partzip) eq 0;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=part_usa1 nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by partzip;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table temp (keep=tic bcity distance sum_rank) as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zipcitydistance(a.partzip,b.zipcode) as distance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from part_usa1 as a,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thedata.Metro_rank (keep=ZipCode City sum_rank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename=(City=bCity)) as b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where city ne bCity and not missing(calculated distance)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by tic, distance&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data need (drop=bCity sum_rank distance);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array cities(50) $35.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array ranks(50);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array distances(50);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain cities: ranks: distances:;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by tic;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.tic then n=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else n+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if n le 50 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cities(n)=bCity;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ranks(n)=sum_rank;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; distances(n)=distance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if n eq 50 then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=thedata.usa1 out=usa1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by tic;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge need usa1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by tic;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 06:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43121#M1381</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-02T06:16:17Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43122#M1382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for suggestions,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will eventually delete all those firms are not in US as my research sample should only include US firms. My another question is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I convert all the longitude and latitude (which are currently in decimals) into radians before your program suggested? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 06:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43122#M1382</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-02T06:29:33Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43123#M1383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code I suggested didn't use the grid coordinates at all but, rather, only used the zip codes to determine distance.&amp;nbsp; That is why it had to omit the non-US entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 13:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43123#M1383</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-02T13:29:41Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43124#M1384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you've got a bit of data-cleaning to do, but ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the data you provided, and assuming that this is the problem statement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each company (designated by a tic), find the closest city which is in the "top 50" cities.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is some code.&amp;nbsp; I've added some comments to let you know what's going on at each step along the way, and of course each step could be done in several different ways (depending on personal preference, the need for efficiency-vs-ease, etc):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname mydata 'somewhere';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* only keep 1 obsn per tic (don't need all the fiscal years */&lt;BR /&gt;/* 12,913 obsns */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table usa1 as&lt;BR /&gt;select unique tic, addzip&lt;BR /&gt;from mydata.usa1;&lt;BR /&gt;quit; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create 'zip' variable with 5-digit numeric zip code */&lt;BR /&gt;/* also do something to also limit these to US-only */&lt;BR /&gt;data usa1; set usa1;&lt;BR /&gt;format zip z5.;&lt;BR /&gt;zip=.; zip=substr(addzip,1,5);&lt;BR /&gt;if zip^=. then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* only keep cities in the "top 50" */&lt;BR /&gt;data metro_rank; set mydata.metro_rank;&lt;BR /&gt;metro_zip=.; metro_zip=substr(zipcode,1,5);&lt;BR /&gt;if sum_rank^=. and sum_rank&amp;lt;=50 and metro_zip^=. then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* get every possible pair of company-to-city */&lt;BR /&gt;/* this produces about 607,215 obsns */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table pairs as&lt;BR /&gt;select&lt;BR /&gt;usa1.tic, usa1.zip,&lt;BR /&gt;metro_rank.metro_zip, metro_rank.city, metro_rank.sum_rank&lt;BR /&gt;from usa1, metro_rank&lt;BR /&gt;where usa1.zip^=metro_rank.metro_zip;&lt;BR /&gt;quit; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* calculate the distance between each tic's zip, and the metro_zips */&lt;BR /&gt;/* this takes about 11 seconds on my laptop */&lt;BR /&gt;data pairs; set pairs;&lt;BR /&gt;distance=zipcitydistance(zip,metro_zip);&lt;BR /&gt;if distance^=. then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* For each tic, get the obsn with the shortest distance */&lt;/P&gt;&lt;P&gt;/* produces 11,680 obsns */&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table closest as&lt;/P&gt;&lt;P&gt;select unique *&lt;/P&gt;&lt;P&gt;from pairs&lt;/P&gt;&lt;P&gt;group by tic&lt;/P&gt;&lt;P&gt;having sum_rank = min(sum_rank);&lt;/P&gt;&lt;P&gt;quit; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 14:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43124#M1384</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2012-02-02T14:27:47Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43125#M1385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Upon looking at Robert's code I realized that I didn't provide any comments or explanations regarding my own code. Hey, at 1:15am, I couldn't stay awake any longer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I proposed results in a file, called work.want, the contains all of the records from USA1, with the addition of 150 fields on each record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;cities1 is the city closest to the firm and ranks1 is its rank and distances1 shows the number of miles it is from the firm.&amp;nbsp; The second closest is cities2, etc. and the 50th closest is cities50. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 14:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43125#M1385</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-02T14:52:04Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43126#M1386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all useful suggestions,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Based on the article entitled "Driving distance and Time using SAS and Google Maps" (refer:&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/resources/papers/proceedings10/050-2010.pdf"&gt;http://support.sas.com/resources/papers/proceedings10/050-2010.pdf&lt;/A&gt;&lt;SPAN&gt;), I find that I can calculate the driving distance between 2 points. However, the examples provided in the article is a small sample, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I would like to calculate the DRIVE TIME between the firm (identified by tic) and the closest top 50 cities. Note: Using the SAS data files I uploaded.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would be the solution? Is it possible to handle this task efficiently? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MEI SEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 03:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43126#M1386</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-03T03:24:58Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43127#M1387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike already provided the code in his paper.&amp;nbsp; I would still start with proc sql to create a file with all combinations of the zip codes, then wrap Mike's code in a Macro that loops through the file you created with proc sql.&amp;nbsp; All you have to pass into the macro are the zip code pairs and run it for each pair.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would simply replace the suggested datastep that is using the SAS zip/distance function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The rest of the code, whichever method you choose, would remain the same.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 04:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43127#M1387</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-03T04:30:58Z</dc:date>
    </item>
    <item>
      <title>Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43128#M1388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should carefully read the Google Maps terms of use documents before using the drive time code to make sure it isn't in violations of their terms.&amp;nbsp; At one time, they specified that 'services' could only be used if the information was being put on a Google map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43128#M1388</guid>
      <dc:creator>Darrell_sas</dc:creator>
      <dc:date>2012-02-03T15:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43129#M1389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; &lt;/SPAN&gt;hi ... some other ideas ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#1 this also uses the ZIPCITYDISTANCE function ... basically Robert's ideas in one use of PROC SQL, though I took out the condition&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;where usa1.zip^=metro_rank.metro_zip;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;since I think it'd be OK if the closest USA zip to a METRO zip was the same zip, yes/no?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first part cleans up USA1&lt;/P&gt;&lt;P&gt;it replaces spaces in ADDZIP with asterisks then creates a numeric variable UZIP using the 1st five characters of ADDZIP&lt;/P&gt;&lt;P&gt;(you get some LOG messages about INVALID strings)&lt;/P&gt;&lt;P&gt;it also checks to see if UZIP is in SASHELP.ZIPCODE since ZIPCITYDISTANCE uses that data set &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the second part grabs the top 50 observations in METRO_RANK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the third part computes the distance and grabs the minimum distance between a TIC and a top 50 CITY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you get some LOG messages about INVALID&amp;nbsp; strings&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;create view usa as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;select unique tic, input(translate(addzip,'*',' '), 5.) as uzip format=z5.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;from z.usa1, sashelp.zipcode (keep=zip) as zc&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;having uzip eq zc.zip;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;create view metro as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;select city, sum_rank, input(zipcode, 5.) as mzip format=z5.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;from z.metro_rank (where=(sum_rank between 1 and 50));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;create table pairs as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;select *, zipcitydistance(uzip, mzip) as dist&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;from usa, metro&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;group tic&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;having dist eq min(dist);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#2&amp;nbsp; 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)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#3&amp;nbsp; the code in the original SGF paper no longer works ... a link to the most recent code canbe found at ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/User:Msz03"&gt;http://www.sascommunity.org/wiki/User:Msz03&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(but remember, your problem is TOO BIG)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#4&amp;nbsp; Darrell's comment of "... Google Maps terms of use ..." ... I looked (again) at ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.google.com/help/terms_maps.html"&gt;http://www.google.com/help/terms_maps.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and see the two possible sticking points as how one would interpret ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; text-align: -webkit-auto; background-color: #ffffff;"&gt;(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 &lt;/SPAN&gt;&lt;A href="http://code.google.com/apis/maps/terms.html" id="guue" name="guue" style="color: #7847b2; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; text-align: -webkit-auto; background-color: #ffffff;" title="Google Maps API"&gt;Google Maps/Google Earth APIs&lt;/A&gt;&lt;SPAN style="color: #444444; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; text-align: -webkit-auto; background-color: #ffffff;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 16px; text-align: -webkit-auto; color: #444444; font-size: 14px; background-color: #ffffff; font-family: arial, sans-serif;"&gt;(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;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see at ... &lt;A class="active_link" href="http://blog.programmableweb.com/2011/10/27/google-maps-usage-fees-how-many-developers-will-have-to-pay/"&gt;http://blog.programmableweb.com/2011/10/27/google-maps-usage-fees-how-many-developers-will-have-to-pay/&lt;/A&gt;&lt;A href="http://code.google.com/apis/maps/faq.html#usagelimits"&gt;http://code.google.com/apis/maps/faq.html#usagelimits&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that folks using Google APIs for map access have a 25,000 free maps/day, after that there's a charge&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#5&amp;nbsp; take a look at ... &lt;A href="http://www.tandfonline.com/doi/abs/10.1080/00330124.2011.583586#preview"&gt;http://www.tandfonline.com/doi/abs/10.1080/00330124.2011.583586#preview&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="line-height: 18px; color: #47473a; font-size: 12px; font-family: 'trebuchet ms', helvetica, sans-serif;"&gt;&lt;STRONG&gt;Boscoe FP, Henry KA, Zdeb MS.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="line-height: 18px; color: #47473a; font-size: 12px; font-family: 'trebuchet ms', helvetica, sans-serif;"&gt;&lt;STRONG&gt;A Nationwide Comparison of Driving Distance Versus Straight Line Distance to Hospitals. &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="line-height: 18px; color: #47473a; font-size: 12px; font-family: 'trebuchet ms', helvetica, sans-serif;"&gt;&lt;STRONG&gt;Professional Geographer 2012&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 19:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43129#M1389</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-02-03T19:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43130#M1390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While we all obviously have to respect terms of agreement, and I'm not familiar with what the following authors did, I just noticed an interesting paper title scheduled to be presented at this year's SGF:&lt;/P&gt;&lt;P&gt;&lt;A class="TableData" href="http://sgf2012.confnav.com/sgf2012/web/sessions/date/view.html#20111103194323199460000000"&gt;&lt;STRONG&gt;Batch Production of Driving Distances and Times Using SAS® and Web Map APIs&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, sans-serif; font-size: 12px; text-align: -webkit-auto; white-space: nowrap; background-color: #b9c1da;"&gt;Ash Roy, Canadian Institute for Health Information&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Verdana, Arial, sans-serif; font-size: 12px; text-align: -webkit-auto; white-space: nowrap; background-color: #b9c1da;"&gt;Yingbo Na, Canadian Institute for Health Information&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://sgf2012.confnav.com/sgf2012/web/sessions/date/view.html#20111103194323199460000000"&gt;http://sgf2012.confnav.com/sgf2012/web/sessions/date/view.html#20111103194323199460000000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't attend their presentation, as I'm presenting a paper at the same time that those authors are presenting, but you can probably contact them now and get some additional answers to your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you discover anything useful I, for one, would appreciate your posting a summary here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Feb 2012 17:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43130#M1390</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-04T17:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Closest distance to top 50 cities</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43131#M1391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for suggestions,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I need time to figure out the correct ways to calculate the drive time efficiently. Some locations may not be accessible by roads. This task is much more complicated as compared to merely calculating the straight line distance between locations as it involves the use of google maps and a big country - US. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There might be many different possible routes on road from one location to another. I will have to choose, the lowest&amp;nbsp; drive time among the possible routes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As requested by art297, I will share some useful tips if I found any good way to handle this complicated calculations efficiently. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Feb 2012 05:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Closest-distance-to-top-50-cities/m-p/43131#M1391</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-02-05T05:04:38Z</dc:date>
    </item>
  </channel>
</rss>

