<?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: Hash join Learning in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518781#M140445</link>
    <description>&lt;P&gt;&lt;STRONG&gt;"what if i need to join more than two tables"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you post a third data set and, I can provide you a usable code answer. The short answer is to define another hash object and use the find() method again.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"any relevant doc to study Hash"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is plenty of material to study in the &lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1b4cbtmb049xtn1vh9x4waiioz4.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SAS Hash Object Documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I found the two books &lt;A href="https://www.sas.com/store/da_dk/books/categories/usage-and-reference/sas-hash-object-programming-made-easy/prodBK_62230_en.html" target="_self"&gt;SAS Hash Object Programming Made Easy&lt;/A&gt;&amp;nbsp;by Michelle Burlew and &lt;A href="https://www.sas.com/store/da_dk/books/categories/examples/data-management-solutions-using-sas-hash-table-operations-a-business-intelligence-case-study/prodBK_69153_en.html" target="_self"&gt;Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study&lt;/A&gt;&amp;nbsp;By Don Hendersen and Paul Dorfman to be the best learning material on the topic out there.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Dec 2018 13:51:06 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-12-05T13:51:06Z</dc:date>
    <item>
      <title>Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518681#M140394</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for same output from HASH join as i have from proc sql. Kindly help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA A;&lt;BR /&gt;input Name $1. Salary Age;&lt;BR /&gt;Cards;&lt;BR /&gt;A 200 20&lt;BR /&gt;B 300 30&lt;BR /&gt;C 400 40&lt;BR /&gt;D 500 50&lt;BR /&gt;E 600 60&lt;BR /&gt;F 700 70&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;DATA B;&lt;BR /&gt;input Name $1. Salary Grade$2.;&lt;BR /&gt;Cards;&lt;BR /&gt;A 200 AA&lt;BR /&gt;G 800 GG&lt;BR /&gt;H 900 HH&lt;BR /&gt;I 1000 II&lt;BR /&gt;F 700 FF&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Proc print;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql; create table AB_SQL as select A.*,B.Grade from A left join B on A.Name=B.Name; quit;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 07:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518681#M140394</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-05T07:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518683#M140395</link>
      <description>&lt;P&gt;Do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data AB_Hash(drop=rc);
   if 0 then set A B;
   if _N_ = 1 then do;
      declare hash h(dataset:'B');
      h.defineKey('Name');
      h.defineData('Grade');
      h.defineDone();
   end;

   set A;

   rc=h.find();
   if rc ne 0 then Grade='';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 07:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518683#M140395</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T07:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518689#M140399</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="未命名.JPG" style="width: 335px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25373iF8D60AEF5B870B6D/image-size/large?v=v2&amp;amp;px=999" role="button" title="未命名.JPG" alt="未命名.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 07:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518689#M140399</guid>
      <dc:creator>learsaas</dc:creator>
      <dc:date>2018-12-05T07:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518690#M140400</link>
      <description>&lt;P&gt;You can verify that the data sets are identical with a simple PROC COMPARE like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc compare data=AB_SQL compare=AB_Hash;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 07:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518690#M140400</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T07:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518692#M140402</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192107"&gt;@learsaas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="未命名.JPG" style="width: 335px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25373iF8D60AEF5B870B6D/image-size/large?v=v2&amp;amp;px=999" role="button" title="未命名.JPG" alt="未命名.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post code as text, not as picture. Also note that hash.find returns 0 if the key was found.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 07:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518692#M140402</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-05T07:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518740#M140431</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;quick question.. Suppose i have 100 variables in B data set and want 40 variable from it in output.&lt;/P&gt;
&lt;P&gt;Do i need to define them in below mentioned style:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;defineData&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Grade',GR1,TR1,AR20&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518740#M140431</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-05T11:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518741#M140432</link>
      <description>&lt;P&gt;There are several ways to do this. Do the 40 variables in question have some common naming scheme?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And remember, the variables here should be in quotation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;defineData&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Grade'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,'&lt;/SPAN&gt;GR1'&lt;SPAN class="token punctuation"&gt;,'&lt;/SPAN&gt;TR1'&lt;SPAN class="token punctuation"&gt;,'&lt;/SPAN&gt;AR20'&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518741#M140432</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T11:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518770#M140440</link>
      <description>&lt;P&gt;yes.... All the variable has different name...No pattern and output includes both type like character (20 var) and Numeric (20 var).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 12:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518770#M140440</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-05T12:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518773#M140441</link>
      <description>&lt;P&gt;If all the variables have different names, no common prefixes or like that exists, then it is probably the best to just type them in manually. Unless you can live with the fact that all the variables are defined in the data portion of your hash object. In that case you could do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;h.defineData(all:"Y");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518773#M140441</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T13:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518779#M140444</link>
      <description>&lt;P&gt;Great ... able to do that...&lt;/P&gt;
&lt;P&gt;other important question ... what if i need to join more than two tables..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and any relevant doc to study Hash ...&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518779#M140444</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-05T13:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518781#M140445</link>
      <description>&lt;P&gt;&lt;STRONG&gt;"what if i need to join more than two tables"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you post a third data set and, I can provide you a usable code answer. The short answer is to define another hash object and use the find() method again.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"any relevant doc to study Hash"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is plenty of material to study in the &lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1b4cbtmb049xtn1vh9x4waiioz4.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SAS Hash Object Documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I found the two books &lt;A href="https://www.sas.com/store/da_dk/books/categories/usage-and-reference/sas-hash-object-programming-made-easy/prodBK_62230_en.html" target="_self"&gt;SAS Hash Object Programming Made Easy&lt;/A&gt;&amp;nbsp;by Michelle Burlew and &lt;A href="https://www.sas.com/store/da_dk/books/categories/examples/data-management-solutions-using-sas-hash-table-operations-a-business-intelligence-case-study/prodBK_69153_en.html" target="_self"&gt;Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study&lt;/A&gt;&amp;nbsp;By Don Hendersen and Paul Dorfman to be the best learning material on the topic out there.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518781#M140445</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T13:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518784#M140447</link>
      <description>what about inner join... I have tried hash for inner as well but in log... Table A has been read by 2 times..Can you please help me for inner join as well (optimized)</description>
      <pubDate>Wed, 05 Dec 2018 14:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518784#M140447</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-05T14:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518795#M140451</link>
      <description>&lt;P&gt;You can simulate an inner join using the return code &lt;STRONG&gt;rc&amp;nbsp;&lt;/STRONG&gt;from the find() method like this (Not I changed the left join to an inner join in your initial code for demonstration purposes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; create table AB_SQL as select A.*,B.Grade from A inner join B on A.Name=B.Name; quit;

data AB_Hash(drop=rc);
   if 0 then set A B;
   if _N_ = 1 then do;
      declare hash h(dataset:'B');
      h.defineKey('Name');
      h.defineData('Grade');
      h.defineDone();
   end;

   set A;

   rc=h.find();
   if rc eq 0;
run;

proc compare data=AB_SQL compare=AB_Hash;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Dec 2018 14:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/518795#M140451</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T14:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/520797#M141254</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am so sorry for my delayed response.&lt;/P&gt;
&lt;P&gt;During this time i tried with one more table for inner and left join but i was not able to do that.&lt;/P&gt;
&lt;P&gt;Kindly help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA C;&lt;BR /&gt;input Name $1. dept;&lt;BR /&gt;Cards;&lt;BR /&gt;A 111&lt;BR /&gt;B 222&lt;BR /&gt;C 333&lt;BR /&gt;Z 000&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/520797#M141254</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2018-12-12T13:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Hash join Learning</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/520799#M141255</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/46512"&gt;@umashankersaini&lt;/a&gt;, please open a new thread. That will help other users benefit from your question and the answers.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-join-Learning/m-p/520799#M141255</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-12T13:26:26Z</dc:date>
    </item>
  </channel>
</rss>

