<?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: Keeping all rows that don't meet Where condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744375#M233207</link>
    <description>&lt;P&gt;Including a field from the "right" table in the WHERE criteria converts your left join into an inner join.&lt;/P&gt;
&lt;P&gt;Is that what you want?&amp;nbsp; Only the records that are in both tables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 May 2021 12:40:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-28T12:40:09Z</dc:date>
    <item>
      <title>Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744302#M233177</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Is there a way to keep all of the rows of an input file, even if they don't meet the Where condition?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Input File:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;789&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer ID&lt;/TD&gt;&lt;TD&gt;Assigned Team Member&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;Jane Doe&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;789&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have so far, but of course it is only returning the row that meets the Where clause.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT DISTINCT
t1.CustomerID
t2.AssignedTeamMember
FROM WORK.Input t1
LEFT JOIN Team.Names t2 ON (t1.Customer_ID = t2.CustomerID)
WHERE t2.AssignedTeamMember&amp;nbsp;NOT IS MISSING&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 May 2021 21:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744302#M233177</guid>
      <dc:creator>HSM_88</dc:creator>
      <dc:date>2021-05-27T21:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744303#M233178</link>
      <description>&lt;P&gt;Why did you include the WHERE clause at all?&lt;/P&gt;
&lt;P&gt;The LEFT JOIN part will include the observations from the "left" dataset even when there is no matching observation from the "right" dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 21:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744303#M233178</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-27T21:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744306#M233180</link>
      <description>No. The left join will ensure that all records from the left table are included. Perhaps you need a COALSECE() instead? Depends on exactly what you're trying to work around.</description>
      <pubDate>Thu, 27 May 2021 21:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744306#M233180</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-27T21:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744370#M233204</link>
      <description>&lt;P&gt;I see what you're saying. I realize now that I forgot to add the other criteria is that status of the case has to be "open", otherwise the query will pull the customer's entire history of past assignments. I only need the names of the assigned team members if the case status is open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT DISTINCT 
t1.CustomerID 
t2.AssignedTeamMember 
FROM WORK.Input t1 
LEFT JOIN Team.Names t2 ON (t1.Customer_ID = t2.CustomerID) 
WHERE t2.CaseStatus = 'open'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 May 2021 12:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744370#M233204</guid>
      <dc:creator>HSM_88</dc:creator>
      <dc:date>2021-05-28T12:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744371#M233205</link>
      <description>&lt;P&gt;I'm trying to work around pulling in the customer's entire history of past assignments. The database includes the closed cases and I only need the open cases. I forgot to include that part in the original post. Below is the updated query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT DISTINCT 
t1.CustomerID 
t2.AssignedTeamMember 
FROM WORK.Input t1 
LEFT JOIN Team.Names t2 ON (t1.Customer_ID = t2.CustomerID) 
WHERE t2.CaseStatus = 'open'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 May 2021 12:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744371#M233205</guid>
      <dc:creator>HSM_88</dc:creator>
      <dc:date>2021-05-28T12:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744375#M233207</link>
      <description>&lt;P&gt;Including a field from the "right" table in the WHERE criteria converts your left join into an inner join.&lt;/P&gt;
&lt;P&gt;Is that what you want?&amp;nbsp; Only the records that are in both tables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 12:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744375#M233207</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-28T12:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744377#M233208</link>
      <description>I'd like the keep all of the rows from the input file and pull the data from the 2nd table if it meets the where criteria. So all 5000+ rows of the input file show and if there is an open case with an assigned team member, it'll have that person's name. If not, it will just be blank. Sorry if I'm not explaining it well. I'm very new to SAS</description>
      <pubDate>Fri, 28 May 2021 12:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744377#M233208</guid>
      <dc:creator>HSM_88</dc:creator>
      <dc:date>2021-05-28T12:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744379#M233209</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/383589"&gt;@HSM_88&lt;/a&gt;&amp;nbsp;your code should work with a small correction. You are missing a comma after&amp;nbsp;t1.CustomerID.&lt;BR /&gt;Second the&amp;nbsp; where clause removes all rows where the case status is not open from the output..&lt;/P&gt;
&lt;P&gt;So if you want to have all customer ID's from the Input table, then the where clause needs to be dropped.&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 12:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744379#M233209</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-28T12:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744381#M233211</link>
      <description>&lt;P&gt;Then move the additional criteria into the ON clause instead of adding a WHERE clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT DISTINCT 
  t1.CustomerID 
, t2.AssignedTeamMember 
FROM WORK.Input t1 
LEFT JOIN Team.Names t2
 ON (t1.Customer_ID = t2.CustomerID) 
  and (t2.CaseStatus = 'open')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will get all of the CUSTOMERID values from INPUT matched with zero or more ASSIGNEDTEAMMEMBER values from TEAM.NAMES.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 13:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744381#M233211</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-28T13:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping all rows that don't meet Where condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744383#M233212</link>
      <description>This worked! Thank you very much. Exactly what I needed.</description>
      <pubDate>Fri, 28 May 2021 13:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-all-rows-that-don-t-meet-Where-condition/m-p/744383#M233212</guid>
      <dc:creator>HSM_88</dc:creator>
      <dc:date>2021-05-28T13:01:41Z</dc:date>
    </item>
  </channel>
</rss>

