<?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 Condition on Inner Join and the rest. in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876134#M42971</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Could someone clarify the effect of using different conditions, such as "greater," "smaller," or "not equal," when joining tables? I initially thought that an inner join requires an equal condition, but now I see that other conditions are possible. How does selecting "not equal" instead of "equal" impact the inner join?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ralizadeh_1-1684278761010.png" style="width: 578px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84045i49370A6FE5A377F1/image-dimensions/578x529?v=v2" width="578" height="529" role="button" title="ralizadeh_1-1684278761010.png" alt="ralizadeh_1-1684278761010.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
   CREATE TABLE WORK.Non_Preg_Count AS 
   SELECT t1.CIN AS CIN1, 
          t1.New_Month AS New_Month1, 
          t2.CIN AS CIN2, 
          t2.New_Month AS New_Month2
      FROM WORK.MERGED_FINAL t1
           INNER JOIN WORK.MERGED_PREG_FINAL t2 ON (t1.CIN ^= t2.CIN);
QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 23:13:52 GMT</pubDate>
    <dc:creator>ralizadeh</dc:creator>
    <dc:date>2023-05-16T23:13:52Z</dc:date>
    <item>
      <title>Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876134#M42971</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Could someone clarify the effect of using different conditions, such as "greater," "smaller," or "not equal," when joining tables? I initially thought that an inner join requires an equal condition, but now I see that other conditions are possible. How does selecting "not equal" instead of "equal" impact the inner join?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ralizadeh_1-1684278761010.png" style="width: 578px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84045i49370A6FE5A377F1/image-dimensions/578x529?v=v2" width="578" height="529" role="button" title="ralizadeh_1-1684278761010.png" alt="ralizadeh_1-1684278761010.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
   CREATE TABLE WORK.Non_Preg_Count AS 
   SELECT t1.CIN AS CIN1, 
          t1.New_Month AS New_Month1, 
          t2.CIN AS CIN2, 
          t2.New_Month AS New_Month2
      FROM WORK.MERGED_FINAL t1
           INNER JOIN WORK.MERGED_PREG_FINAL t2 ON (t1.CIN ^= t2.CIN);
QUIT;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 23:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876134#M42971</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-05-16T23:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876140#M42972</link>
      <description>&lt;P&gt;The INNER JOIN means that both sides have to contribute to the join by matching based on the ON criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The use of NOT EQUAL operator as part of the logic of the ON condition just means that the test that needs to succeed for the combination to be considered a match is that the two values being compared are not equal.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 00:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876140#M42972</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-17T00:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876145#M42973</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, but I am not sure if I get your point. In the picture I shared, the ON condition is based on CIN i.e. t1.CIN1 = t2.CIN2. So, it won't make sense to me to have t1.CIN1=t2.CIN2 in my INNER JOIN and also t1.CIN1 ^= t2.CIN2 as another condition. Am I missing something here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 01:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876145#M42973</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-05-17T01:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876150#M42974</link>
      <description>&lt;P&gt;It's a good question, but I think you've got yourself into a bit of a muddle. I explain a SQL join as "First, all of the records are matched with all of the records (a cartesian join)." "Second, based on your selection criteria, any records that don't match the criteria are removed". So, suppose t1.CIN values are a, c, e and t2.CIN values are b, c, e. After step one, you'll have 9 records with keys a, b; a, c; a, e; c, b; c, c; c, e; e, b; e, c; e, e. Now, step 2, follow the selection criteria. This will remove records c, c and e, e leaving you with 7 records.&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 02:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876150#M42974</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2023-05-17T02:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876152#M42975</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440479"&gt;@ralizadeh&lt;/a&gt;&amp;nbsp;wrote &lt;EM&gt;&lt;STRONG&gt;(bold italics mine)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, but I am not sure if I get your point. In the picture I shared, the ON condition &lt;EM&gt;&lt;STRONG&gt;is based on CIN i.e. t1.CIN1 = t2.CIN2.&lt;/STRONG&gt;&lt;/EM&gt; So, it won't make sense to me to have t1.CIN1=t2.CIN2 in my INNER JOIN and also t1.CIN1 ^= t2.CIN2 as another condition. Am I missing something here?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;
&lt;P&gt;I don't see any instance of t1.cin=t2.cin in your picture (reproduced below) or in the associated code box.&amp;nbsp; BTW, you typed t1.cin1=t2.cin2 - I presume you meant t1.cin=t2.cin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mkeintz_0-1684291853014.png" style="width: 699px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84046i6884477BF16A1433/image-dimensions/699x640?v=v2" width="699" height="640" role="button" title="mkeintz_0-1684291853014.png" alt="mkeintz_0-1684291853014.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 02:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876152#M42975</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-05-17T02:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876153#M42976</link>
      <description>&lt;P&gt;SQL can be a little weird, especially when you're using something like EG, which tries to give you a user-friendly interface. It might be easier for you to do some experimenting, and see what happens. I suggest you try these as t1 and t2, and see what happens. Feel free to post questions. It'll give everybody a basis for discussion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T!:&lt;/P&gt;
&lt;PRE&gt;Recnum1	CIN
101	a
102	(null)
103	a
104	c
105	e
106	(null)
107	f
108	f
109	g
&lt;/PRE&gt;
&lt;P&gt;T2:&lt;/P&gt;
&lt;PRE&gt;Recnum2	CIN
201	(null)
202	a
203	a
204	b
205	b
206	c
207	c
208	(null)
209	g
&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 03:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876153#M42976</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2023-05-17T03:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876154#M42977</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440479"&gt;@ralizadeh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, but I am not sure if I get your point. In the picture I shared, the ON condition is based on CIN i.e. t1.CIN1 = t2.CIN2. So, it won't make sense to me to have t1.CIN1=t2.CIN2 in my INNER JOIN and also t1.CIN1 ^= t2.CIN2 as another condition. Am I missing something here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand what you are asking.&amp;nbsp; That GUI tool looks like it is used to generate the SQL by letting your point and click.&amp;nbsp; So if you select the = operator it generates code with the = operator.&amp;nbsp; If you select the ^= operator it generates code with the ^= operator.&amp;nbsp; Note that the ^ is just short hand for NOT.&amp;nbsp; In SAS code you can also just the pneumonic NE for not equal in the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 03:17:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876154#M42977</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-17T03:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876161#M42978</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15142"&gt;@TomKari&lt;/a&gt;&amp;nbsp;I am getting somewhere now. So, in this case, if I want to pull the CINs that are NOT in t2 table how should I proceed? should I just use Inner Join with&amp;nbsp; t1.CIN ^= t2.CIN?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get this with SAS EG:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorralizadeh_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;ELECT * FROM TableA
LEFT OUTER JOIN TableB
ON TableA.name = TableB.name
&lt;STRONG&gt;WHERE TableB.id IS null&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorralizadeh_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6a0120a85dcdae970b012877702754970c-pi.png" style="width: 397px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84049i69A4B39E56E4A5FC/image-dimensions/397x260?v=v2" width="397" height="260" role="button" title="6a0120a85dcdae970b012877702754970c-pi.png" alt="6a0120a85dcdae970b012877702754970c-pi.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 04:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876161#M42978</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-05-17T04:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Condition on Inner Join and the rest.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876163#M42979</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table Want AS 
  select T1.*
  from WORK.MERGED_FINAL t1
  left join WORK.MERGED_PREG_FINAL t2 
  on t1.CIN = t2.CIN
  where missing(t2.CIN)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 04:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Condition-on-Inner-Join-and-the-rest/m-p/876163#M42979</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-05-17T04:23:58Z</dc:date>
    </item>
  </channel>
</rss>

