<?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: If statement issue? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425684#M281121</link>
    <description>&lt;P&gt;Very likely indeed. Combining negations&amp;nbsp;and OR doesn't build immediately-obvious Boolean clauses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if ^A | ^B&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is the same (but less legible imho) as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if ^(A &amp;amp; B)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this really what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you may (or not) want to use the &lt;FONT face="courier new,courier"&gt;\b&amp;nbsp;&lt;/FONT&gt;expression in your &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; clause to look for word boundaries.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2018 04:38:02 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-01-08T04:38:02Z</dc:date>
    <item>
      <title>If statement issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425223#M281117</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the codes list below.&amp;nbsp; I found the codes works fine when I only use either of&amp;nbsp;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;classkeeplist&lt;/FONT&gt; or &lt;FONT face="Courier New" size="2"&gt;&amp;amp;componentkeeplist&lt;/FONT&gt;.&amp;nbsp; However when I combine these two together and use them in "if statement",&amp;nbsp; it doesn't work.&amp;nbsp;&amp;nbsp; I could see the proc sql generated the two sets of macro list in log.&amp;nbsp; &amp;nbsp; But I don't understand why it didn't work when I use them in data step.&amp;nbsp; Please help, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; strip(Class) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; : classkeeplist separated &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'","'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Class &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ('&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;ANTI-INFECTIVES/MISC ANTIBACT'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ANTIBACTERIALS/MISC B-LACTAM'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; strip(Component) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; : componentkeeplist separated &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'","'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Component &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'NOS- INFLUENZA VACCINE UNKNOWN'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'NOS- NICOTINE PATCH UNKNOWN'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;classkeeplist;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;componentkeeplist;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; nosmisc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;test (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=(max(&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'/NOS | NOS|-NOS|NOS-|MISC/i'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,Class),&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'/NOS | NOS|-NOS|NOS-|MISC/i'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,Component),&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'/NOS | NOS|-NOS|NOS-|MISC/i'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,Product) ) gt &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Class not in (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;classkeeplist"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) or &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; Component not in (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;componentkeeplist"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 13:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425223#M281117</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-01-05T13:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: If statement issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425225#M281118</link>
      <description>&lt;P&gt;"Doesn't work" tells us exactly NOTHING. Please supply information like the log when an ERROR/WARNING happens, or where the resulting dataset differs from your expectations.&lt;/P&gt;
&lt;P&gt;For testing, supply example data in a data step.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 14:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425225#M281118</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-05T14:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: If statement issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425227#M281119</link>
      <description>&lt;P&gt;Why do it this way in the first place?&lt;/P&gt;
&lt;PRE&gt;data nomisc;
  set want (where=(class not in ('ANTI-INFECTIVES/MISC ANTIBACT','ANTIBACTERIALS/MISC B-LACTAM')
                    or component not in ('NOS-INFLUENZA...','NOS-...'));
  if max(prxmatch...,prxmatch...) gt 0;
run;&lt;/PRE&gt;
&lt;P&gt;There isn't any need as far as I can tell to take all the sub components into a macro list and then use that, as the first sql will return a list of only&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;ANTI-INFECTIVES/MISC ANTIBACT'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'ANTIBACTERIALS/MISC B-LACTAM'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;And the second the same on component.&amp;nbsp; Your not actually doing anything ther that isn't a simple where clause??&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 14:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425227#M281119</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-05T14:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: If statement issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425245#M281120</link>
      <description>&lt;P&gt;Very likely:&amp;nbsp; the logic of the final IF statement is wrong.&amp;nbsp; It should use AND instead of OR.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 14:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425245#M281120</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-05T14:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: If statement issue?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425684#M281121</link>
      <description>&lt;P&gt;Very likely indeed. Combining negations&amp;nbsp;and OR doesn't build immediately-obvious Boolean clauses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if ^A | ^B&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is the same (but less legible imho) as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if ^(A &amp;amp; B)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this really what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you may (or not) want to use the &lt;FONT face="courier new,courier"&gt;\b&amp;nbsp;&lt;/FONT&gt;expression in your &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; clause to look for word boundaries.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 04:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-issue/m-p/425684#M281121</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-01-08T04:38:02Z</dc:date>
    </item>
  </channel>
</rss>

