<?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 &amp;quot;AND&amp;quot; in an &amp;quot;IF&amp;quot; statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820818#M324022</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428614"&gt;@Sas97&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using &lt;SPAN&gt;the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0xgxvo2we2mqrn1kteecpv1opx0" target="_blank" rel="noopener nofollow noreferrer"&gt;IN operator&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;and the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0wism8jqta3qmn1swtpxrs71e9a.htm" target="_blank" rel="noopener"&gt;CAT function&lt;/A&gt;&amp;nbsp;(applied to a&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p08ywlo51p6ezbn1lde9f0aphq6r.htm" target="_blank" rel="nofollow noopener noreferrer"&gt;name range list&lt;/A&gt;) you can possibly avoid&amp;nbsp;multiple "AND" and "OR" in your particular IF condition:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '5.1b'n in (0 1) &amp;amp; cat(of '5.2a'n--'5.9a'n) = '00000000' then variable = result;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This assumes that&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;You want the condition to be evaluated the way Paige Miller has suggested.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'5.2a'n&lt;/FONT&gt;&amp;nbsp;is the first and &lt;FONT face="courier new,courier"&gt;'5.9a'n&lt;/FONT&gt;&amp;nbsp;is the last of eight consecutive variables including also&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'5.3a'n&lt;/FONT&gt;, ..., &lt;FONT face="courier new,courier"&gt;'5.8a'n&lt;/FONT&gt;&amp;nbsp;in the &lt;A href="https://documentation.sas.com/doc/en/basegl/9.4/glossary.htm#p1ttgjpqfxtipan1r95c5nyvcidx" target="_blank" rel="noopener"&gt;program data vector&lt;/A&gt; of your DATA step.Typically, these eight variables would occur in this order in &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hqa4dk5tay0an15nrys1iwr5o2.htm" target="_blank" rel="noopener"&gt;PROC CONTENTS&lt;/A&gt; output (using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1v2467vdjbp7xn1222c7t3sejz3.htm#p0vwh5ho9ufb0pn1k2gj0ol938t0" target="_blank" rel="noopener"&gt;VARNUM option&lt;/A&gt;) of a dataset that is processed in the DATA step.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Tue, 28 Jun 2022 21:41:13 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-06-28T21:41:13Z</dc:date>
    <item>
      <title>Multiple "AND" in an "IF" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820694#M323966</link>
      <description>&lt;P&gt;How to include multiple "AND" and "OR" in an IF statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;P&gt;'5.1b'n = 0 or '5.1b'n = 1&lt;/P&gt;&lt;P&gt;and '5.2a'n = 0 and '5.3a'n = 0 and '5.4a'n = 0 and&lt;BR /&gt;'5.5a'n = 0 and '5.6a'n = 0 and '5.7a'n = 0 and '5.8a'n = 0 and '5.9a'n = 0&lt;/P&gt;&lt;P&gt;then&lt;/P&gt;&lt;P&gt;variable = result&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 14:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820694#M323966</guid>
      <dc:creator>Sas97</dc:creator>
      <dc:date>2022-06-28T14:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple "AND" in an "IF" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820697#M323969</link>
      <description>&lt;P&gt;What is wrong with the code you show (other than it is missing a semi-colon)?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Do you want something like this, where there are parentheses added so that the OR conditions are executed together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if

('5.1b'n = 0 or '5.1b'n = 1)

and '5.2a'n = 0 and '5.3a'n = 0 and '5.4a'n = 0 and
'5.5a'n = 0 and '5.6a'n = 0 and '5.7a'n = 0 and '5.8a'n = 0 and '5.9a'n = 0

then

variable = result;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 14:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820697#M323969</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T14:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple "AND" in an "IF" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820746#M324000</link>
      <description>&lt;P&gt;AND is evaluated before OR, so your condition is equivalent to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if
  '5.1b'n = 0 or (
    '5.1b'n = 1 and '5.2a'n = 0 and '5.3a'n = 0 and '5.4a'n = 0 and
    '5.5a'n = 0 and '5.6a'n = 0 and '5.7a'n = 0 and '5.8a'n = 0 and '5.9a'n = 0
  )
then variable = result;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why do you make your life difficult by having non-standard names which force you to use name literals?&lt;/P&gt;
&lt;P&gt;Use underlines instead of the dots.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 17:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820746#M324000</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-28T17:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple "AND" in an "IF" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820818#M324022</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428614"&gt;@Sas97&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using &lt;SPAN&gt;the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0xgxvo2we2mqrn1kteecpv1opx0" target="_blank" rel="noopener nofollow noreferrer"&gt;IN operator&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;and the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0wism8jqta3qmn1swtpxrs71e9a.htm" target="_blank" rel="noopener"&gt;CAT function&lt;/A&gt;&amp;nbsp;(applied to a&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p08ywlo51p6ezbn1lde9f0aphq6r.htm" target="_blank" rel="nofollow noopener noreferrer"&gt;name range list&lt;/A&gt;) you can possibly avoid&amp;nbsp;multiple "AND" and "OR" in your particular IF condition:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '5.1b'n in (0 1) &amp;amp; cat(of '5.2a'n--'5.9a'n) = '00000000' then variable = result;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This assumes that&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;You want the condition to be evaluated the way Paige Miller has suggested.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'5.2a'n&lt;/FONT&gt;&amp;nbsp;is the first and &lt;FONT face="courier new,courier"&gt;'5.9a'n&lt;/FONT&gt;&amp;nbsp;is the last of eight consecutive variables including also&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'5.3a'n&lt;/FONT&gt;, ..., &lt;FONT face="courier new,courier"&gt;'5.8a'n&lt;/FONT&gt;&amp;nbsp;in the &lt;A href="https://documentation.sas.com/doc/en/basegl/9.4/glossary.htm#p1ttgjpqfxtipan1r95c5nyvcidx" target="_blank" rel="noopener"&gt;program data vector&lt;/A&gt; of your DATA step.Typically, these eight variables would occur in this order in &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hqa4dk5tay0an15nrys1iwr5o2.htm" target="_blank" rel="noopener"&gt;PROC CONTENTS&lt;/A&gt; output (using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1v2467vdjbp7xn1222c7t3sejz3.htm#p0vwh5ho9ufb0pn1k2gj0ol938t0" target="_blank" rel="noopener"&gt;VARNUM option&lt;/A&gt;) of a dataset that is processed in the DATA step.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 28 Jun 2022 21:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-quot-AND-quot-in-an-quot-IF-quot-statement/m-p/820818#M324022</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-06-28T21:41:13Z</dc:date>
    </item>
  </channel>
</rss>

