<?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 Re: Base SAS Programming in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364257#M86374</link>
    <description>&lt;P&gt;You owe me one hundred dollars .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input PS   $   Lat            Long         SLOT;
cards;
abc    75.8233    26.2454     1
abc    75.4785    26.4589     1
abc    75.5495    26.4679     1
abc    75.4875    26.8997     2
abc    75.5649    26.7268     2
abc    75.5666    26.8647     2
xyz    75.4875    26.3842      1
xyz    75.4937    26.5877      1
xyz    75.8473    26.3971      1
;
run;

data first rest;
 set have;
 by ps slot;
 if first.slot then output first;
  else output rest;
run;
proc sql;
select b.*,1000*geodist(a.lat,a.long,b.lat,b.long,'k') as distance_in_meters
 from first as a,rest as b 
  where a.ps=b.ps and a.slot=b.slot ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Jun 2017 12:28:31 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-06-05T12:28:31Z</dc:date>
    <item>
      <title>Base SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364245#M86366</link>
      <description>&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-left lia-quilt-column-main-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-author lia-component-author"&gt;&lt;DIV class="lia-message-author-post-count"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;I have the following data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS &amp;nbsp; &amp;nbsp; &amp;nbsp;Lat &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Long &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SLOT&lt;/P&gt;&lt;P&gt;abc &amp;nbsp; &amp;nbsp;75.8233 &amp;nbsp; &amp;nbsp;26.2454 &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;abc &amp;nbsp; &amp;nbsp;75.4785 &amp;nbsp; &amp;nbsp;26.4589 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc &amp;nbsp; &amp;nbsp;75.5495 &amp;nbsp; &amp;nbsp;26.4679 &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;abc &amp;nbsp; &amp;nbsp;75.4875 &amp;nbsp; &amp;nbsp;26.8997 &amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;abc &amp;nbsp; &amp;nbsp;75.5649 &amp;nbsp; &amp;nbsp;26.7268 &amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;abc &amp;nbsp; &amp;nbsp;75.5666 &amp;nbsp; &amp;nbsp;26.8647 &amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;xyz &amp;nbsp; &amp;nbsp;75.4875 &amp;nbsp; &amp;nbsp;26.3842 &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;xyz &amp;nbsp; &amp;nbsp;75.4937 &amp;nbsp; &amp;nbsp;26.5877 &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;xyz &amp;nbsp; &amp;nbsp;75.8473 &amp;nbsp; &amp;nbsp;26.3971 &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;.... &amp;nbsp; &amp;nbsp; ............. &amp;nbsp; &amp;nbsp; ............. &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want a new column which shows the distances in the following way:&lt;/P&gt;&lt;P&gt;All the points with PS=abc and Slot=1 &amp;nbsp;should have their distances calculated from the first point of this group(i.e., &lt;SPAN&gt;&amp;nbsp;75.8233 &amp;nbsp; &amp;nbsp;26.2454&lt;/SPAN&gt;), similarly all the points with PS=abc and Slot=2 should have their distances calculated from the first point of this group(i.e., &lt;SPAN&gt;75.4875 &amp;nbsp; &amp;nbsp;26.8997&lt;/SPAN&gt;) and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So please suggest me a solution for this.&lt;/P&gt;&lt;P&gt;Also the points should not be entered manually, a programmable solution is needed.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Jun 2017 11:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364245#M86366</guid>
      <dc:creator>Himanshu007</dc:creator>
      <dc:date>2017-06-05T11:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364253#M86370</link>
      <description>&lt;P&gt;Post test data in the form of a datastep, we are not here to type test data in nor guess what the structure is. &amp;nbsp;Hence this code is just a guess, also the output is a guess as you have not shown what you want out.&lt;/P&gt;
&lt;PRE&gt;data first;
  set have;
  by ps slot;
  if first.slot then output;
run;
data want;
  merge have first (rename=(lat=comp_lat long=comp_long));
  by ps slot;
  dist=lat - comp_lat;
  dist2=long - comp_long;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 12:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364253#M86370</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-05T12:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364257#M86374</link>
      <description>&lt;P&gt;You owe me one hundred dollars .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input PS   $   Lat            Long         SLOT;
cards;
abc    75.8233    26.2454     1
abc    75.4785    26.4589     1
abc    75.5495    26.4679     1
abc    75.4875    26.8997     2
abc    75.5649    26.7268     2
abc    75.5666    26.8647     2
xyz    75.4875    26.3842      1
xyz    75.4937    26.5877      1
xyz    75.8473    26.3971      1
;
run;

data first rest;
 set have;
 by ps slot;
 if first.slot then output first;
  else output rest;
run;
proc sql;
select b.*,1000*geodist(a.lat,a.long,b.lat,b.long,'k') as distance_in_meters
 from first as a,rest as b 
  where a.ps=b.ps and a.slot=b.slot ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 12:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364257#M86374</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-05T12:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364260#M86376</link>
      <description>Thnx a lot, it's exactly what I wanted.</description>
      <pubDate>Mon, 05 Jun 2017 13:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS-Programming/m-p/364260#M86376</guid>
      <dc:creator>Himanshu007</dc:creator>
      <dc:date>2017-06-05T13:00:37Z</dc:date>
    </item>
  </channel>
</rss>

