<?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 Pairwise geodist calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pairwise-geodist-calculation/m-p/254529#M48560</link>
    <description>&lt;P&gt;I looked at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Calculating-pair-wise-distances-using-the-geodist-function/td-p/190864" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Calculating-pair-wise-distances-using-the-geodist-function/td-p/190864&lt;/A&gt; but the code isn't well documented so I am not entirely sure what is going on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with millions of lat long. Let's call it loc_dist.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data loc_dist (keep = ser_no EQP_GPS_SPEC_LAT_CORD EQP_GPS_SPEC_Long_CORD);
	set mttt.locs_machines;
	recid = _n_;
run;

data results (keep = ser_no gdist);
	set loc_dist nobs = nobs;
	if _n_ = 1 then do;
		if 0 then 
			set loc_dist(keep = EQP_GPS_SPEC_LAT_CORD EQP_GPS_SPEC_Long_CORD 
			rename = (EQP_GPS_SPEC_LAT_CORD = lat EQP_GPS_SPEC_Long_CORD = long));
			_rc = h1.definekey('recid');
			_rc = h1.definedata('lat', 'long');
			_rc = h1.definedone();
	end;
	do i = (recid + 1) to nobs;
		_rc = h1.find(key:_i);
		gdist = geodist(EQP_GPS_SPEC_LAT_CORD, EQP_GPS_SPEC_Long_CORD, lat, long);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, I get the following error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;830              _rc = h1.definekey('recid');
                       ------------
                       557
ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable h1 is not an object.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Mar 2016 16:49:41 GMT</pubDate>
    <dc:creator>dwsmith</dc:creator>
    <dc:date>2016-03-04T16:49:41Z</dc:date>
    <item>
      <title>Pairwise geodist calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pairwise-geodist-calculation/m-p/254529#M48560</link>
      <description>&lt;P&gt;I looked at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Calculating-pair-wise-distances-using-the-geodist-function/td-p/190864" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Calculating-pair-wise-distances-using-the-geodist-function/td-p/190864&lt;/A&gt; but the code isn't well documented so I am not entirely sure what is going on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with millions of lat long. Let's call it loc_dist.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data loc_dist (keep = ser_no EQP_GPS_SPEC_LAT_CORD EQP_GPS_SPEC_Long_CORD);
	set mttt.locs_machines;
	recid = _n_;
run;

data results (keep = ser_no gdist);
	set loc_dist nobs = nobs;
	if _n_ = 1 then do;
		if 0 then 
			set loc_dist(keep = EQP_GPS_SPEC_LAT_CORD EQP_GPS_SPEC_Long_CORD 
			rename = (EQP_GPS_SPEC_LAT_CORD = lat EQP_GPS_SPEC_Long_CORD = long));
			_rc = h1.definekey('recid');
			_rc = h1.definedata('lat', 'long');
			_rc = h1.definedone();
	end;
	do i = (recid + 1) to nobs;
		_rc = h1.find(key:_i);
		gdist = geodist(EQP_GPS_SPEC_LAT_CORD, EQP_GPS_SPEC_Long_CORD, lat, long);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, I get the following error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;830              _rc = h1.definekey('recid');
                       ------------
                       557
ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable h1 is not an object.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Mar 2016 16:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pairwise-geodist-calculation/m-p/254529#M48560</guid>
      <dc:creator>dwsmith</dc:creator>
      <dc:date>2016-03-04T16:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pairwise geodist calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pairwise-geodist-calculation/m-p/254545#M48564</link>
      <description>&lt;P&gt;I think, you just forgot to copy (and adapt) the declaration of the hash object you want to use. So, please insert the following statement before the line which contains "h1.definekey":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      dcl hash h1(dataset:'loc_dist(keep=recid EQP_GPS_SPEC_LAT_CORD EQP_GPS_SPEC_Long_CORD
                  rename=(EQP_GPS_SPEC_LAT_CORD=lat EQP_GPS_SPEC_Long_CORD=long))');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, you may want to keep more variables than just SER_NO and GDIST in dataset RESULTS in order to uniquely identify the pair of points the distance GDIST belongs to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: One more mistake: &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt; should read &lt;FONT face="courier new,courier"&gt;_i&lt;/FONT&gt; in the "&lt;FONT face="courier new,courier"&gt;do i= ...&lt;/FONT&gt;" loop.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 17:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pairwise-geodist-calculation/m-p/254545#M48564</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-04T17:39:54Z</dc:date>
    </item>
  </channel>
</rss>

