<?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 Distance Calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445467#M111626</link>
    <description>&lt;P&gt;&lt;BR /&gt;SAS_M&amp;nbsp; SAS_F&lt;BR /&gt;myzip&amp;nbsp; facility_zip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;22180&amp;nbsp; 33180&lt;BR /&gt;22181&amp;nbsp; 33181&lt;BR /&gt;22182&amp;nbsp; 33182&lt;BR /&gt;22183&amp;nbsp; 33183&lt;BR /&gt;22184&amp;nbsp; .....&lt;BR /&gt;22185&amp;nbsp; numobs=270 zip codes&lt;BR /&gt;22186&lt;BR /&gt;22187&lt;BR /&gt;22188&lt;BR /&gt;22189&lt;BR /&gt;22190&lt;BR /&gt;.....&lt;BR /&gt;.....&lt;BR /&gt;.....&lt;BR /&gt;numobs=3000 zip codes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS_M and SAS_F are two SAS datasets each containing only a column of zip. SAS_M has 3000 rows and SAS_F has 270 rows.&lt;BR /&gt;ZIPCITYDISTANCE function works fine for a pair of zips. I need some sort of looping that can do the followings,&lt;/P&gt;&lt;P&gt;ZIPCITYDISTANCE(22180,33180) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33181) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33182) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33183) then&lt;BR /&gt;ZIPCITYDISTANCE(22181,33180) then&lt;BR /&gt;ZIPCITYDISTANCE(22181,33181) and soforth.&lt;BR /&gt;............................&lt;/P&gt;&lt;P&gt;As said the ZIPCITYDISTANCE function works fine when you only have a pair of zips. In my case I need the distance between&lt;BR /&gt;first zip from SAS_M to every row of zip in the SAS_F dataset and then the second zip from the SAS_M to every zip rows of&lt;BR /&gt;SAS_F dataset and soforth.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;BR /&gt;* ZIPCITYDISTANCE function;&lt;BR /&gt;&amp;nbsp;d1 = zipcitydistance(12203,27513);&lt;/P&gt;</description>
    <pubDate>Wed, 14 Mar 2018 13:09:51 GMT</pubDate>
    <dc:creator>mauri0623</dc:creator>
    <dc:date>2018-03-14T13:09:51Z</dc:date>
    <item>
      <title>Distance Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445467#M111626</link>
      <description>&lt;P&gt;&lt;BR /&gt;SAS_M&amp;nbsp; SAS_F&lt;BR /&gt;myzip&amp;nbsp; facility_zip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;22180&amp;nbsp; 33180&lt;BR /&gt;22181&amp;nbsp; 33181&lt;BR /&gt;22182&amp;nbsp; 33182&lt;BR /&gt;22183&amp;nbsp; 33183&lt;BR /&gt;22184&amp;nbsp; .....&lt;BR /&gt;22185&amp;nbsp; numobs=270 zip codes&lt;BR /&gt;22186&lt;BR /&gt;22187&lt;BR /&gt;22188&lt;BR /&gt;22189&lt;BR /&gt;22190&lt;BR /&gt;.....&lt;BR /&gt;.....&lt;BR /&gt;.....&lt;BR /&gt;numobs=3000 zip codes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS_M and SAS_F are two SAS datasets each containing only a column of zip. SAS_M has 3000 rows and SAS_F has 270 rows.&lt;BR /&gt;ZIPCITYDISTANCE function works fine for a pair of zips. I need some sort of looping that can do the followings,&lt;/P&gt;&lt;P&gt;ZIPCITYDISTANCE(22180,33180) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33181) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33182) then&lt;BR /&gt;ZIPCITYDISTANCE(22180,33183) then&lt;BR /&gt;ZIPCITYDISTANCE(22181,33180) then&lt;BR /&gt;ZIPCITYDISTANCE(22181,33181) and soforth.&lt;BR /&gt;............................&lt;/P&gt;&lt;P&gt;As said the ZIPCITYDISTANCE function works fine when you only have a pair of zips. In my case I need the distance between&lt;BR /&gt;first zip from SAS_M to every row of zip in the SAS_F dataset and then the second zip from the SAS_M to every zip rows of&lt;BR /&gt;SAS_F dataset and soforth.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;BR /&gt;* ZIPCITYDISTANCE function;&lt;BR /&gt;&amp;nbsp;d1 = zipcitydistance(12203,27513);&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445467#M111626</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2018-03-14T13:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445472#M111628</link>
      <description>&lt;P&gt;SQL should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  a.myzip,
  b.facility_zip,
  zipcitydistance(a.myzip,b.facility_zip) as distance
from sas_m a, sas_f b;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as it automatically creates a cartesian join.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445472#M111628</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-14T13:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445473#M111629</link>
      <description>&lt;P&gt;If you need all rows of the second calculated against the rows from the first, them merge 1 to many:&lt;/P&gt;
&lt;PRE&gt;data want;
  merge myzip (in=a) facility_zip (in=b;
  if a;
  diff=zipdistance(myzip,facility_zip);
run;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Note, not tested, post test data in the form of a datastep, and show required output.&amp;nbsp; We are not here to type this in for you!&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445473#M111629</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-14T13:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445481#M111631</link>
      <description>&lt;P&gt;Thank you. I will try.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-Calculation/m-p/445481#M111631</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2018-03-14T13:49:42Z</dc:date>
    </item>
  </channel>
</rss>

