<?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: Distance calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249612#M46980</link>
    <description>&lt;P&gt;It will be easier and faster if you post your sql code. So we can suggest the equivalent in data step or hash.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2016 07:57:17 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2016-02-12T07:57:17Z</dc:date>
    <item>
      <title>Distance calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249604#M46978</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS file with the followign variables:&lt;/P&gt;
&lt;P&gt;Company identification code: CIK&lt;/P&gt;
&lt;P&gt;Auditor Key:&amp;nbsp;AUDITOR_FKEY&lt;/P&gt;
&lt;P&gt;Audit fees: AUDITOR_FEES&lt;/P&gt;
&lt;P&gt;FYEAR: Financial Year&lt;/P&gt;
&lt;P&gt;ZIPCODE: ZIP1&lt;/P&gt;
&lt;P&gt;CBSA:&amp;nbsp;&lt;SPAN class="st"&gt;Core Based Statistical Area&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SIC2: SIC code 2-digit&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would liKE to calculate the absolute difference between the current auditor's market share in client's industry (note: client = CIK, industry =SIC2) and the market share of his closest (other) auditor in the market (Same CBSA,&amp;nbsp;SIC2 and FYEAR).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Market share =proportion of audit fees&amp;nbsp;an audit firm&amp;nbsp;generates in a 2-digit SIC industry relative to the total audit fees&amp;nbsp;generated by all&amp;nbsp;audit firms in an CBSA and in a given year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have programs in sql, however, it consumes too much memory and time. I would like to seek for your helps to get some ideas in SAS HASH.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You help is much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;mspak&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 07:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249604#M46978</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2016-02-12T07:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Distance calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249612#M46980</link>
      <description>&lt;P&gt;It will be easier and faster if you post your sql code. So we can suggest the equivalent in data step or hash.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 07:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249612#M46980</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-12T07:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Distance calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249626#M46983</link>
      <description>&lt;P&gt;The following is the possible steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*step 1: calculate the total fee of each auditor in the market;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table sum1 as&lt;BR /&gt;select *,sum(audit_fees) as fee_sum&lt;BR /&gt;&amp;nbsp; from cluster.forum&lt;BR /&gt;&amp;nbsp;&amp;nbsp; group by auditor_fkey, fyear,sic2,cbsa;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;*step 2: calculate the total fees charged in the market;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table sum2 as&lt;BR /&gt;select *,sum(audit_fees) as market_fee&lt;BR /&gt;&amp;nbsp; from fee1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; group by fyear,sic2,cbsa;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;*step 3: calculate the market share of each auditor in the market;&lt;BR /&gt;&lt;BR /&gt;data sum3;&lt;BR /&gt;set sum2;&lt;BR /&gt;fee_shr = fee_sum/market_fee;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*step 4: calculate the closest competitors in the market &lt;BR /&gt;(market size is depend on CBSA, SIC2 and fyear);&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table geog.dist as&lt;BR /&gt;select a.*, min(zipcitydistance(a.zip1,b.zip1)) as min_dist&lt;BR /&gt;from sum3 a , sum3 b&lt;BR /&gt;where a.fyear=b.fyear &lt;BR /&gt;group by fyear, sic2, cbsa&lt;BR /&gt;having not missing(calculated min_dist);&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;*step5: only output the data with closest competitors in the market;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 12:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249626#M46983</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2016-02-12T12:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Distance calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249871#M47063</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the following SQL program to be included in hash:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table dist as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select a.*, min(zipcitydistance(a.zip1,b.zip1)) as min_dist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from sum3 a , sum3 b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by fyear, sic2, cbsa&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;having not missing(calculated min_dist);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you in advance for any solution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;mspak&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2016 13:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Distance-calculation/m-p/249871#M47063</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2016-02-13T13:53:03Z</dc:date>
    </item>
  </channel>
</rss>

