<?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: Join with AND function in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652953#M36157</link>
    <description>Thanks for the example. This has made a lot of sense and after re-visiting documentation on joins in SAS EG I found the "edit" button in the GUI section of the joins and tables where I can add in those ON statements. Much appreciated!</description>
    <pubDate>Wed, 03 Jun 2020 17:45:50 GMT</pubDate>
    <dc:creator>mmagnuson</dc:creator>
    <dc:date>2020-06-03T17:45:50Z</dc:date>
    <item>
      <title>Join with AND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652940#M36155</link>
      <description>&lt;P&gt;Hello, I am working on taking code from a program and building it out in GUI format for other SAS users who have limited understanding with reading programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came across code similar to the following:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;CREATE TABLE Gridwork.Test AS&lt;/P&gt;&lt;P&gt;&amp;nbsp;SELECT t1.ID1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t2.ID2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t1.First_Column,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t2.Second_Column&lt;/P&gt;&lt;P&gt;FROM Gridwork.Dataset1 t1&lt;/P&gt;&lt;P&gt;LEFT JOIN Gridwork.Dataset2 v2 ON (t1.ID=t2.ID) AND (t2.ID &amp;lt;&amp;gt; "0")&lt;/P&gt;&lt;P&gt;WHERE t1.First_Column not is missing&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is in regards to the "AND" within the Left Join statement.&amp;nbsp; Is it the same as just taking t2.&amp;lt;&amp;gt;"0" and putting it in the where statement similar to below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CREATE TABLE Gridwork.Test AS&lt;/P&gt;&lt;P&gt;&amp;nbsp;SELECT t1.ID1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t2.ID2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t1.First_Column,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t2.Second_Column&lt;/P&gt;&lt;P&gt;FROM Gridwork.Dataset1 t1&lt;/P&gt;&lt;P&gt;LEFT JOIN Gridwork.Dataset2 v2 ON (t1.ID=t2.ID)&lt;/P&gt;&lt;P&gt;WHERE t1.First_Column not is missing AND t2.ID&amp;lt;&amp;gt;"0"&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm unsure of how to make that "t2.ID&amp;lt;&amp;gt;"0" distinction within the "Tables and Joins" section of SAS EG.&amp;nbsp; There only seems to be the ability to pick the join, join order and that's it. Any "and" functionality without programming seems to lead itself to a "Where" clause but that looks different than the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope I explained this well and thanks for any help!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 16:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652940#M36155</guid>
      <dc:creator>mmagnuson</dc:creator>
      <dc:date>2020-06-03T16:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Join with AND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652950#M36156</link>
      <description>&lt;P&gt;The location of the condition (ON clause vs WHERE clause) can make a difference for LEFT joins. The ON clause is evaluated during the join, when the condition involves the right table and is not met, the record is kept in the results with the right side columns set to missing. When the condition figures in the WHERE clause, it is evaluated &lt;EM&gt;after&lt;/EM&gt; the join. Right side columns enter the condition as missing and may cause the record to be excluded from the result set. An example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
do r = "A", "B", "C";
    output;
    end;
run;

data b;
r = "A"; x = 1; output;
r = "C"; x = 3; output;
run;

proc sql;
title "Condition in join";
select a.r, b.x
from a left join b on a.r=b.r and x &amp;gt; 0;
title "Condition in where";
select a.r, b.x
from a left join b on a.r=b.r
where x &amp;gt; 0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Condition in join
r 	x
A 	1
B 	.
C 	3

Condition in where
r 	x
A 	1
C 	3&lt;/PRE&gt;
&lt;P&gt;when the condition is in the WHERE clause, the value of x (missing) is compared to 0 and the record is rejected.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 17:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652950#M36156</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-03T17:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Join with AND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652953#M36157</link>
      <description>Thanks for the example. This has made a lot of sense and after re-visiting documentation on joins in SAS EG I found the "edit" button in the GUI section of the joins and tables where I can add in those ON statements. Much appreciated!</description>
      <pubDate>Wed, 03 Jun 2020 17:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-with-AND-function/m-p/652953#M36157</guid>
      <dc:creator>mmagnuson</dc:creator>
      <dc:date>2020-06-03T17:45:50Z</dc:date>
    </item>
  </channel>
</rss>

