<?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: Make data step working like SQL right join in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6794#M703</link>
    <description>Thank you for this code, but I need to use hash objects, because there are very large tables and i have no idea how can I do this using merge.</description>
    <pubDate>Wed, 06 Feb 2008 15:34:58 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-02-06T15:34:58Z</dc:date>
    <item>
      <title>Make data step working like SQL right join</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6792#M701</link>
      <description>Hi gyes&lt;BR /&gt;
I need to make this code &lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data test;&lt;BR /&gt;
	set table1;&lt;BR /&gt;
	declare hash h0 (dataset: "table1",hashexp:10);&lt;BR /&gt;
	h0.DefineKey ("Field1");&lt;BR /&gt;
	h0.DefineData ("Field2");&lt;BR /&gt;
&lt;BR /&gt;
	h0.DefineDone();&lt;BR /&gt;
&lt;BR /&gt;
	do until (eof);&lt;BR /&gt;
	    set table2 end=eof;&lt;BR /&gt;
	    rc=h0.find();&lt;BR /&gt;
	    if rc = 0 then output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
worked like this SQL-query:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;create table test as (select * from table2 t2 right join table1 t1 on t1.Field1 = t2.Field1);&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
It almost the same, but sql outputs records even they are not in table2 (cause of right join) and data step doesn't do that.&lt;BR /&gt;
Can somebody please explain how can I force it to output null record?</description>
      <pubDate>Wed, 06 Feb 2008 14:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6792#M701</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-02-06T14:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Make data step working like SQL right join</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6793#M702</link>
      <description>What you want is a MERGE, not a SET.&lt;BR /&gt;
&lt;BR /&gt;
* untested code;&lt;BR /&gt;
PROC SORT DATA=table1; BY field1; RUN;&lt;BR /&gt;
PROC SORT DATA=table2; BY field2; RUN;&lt;BR /&gt;
&lt;BR /&gt;
DATA test;&lt;BR /&gt;
MERGE  table2 (in=int2) &lt;BR /&gt;
              table1 (in=in1);&lt;BR /&gt;
BY field1;&lt;BR /&gt;
IF in1;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
You may get slightly different results if there are repeated values of field1 (particularly if there are matching repeats in both datasets).&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Wed, 06 Feb 2008 15:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6793#M702</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2008-02-06T15:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Make data step working like SQL right join</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6794#M703</link>
      <description>Thank you for this code, but I need to use hash objects, because there are very large tables and i have no idea how can I do this using merge.</description>
      <pubDate>Wed, 06 Feb 2008 15:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6794#M703</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-02-06T15:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Make data step working like SQL right join</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6795#M704</link>
      <description>Hi:&lt;BR /&gt;
  If you have an immediate need, I think your best bet for a response is to contact SAS Tech Support.&lt;BR /&gt;
&lt;BR /&gt;
  The problem I'm having with your request is your insistence on using Hash tables. Even if you have a large file, a hash table might not be the best way to get a count and a sum, even with the need to do the join. On the other hand, a hash table might be the right approach. Only Tech Support can tell you for sure. Like Doc, I would use Proc Means or Proc Tabulate, both of which are highly efficient at summarizing and/or counting.&lt;BR /&gt;
&lt;BR /&gt;
  However, since you really seem to want a hash table approach, then Tech Support would be the right people to help you. They can find out ALL the specifics of your big tables and help you with a solution in a timely manner.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 06 Feb 2008 16:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Make-data-step-working-like-SQL-right-join/m-p/6795#M704</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-02-06T16:13:02Z</dc:date>
    </item>
  </channel>
</rss>

