<?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: Left join with hash:  many to many in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497846#M132111</link>
    <description>&lt;P&gt;Ok, please clarify and elaborate your requirement with your HAVE samples and WANT sample clearly. Let us work on the solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6 million is not big in my opinion. Use hashexp:20 just in case&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 14:46:04 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-21T14:46:04Z</dc:date>
    <item>
      <title>Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497367#M131805</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to make a join between a small table and a big one. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The hash method seems to me the right solution. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i develop this program, but the result&amp;nbsp; whith hash method&amp;nbsp;is different whith sql&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the case where I have to join with data many to many, how can I adapt this solution? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  a ;
input key adata adata2 ;
cards ;
1 1 2
1 1 3
2 2 5
3 3 4
4 4 6
5 5 5
6 6 6
7 7 5
;
run ;
data b ;
input key bdata ;
cards ;
1 11
1 12
3 31
4 4
6 61
6 62
6 63
7 7
;
run ;


proc sql;
create table aa as select a.key,adata,bdata,adata2
from a left join b on a.key=b.key;
quit;

data c;
 if _n_ = 1 then do ;
 if 0 then set a ;
 dcl hash b (dataset: "a", multidata: "y",ordered:'y') ;
 b.definekey ("key") ;
 b.definedata (all:'y') ;
 b.definedone () ;
 end;

  do until(eof);
   set b end=eof;
    if b.find()=0 then output;
    else do;
    call missing(adata ,bdata, adata2);
    output;
    end;
 end;
stop;
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497367#M131805</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-20T14:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497386#M131813</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  a ;
input key adata adata2 ;
cards ;
1 1 2
1 1 3
2 2 5
3 3 4
4 4 6
5 5 5
6 6 6
7 7 5
;
run ;
data b ;
input key bdata ;
cards ;
1 11
1 12
3 31
4 4
6 61
6 62
6 63
7 7
;
run ;


proc sql;
create table aa as select a.key,adata,bdata,adata2
from a left join b on a.key=b.key;
quit;

data want_hash;
 if 0 then set a b ;
 dcl hash b (dataset: "b", multidata: "y",ordered:'y') ;
 b.definekey ("key") ;
 b.definedata (all:'y') ;
 b.definedone () ;
  do until(eof);
   set a end=eof;
   rc=b.find();
   if rc ne 0 then do;
	call missing(bdata);
	output;
	end;
   else 
    do  while(rc eq 0);
     output;
	 rc=b.find_next();
    end;
 end;
stop;
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497386#M131813</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-20T14:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497392#M131818</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497392#M131818</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-20T14:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497393#M131819</link>
      <description>&lt;P&gt;Some Notes:&lt;/P&gt;
&lt;P&gt;1. No need for if _n_=1 when going for a full pass of dataset while _n_=1, since there is gonna be only one hash instance at run time&lt;/P&gt;
&lt;P&gt;2. do until pass akin to dow is apparently not any different in performance if you used if _n_=1 ,creating a hash instance and a traditional data-step as portrayed in sas docs.&lt;/P&gt;
&lt;P&gt;3. If you are using PD hash guru's style of coding, great but you have to be very careful knowing how instances&amp;nbsp; value vary and differ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well after all, it's all about &lt;U&gt;&lt;STRONG&gt;diligence&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497393#M131819</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-20T14:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497429#M131841</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can&amp;nbsp; add a filtre on the date column in the big table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 15:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497429#M131841</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-20T15:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497430#M131842</link>
      <description>&lt;P&gt;I don't see any date values in your samples. I assume you can&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 15:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497430#M131842</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-20T15:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497821#M132095</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the 8 and 9 did not come in result whith Hash method?&lt;/P&gt;&lt;P&gt;thank you&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  a ;
input key adata adata2 ;
cards ;
1 1 2
1 1 3
2 2 5
8 7 5
9 5 4
;
run ;

data b ;
input key bdata ;
cards ;
1 11
1 12
3 31
4 4
6 61
6 62
6 63
7 7
;
run ;


proc sql;
create table yes as select a.*,b.bdata
from a left join b on a.key=b.key;
quit;


data want_hash;
 if 0 then set a ;
 dcl hash b (dataset: "a", multidata: "y",ordered:'y') ;
 b.definekey ("key") ;
 b.definedata (all:'y') ;
 b.definedone () ;
  do until(eof);
   set b end=eof;
   rc=b.find();
   if rc ne 0 then do;
	call missing(bdata);
	output;
	end;
   else 
    do  while(rc eq 0);
     output;
	 rc=b.find_next();
    end;
 end;
stop;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497821#M132095</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-21T14:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497830#M132100</link>
      <description>&lt;P&gt;Your left table is &lt;STRONG&gt;a , &lt;/STRONG&gt;but in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  do until&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;eof&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; b end&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;eof&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;so change the above to&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  do until&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;eof&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; a end&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;eof&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>Fri, 21 Sep 2018 14:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497830#M132100</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-21T14:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497836#M132104</link>
      <description>&lt;P&gt;Yes, the table A is the left table.&lt;/P&gt;&lt;P&gt;It's the small table that is loaded in memory through declare the object hash&lt;/P&gt;&lt;P&gt;In the statement set; the big table is B.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497836#M132104</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-21T14:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497840#M132105</link>
      <description>&lt;P&gt;to match the sql results, the change i suggested works&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497840#M132105</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-21T14:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497845#M132110</link>
      <description>&lt;P&gt;The table B have 6 millions obseravation. loaded this in memory ?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497845#M132110</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-09-21T14:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Left join with hash:  many to many</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497846#M132111</link>
      <description>&lt;P&gt;Ok, please clarify and elaborate your requirement with your HAVE samples and WANT sample clearly. Let us work on the solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6 million is not big in my opinion. Use hashexp:20 just in case&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-join-with-hash-many-to-many/m-p/497846#M132111</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-21T14:46:04Z</dc:date>
    </item>
  </channel>
</rss>

