<?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: Multiple left joins on null values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469795#M70822</link>
    <description>&lt;P&gt;Kind of tough without seeing the data and being able to play with it. Does it work if you wrap the whole where clause in parentheses with OR? If&amp;nbsp;your left table matches anything from b, c, or d, it is going to keep those rows from table a when you use OR.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;WHERE ((b.accession_num is NULL AND b.lab is NULL AND b.specimen_first_rpt_date is NULL)&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;OR&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;(c.accession_num is NULL AND c.lab is NULL AND c.specimen_first_rpt_date is NULL)&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;OR&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;(d.accession_num is NULL AND d.lab is NULL AND d.specimen_first_rpt_date is NULL))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think this will work if you want to keep the rows from A where you don't find a match in B or C or D.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 23:05:29 GMT</pubDate>
    <dc:creator>bobpep212</dc:creator>
    <dc:date>2018-06-12T23:05:29Z</dc:date>
    <item>
      <title>Multiple left joins on null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469784#M70821</link>
      <description>&lt;P&gt;I've been looking online for what seems like hours. Is anyone able to explain why in the following code AND is used between where clauses rather than OR? I'm trying to say that if the variable is in any of the tables then it should be deleted not if it is in ALL of the tables. However, when I use OR it doesn't appear to delete any of the variables but with AND it does.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;create table spec2 as&lt;BR /&gt;select a.*&lt;BR /&gt;from spec a&lt;BR /&gt;left join qtnhst.Medpro_spec b&lt;BR /&gt;on a.accession_num = b.accession_num AND&lt;BR /&gt;a.lab = b.lab AND&lt;BR /&gt;a.specimen_first_rpt_date = b.specimen_first_rpt_date&lt;BR /&gt;left join qtnhst.DL_spec c&lt;BR /&gt;on a.accession_num = c.accession_num AND&lt;BR /&gt;a.lab = c.lab AND&lt;BR /&gt;a.specimen_first_rpt_date = c.specimen_first_rpt_date&lt;BR /&gt;left join qtnhst.EXCL_spec d&lt;BR /&gt;on a.accession_num = d.accession_num AND&lt;BR /&gt;a.lab = d.lab AND&lt;BR /&gt;a.specimen_first_rpt_date = d.specimen_first_rpt_date&lt;BR /&gt;left join qtnhst.chng_clnt_hst e&lt;BR /&gt;on a.accession_num = e.accession_num AND&lt;BR /&gt;a.lab = e.lab AND&lt;BR /&gt;a.client_num = e.new_client_num&lt;BR /&gt;where (b.accession_num is NULL AND b.lab is NULL AND b.specimen_first_rpt_date is NULL) &lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;AND&lt;/FONT&gt;&lt;BR /&gt;(c.accession_num is NULL AND c.lab is NULL AND c.specimen_first_rpt_date is NULL) &lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;AND&lt;/FONT&gt;&lt;BR /&gt;(d.accession_num is NULL AND d.lab is NULL AND d.specimen_first_rpt_date is NULL)&lt;BR /&gt;order by accession_num, lab, specimen_first_rpt_date, specimen_type, change_date desc ;&lt;BR /&gt;quit ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469784#M70821</guid>
      <dc:creator>ashhazard</dc:creator>
      <dc:date>2018-06-12T22:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple left joins on null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469795#M70822</link>
      <description>&lt;P&gt;Kind of tough without seeing the data and being able to play with it. Does it work if you wrap the whole where clause in parentheses with OR? If&amp;nbsp;your left table matches anything from b, c, or d, it is going to keep those rows from table a when you use OR.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;WHERE ((b.accession_num is NULL AND b.lab is NULL AND b.specimen_first_rpt_date is NULL)&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;OR&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;(c.accession_num is NULL AND c.lab is NULL AND c.specimen_first_rpt_date is NULL)&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="arial black,avant garde" color="#FFFF00"&gt;OR&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;(d.accession_num is NULL AND d.lab is NULL AND d.specimen_first_rpt_date is NULL))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think this will work if you want to keep the rows from A where you don't find a match in B or C or D.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 23:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469795#M70822</guid>
      <dc:creator>bobpep212</dc:creator>
      <dc:date>2018-06-12T23:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple left joins on null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469834#M70831</link>
      <description>&lt;P&gt;"&lt;EM&gt;if the variable is in any of the tables then it should be deleted&lt;/EM&gt;" ==&amp;gt; Keep the row if it is in &lt;STRONG&gt;none&lt;/STRONG&gt; of the tables, i.e. it is not in table b and not in table c and not in table d&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 05:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-left-joins-on-null-values/m-p/469834#M70831</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-13T05:14:27Z</dc:date>
    </item>
  </channel>
</rss>

