<?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 SQL: Alternative to using multiple 'AND' statements to find if columns contain same value)? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Alternative-to-using-multiple-AND-statements-to-find-if/m-p/781812#M249178</link>
    <description>&lt;P&gt;I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.&lt;/P&gt;
&lt;P&gt;It would ultimately be used within a CASE WHEN statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
select
PAT_ID,
COL2, COL3, COL4, COL5, COL6, COL7,
CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS
FROM data;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Nov 2021 23:13:19 GMT</pubDate>
    <dc:creator>PharmlyDoc</dc:creator>
    <dc:date>2021-11-22T23:13:19Z</dc:date>
    <item>
      <title>SQL: Alternative to using multiple 'AND' statements to find if columns contain same value)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Alternative-to-using-multiple-AND-statements-to-find-if/m-p/781812#M249178</link>
      <description>&lt;P&gt;I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.&lt;/P&gt;
&lt;P&gt;It would ultimately be used within a CASE WHEN statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
select
PAT_ID,
COL2, COL3, COL4, COL5, COL6, COL7,
CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS
FROM data;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Nov 2021 23:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Alternative-to-using-multiple-AND-statements-to-find-if/m-p/781812#M249178</guid>
      <dc:creator>PharmlyDoc</dc:creator>
      <dc:date>2021-11-22T23:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: SQL: Alternative to using multiple 'AND' statements to find if columns contain same value)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Alternative-to-using-multiple-AND-statements-to-find-if/m-p/781813#M249179</link>
      <description>&lt;P&gt;Mathematical logic alternatives&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Max of the series = Min of the series = 0&lt;/LI&gt;
&lt;LI&gt;Range =0 and any value = 0&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Add values and check if sum is 0&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Use WHICHN to search for 1, if the alternative values are 1. If they're something else this option doesn't work&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The third option is probably the easiest. If you run into floating point errors you may want to use a ROUND to ensure it doesn't happen or FUZZ but the idea is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN sum(col3, col4, col5, col6, col7) = 0THEN 1 ELSE 0 END ZEROS&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366713"&gt;@PharmlyDoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.&lt;/P&gt;
&lt;P&gt;It would ultimately be used within a CASE WHEN statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
select
PAT_ID,
COL2, COL3, COL4, COL5, COL6, COL7,
CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS
FROM data;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 23:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Alternative-to-using-multiple-AND-statements-to-find-if/m-p/781813#M249179</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-22T23:20:59Z</dc:date>
    </item>
  </channel>
</rss>

