<?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 tables merging more then 2 tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387189#M92810</link>
    <description>&lt;P&gt;I have written this code already. It seems to be fast enough,&lt;/P&gt;&lt;P&gt;klasa3 is left join table and klasa1 is inner join table.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hash_test;

 if 0 then set klasa1 klasa2 klasa3;
if _N_= 1 then do;
declare hash merge(dataset:'klasa1');
	merge.definekey('name');
	merge.definedata(all:'yes');
	merge.definedone();

declare hash merge2(dataset:'klasa3');
	merge2.definekey('name');
	merge2.definedata('test');
	merge2.definedone();
end;
	
 do until(eof);
 set klasa2 end=eof;
 
rc=merge2.find();
if rc =0 then do;
	if merge.find()=0 then output;
end;
else do;
	if merge.find()=0 then do;
    call missing (test);
   	output;
end;
end;

end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 10 Aug 2017 21:14:13 GMT</pubDate>
    <dc:creator>Matt3</dc:creator>
    <dc:date>2017-08-10T21:14:13Z</dc:date>
    <item>
      <title>Hash tables merging more then 2 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387004#M92741</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to hash tables, I know this is an efficient way to merge tables. I have found articles how to merge two or more tables in one way only left join, right join or inner in one data step, already. However, I wonder if it is possible to merge three or more tables. Two of them like using left join, third inner join by hash tables in one data step? &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 17:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387004#M92741</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-08-10T17:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Hash tables merging more then 2 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387134#M92800</link>
      <description>&lt;P&gt;Yes, it is possible.&amp;nbsp; But if the datasets have variables in common other than the join keys, you'll have to program logic accordingly.&amp;nbsp; SQL is easier in this regard in that you can just specify&amp;nbsp;A.myvar or B.myvar, etc.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 18:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387134#M92800</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-08-10T18:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Hash tables merging more then 2 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387142#M92801</link>
      <description>&lt;P&gt;I am working with large datasets so, I guess hash tables should be more efficient.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 18:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387142#M92801</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-08-10T18:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hash tables merging more then 2 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387187#M92809</link>
      <description>&lt;P&gt;Please note hash tables need to be loaded into memory so the more tables you load the less available memory you will have for each table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to balance any performance gains you might get against the increased coding complexity and any memory limitations you might have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are doing any data lookups in your joins (looking up just one or two columns) you might want to consider using SAS format lookups instead. They are a lot less complicated to code and are just as fast as hash tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 20:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387187#M92809</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-08-10T20:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Hash tables merging more then 2 tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387189#M92810</link>
      <description>&lt;P&gt;I have written this code already. It seems to be fast enough,&lt;/P&gt;&lt;P&gt;klasa3 is left join table and klasa1 is inner join table.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hash_test;

 if 0 then set klasa1 klasa2 klasa3;
if _N_= 1 then do;
declare hash merge(dataset:'klasa1');
	merge.definekey('name');
	merge.definedata(all:'yes');
	merge.definedone();

declare hash merge2(dataset:'klasa3');
	merge2.definekey('name');
	merge2.definedata('test');
	merge2.definedone();
end;
	
 do until(eof);
 set klasa2 end=eof;
 
rc=merge2.find();
if rc =0 then do;
	if merge.find()=0 then output;
end;
else do;
	if merge.find()=0 then do;
    call missing (test);
   	output;
end;
end;

end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 21:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-tables-merging-more-then-2-tables/m-p/387189#M92810</guid>
      <dc:creator>Matt3</dc:creator>
      <dc:date>2017-08-10T21:14:13Z</dc:date>
    </item>
  </channel>
</rss>

