<?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 missing rows from left table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730483#M227464</link>
    <description>&lt;P&gt;I tried AND too instead of where and that bring me 320K records back.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 19:51:31 GMT</pubDate>
    <dc:creator>sasuser_sk</dc:creator>
    <dc:date>2021-03-31T19:51:31Z</dc:date>
    <item>
      <title>Left Join missing rows from left table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730478#M227461</link>
      <description>&lt;P&gt;Hi: I have 280K records in left table and over a million in table 2. My join brings me 100K records only. I don't understand the problem as to why data is dropped in left join. I have tried it two ways but both bring back 100K records. Help will be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Methods1:&lt;/STRONG&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.ASSIGNS AS &lt;BR /&gt;SELECT DISTINCT t1.ACCT_NO, &lt;BR /&gt;t1.ACCT_NO_DET, &lt;BR /&gt;t1.PROD_ONE, &lt;BR /&gt;t1.PROD_TWO, &lt;BR /&gt;t1.START_DATE, &lt;BR /&gt;t1.END_DATE,&lt;BR /&gt;t2.PROD_DETAILS&lt;BR /&gt;&lt;BR /&gt;FROM WORK.CUSTOMER t1&lt;BR /&gt;LEFT JOIN SCHEMA.PRODUCTS t2 ON (t1.ACCT = t2.ACCT_NO) AND (t1.ACCT_NO_DET = t2.ACCT_NO_DET)&lt;BR /&gt;WHERE t2.PROD_DETAILS LIKE 'ACCESSORY' ;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Method&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;2:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.ASSIGNS AS &lt;BR /&gt;SELECT DISTINCT t1.ACCT_NO, &lt;BR /&gt;t1.ACCT_NO_DET, &lt;BR /&gt;t1.PROD_ONE, &lt;BR /&gt;t1.PROD_TWO, &lt;BR /&gt;t1.START_DATE, &lt;BR /&gt;t1.END_DATE,&lt;BR /&gt;t2.PROD_DETAILS&lt;BR /&gt;&lt;BR /&gt;FROM WORK.CUSTOMER t1&lt;BR /&gt;LEFT JOIN SCHEMA.PRODUCTS t2 ON (t1.ACCT = t2.ACCT_NO) AND (t1.ACCT_NO_DET = t2.ACCT_NO_DET)&lt;BR /&gt;WHERE t2.PROD_DETAILS LIKE 'ACCESSORY' &lt;STRONG&gt;or&amp;nbsp;t2.PROD_DETAILS is&amp;nbsp; missing&lt;/STRONG&gt; ;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 19:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730478#M227461</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-03-31T19:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join missing rows from left table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730479#M227462</link>
      <description>Your WHERE clause is filtering out the records most likely.</description>
      <pubDate>Wed, 31 Mar 2021 19:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730479#M227462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-31T19:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join missing rows from left table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730483#M227464</link>
      <description>&lt;P&gt;I tried AND too instead of where and that bring me 320K records back.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 19:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730483#M227464</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-03-31T19:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join missing rows from left table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730485#M227465</link>
      <description>&lt;P&gt;You must force the where clause to be evaluated before the join. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WORK.ASSIGNS AS
SELECT DISTINCT t1.ACCT_NO,
	t1.ACCT_NO_DET,
	t1.PROD_ONE,
	t1.PROD_TWO,
	t1.START_DATE,
	t1.END_DATE,
	t2.PROD_DETAILS
FROM 
	WORK.CUSTOMER as t1 LEFT JOIN 
	(	select * 
		from  SCHEMA.PRODUCTS
		WHERE PROD_DETAILS LIKE 'ACCESSORY'  ) as t2 
		ON t1.ACCT = t2.ACCT_NO AND t1.ACCT_NO_DET = t2.ACCT_NO_DET;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Mar 2021 20:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730485#M227465</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-03-31T20:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join missing rows from left table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730489#M227466</link>
      <description>&lt;P&gt;Thank you! It worked.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 20:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-missing-rows-from-left-table/m-p/730489#M227466</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-03-31T20:14:23Z</dc:date>
    </item>
  </channel>
</rss>

