<?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 Calculating All GEODIST Combos in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255163#M13460</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to come up with a way to calculate all distances between particular locations and run a tally of other locations that fall within particular ranges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, take this data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEMP;
INPUT STORE LATITUDE LONGITUDE;
DATALINES;
147 40.00376 -105.27621
193 40.58591 -105.00766
211 39.63461 -104.80849
245 40.39708 -104.69702
365 39.74437 -104.98742
384 40.55901 -105.09548
422 39.74773 -104.84025
449 39.58765 -104.86672
578 39.55761 -104.88142
584 40.57984 -105.05559
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have ten separate stores and their locations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to do is tally all the stores within three- and five-mile radiuses of each store.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DISTANCE=GEODIST(40.00376,-105.27621,40.58591,-105.00766, 'M');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This value would give the distance, in miles, between stores 147 and 193. I want to repeat this process for stores 147 vs 211, 147 vs 245, etc. If this distance were less than or equal to 3 miles, I'd like to code a variable, &lt;STRONG&gt;MILE_3&lt;/STRONG&gt;, as 1, otherwise zero. If this distance were less than or equal to 5 miles, I'd like to code a variable, &lt;STRONG&gt;MILE_5&lt;/STRONG&gt;, as 1, otherwise 0. Then, I'd like a final tally record that resembled something like the following (where TOT_3 and TOT_5 are made up values for the number of stores in the data set within 3 and 5 miles of store 147).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STORE LATITUDE LONGITUDE TOT_3 TOT_5&lt;/P&gt;
&lt;P&gt;---------- ------------- ----------------- --------- ---------&lt;/P&gt;
&lt;P&gt;147 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40.00376 &amp;nbsp;-105.27621 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;193 ... etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible, once store 147 is finished, I'd like store 193 to begin at the top and compare itself with store 147 so that its TOT_3 and TOT_5 values are accurate for itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm just trying to find some way to do this, so if anyone far more clever than I has any suggestions, I'd &amp;nbsp;love to try them. So far, the similar GEODIST topics haven't provided me the results I was after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2016 04:36:19 GMT</pubDate>
    <dc:creator>KyleM_Corrie</dc:creator>
    <dc:date>2016-03-08T04:36:19Z</dc:date>
    <item>
      <title>Calculating All GEODIST Combos</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255163#M13460</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to come up with a way to calculate all distances between particular locations and run a tally of other locations that fall within particular ranges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, take this data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEMP;
INPUT STORE LATITUDE LONGITUDE;
DATALINES;
147 40.00376 -105.27621
193 40.58591 -105.00766
211 39.63461 -104.80849
245 40.39708 -104.69702
365 39.74437 -104.98742
384 40.55901 -105.09548
422 39.74773 -104.84025
449 39.58765 -104.86672
578 39.55761 -104.88142
584 40.57984 -105.05559
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have ten separate stores and their locations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to do is tally all the stores within three- and five-mile radiuses of each store.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DISTANCE=GEODIST(40.00376,-105.27621,40.58591,-105.00766, 'M');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This value would give the distance, in miles, between stores 147 and 193. I want to repeat this process for stores 147 vs 211, 147 vs 245, etc. If this distance were less than or equal to 3 miles, I'd like to code a variable, &lt;STRONG&gt;MILE_3&lt;/STRONG&gt;, as 1, otherwise zero. If this distance were less than or equal to 5 miles, I'd like to code a variable, &lt;STRONG&gt;MILE_5&lt;/STRONG&gt;, as 1, otherwise 0. Then, I'd like a final tally record that resembled something like the following (where TOT_3 and TOT_5 are made up values for the number of stores in the data set within 3 and 5 miles of store 147).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STORE LATITUDE LONGITUDE TOT_3 TOT_5&lt;/P&gt;
&lt;P&gt;---------- ------------- ----------------- --------- ---------&lt;/P&gt;
&lt;P&gt;147 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40.00376 &amp;nbsp;-105.27621 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;193 ... etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible, once store 147 is finished, I'd like store 193 to begin at the top and compare itself with store 147 so that its TOT_3 and TOT_5 values are accurate for itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm just trying to find some way to do this, so if anyone far more clever than I has any suggestions, I'd &amp;nbsp;love to try them. So far, the similar GEODIST topics haven't provided me the results I was after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 04:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255163#M13460</guid>
      <dc:creator>KyleM_Corrie</dc:creator>
      <dc:date>2016-03-08T04:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating All GEODIST Combos</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255169#M13461</link>
      <description>&lt;P&gt;Do you just need counts or a list of the actual stores.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's inefficient but a starting point is a cross join in SQL.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 06:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255169#M13461</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-08T06:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating All GEODIST Combos</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255170#M13462</link>
      <description>&lt;P&gt;Hi, Reeza.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Efficiency isn't a primary concern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a count is what I'm after, but a list of stores would be cool as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now I'm messing with a DO loop idea. I've created a separate data set with just the latitude and longitude values, and I'm trying to do it that way. Just trying to come up with something. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 06:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255170#M13462</guid>
      <dc:creator>KyleM_Corrie</dc:creator>
      <dc:date>2016-03-08T06:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating All GEODIST Combos</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255265#M13463</link>
      <description>&lt;P&gt;Here's the calculate all portion. You should be able to get the other metrics from this data set relatively easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mixed as
select a.*,b.store as store2, geodist(a.latitude,  a.longitude, b.latitude, b.longitude, 'M') as dist 
from TEMP as a
cross join TEMP as b
and a.store  ne b.store
order by a.store;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Mar 2016 15:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-All-GEODIST-Combos/m-p/255265#M13463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-08T15:28:52Z</dc:date>
    </item>
  </channel>
</rss>

