<?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 find out possible pairs by years in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19741#M4057</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The log means that you don't have functions like min(), max(), count(), sum() as such in your select statement, so group by will be recognized as order by. It is fine. The second pass, I&amp;nbsp; will use sum() instead of count(), sometimes, count() could be tricky.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Mar 2012 03:08:13 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-03-03T03:08:13Z</dc:date>
    <item>
      <title>find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19733#M4049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand that proc sql can create the possible pairs from the data. But I am unclear on how this to be done by year basis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached 2 files as example:&lt;/P&gt;&lt;P&gt;comp - is the company data: zipcode, financial year(fyear) and company identification code (tic)&lt;/P&gt;&lt;P&gt;major_bank is major bank data: ban identification code (bank_id), financial year (fyear) and zipcode (bankzip)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My task is to calculate&lt;STRONG&gt; the distance in miles to the closets large bank&lt;/STRONG&gt;. I understand the ways to calculate the distance, but I have no idea on how to generate the possible pairs of origin and destination points between the company and the major banks for a given year from years 2003 to 2010. I have to get the possible pairs and then calculate distances. Lastly, i have to select the lowest distance between the company and the closest bank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some banks might available in some years but not in other years. There might be relocation of banks to another places (ie. different zip codes). My query is how to get the possible pairs for every year from 2003 to 2010?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 04:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19733#M4049</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-02T04:03:58Z</dc:date>
    </item>
    <item>
      <title>find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19734#M4050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After I import your data into library 'dist', here is one try base on SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table dist as&lt;/P&gt;&lt;P&gt;select a.fyear, catx('-',tic,bank_id) as pairs, min(zipcitydistance(zipcode,zipbank)) as min_dist &lt;/P&gt;&lt;P&gt;from dist.comp a , dist.major_bank b&lt;/P&gt;&lt;P&gt;where a.fyear=b.fyear&amp;nbsp; &lt;/P&gt;&lt;P&gt;group by a.fyear,tic&lt;/P&gt;&lt;P&gt;having not missing(calculated min_dist);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 05:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19734#M4050</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-02T05:11:21Z</dc:date>
    </item>
    <item>
      <title>find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19735#M4051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;. Everything can be solved with a very short program. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 06:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19735#M4051</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-02T06:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19736#M4052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I were to calculate number of banks which are within 60 miles from the company, is the following program correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table bankdist as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a.fyear, tic, bank_id, count(zipcitydistance(zipcode,zipbank)&amp;lt;=60) as banknum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from dist.comp a , dist.major_banks b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where a.fyear=b.fyear &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;group by a.fyear,tic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;having not missing(calculated banknum);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I feel the answer is strange (based on the program above), as almost all the answers are the same of the different companies in the same year?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 11:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19736#M4052</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-02T11:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19737#M4053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one thing I can suggest is that using:&amp;nbsp; count(.&amp;lt; zipcitydistance(zipcode,zipbank)&amp;lt;=60), and removing 'having' statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 13:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19737#M4053</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-02T13:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19738#M4054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi and thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a libname geog. I tried your suggested method and try the following as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table geog.bankbank1 as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a.fyear, tic, bank_id,zipcitydistance(zipcode, bankzip)as bankdist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from geog.comp a , geog.us_banks_unique b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where a.fyear=b.fyear &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;group by a.fyear,tic;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;having not missing(calculated bankdist);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table geog.banknum as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select fyear, tic, count(0&amp;lt;=bankdist&amp;lt;=60) as banknum &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from geog.bankbank1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;group by tic, fyear;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found the similar answer. I attached the files if you need them. I feel it is a bit strange as the number of banks within 60 miles radius is similar for different firms in the same year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 15:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19738#M4054</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-02T15:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19739#M4055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have seen some issues with your code.&amp;nbsp; The first pass, when you generate 'geog.bankbank1', if you include&amp;nbsp; bank_id, the 'group by' will be turning into 'order by'only. So you are not going to have the results you want. Try to remove it and see want happens. And when you testing your code, use options like 'obs=1000' to speed it up instead of running against the whole table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 17:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19739#M4055</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-02T17:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19740#M4056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same answer appeared even if I remove bank_id.&amp;nbsp; for answer. The following on the SAS log: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT clause nor the optional HAVING clause of the associated table-expression referenced a summary function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What does the log mean?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 02:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19740#M4056</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-03T02:20:22Z</dc:date>
    </item>
    <item>
      <title>find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19741#M4057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The log means that you don't have functions like min(), max(), count(), sum() as such in your select statement, so group by will be recognized as order by. It is fine. The second pass, I&amp;nbsp; will use sum() instead of count(), sometimes, count() could be tricky.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 03:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19741#M4057</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-03T03:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: find out possible pairs by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19742#M4058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Haikuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using sum instead of count ---- leading to answer &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MSPAK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 13:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/find-out-possible-pairs-by-years/m-p/19742#M4058</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-03-06T13:59:14Z</dc:date>
    </item>
  </channel>
</rss>

