<?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: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845244#M334135</link>
    <description>&lt;P&gt;so SAS still run fine despite the error?&lt;/P&gt;</description>
    <pubDate>Sat, 19 Nov 2022 04:20:22 GMT</pubDate>
    <dc:creator>Nietzsche</dc:creator>
    <dc:date>2022-11-19T04:20:22Z</dc:date>
    <item>
      <title>Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845232#M334128</link>
      <description>&lt;P&gt;so SAS is able to run an IF statement without THEN statement and this is called subsetting.&lt;/P&gt;
&lt;P&gt;But if I follow that with an ELSE statement, SAS is still able run correctly as shown by the code below and the result attached.&lt;/P&gt;
&lt;PRE&gt;data merged nomatch;
	merge cert.patdat (in=inpat rename=(date=BirthDate))
			cert.visit (in=invisit rename=(date=VisitDate));
by id;
if inpat=1 and invisit=1;
else output nomatch;
run;

proc print data=merged;run;
proc print data=nomatch;run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nietzsche_0-1668817682185.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77473iE183F154A7ACE35F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nietzsche_0-1668817682185.png" alt="Nietzsche_0-1668817682185.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so why is it that when I look at the log, there is an error&amp;nbsp;No matching IF-THEN clause if everything was ran okay?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nietzsche_1-1668817722728.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77474iF9AA4D92B37646FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nietzsche_1-1668817722728.png" alt="Nietzsche_1-1668817722728.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 00:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845232#M334128</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-19T00:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845233#M334129</link>
      <description>&lt;P&gt;I don't see any THEN in your code.&lt;/P&gt;
&lt;P&gt;So you have an ELSE without any &lt;A href="https://documentation.sas.com/doc/en/lestmtsref/9.4/n1j60arf27ll4nn1ejavv3nby4pa.htm#:~:text=If%20the%20conditions%20that%20are,THEN%20clause%20is%20not%20executed." target="_self"&gt;IF/THEN&lt;/A&gt;. Just like the error message says.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that a &lt;A href="https://documentation.sas.com/doc/en/lestmtsref/3.1/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm#:~:text=The%20subsetting%20IF%20statement%20causes,specified%20in%20the%20IF%20statement." target="_self"&gt;subsetting IF&lt;/A&gt; is a completely different statement than and IF/THEN statement.&amp;nbsp; And there is no way an ELSE statement makes any sense with a subsetting IF.&amp;nbsp; If the condition is false none of the code after that runs. So the ELSE can never happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Click to see corrected code:&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data merged nomatch;
  merge cert.patdat (in=inpat rename=(date=BirthDate))
    cert.visit (in=invisit rename=(date=VisitDate))
  ;
  by id;
  if inpat=1 and invisit=1 then output merged;
  else output nomatch;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 00:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845233#M334129</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-19T00:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845244#M334135</link>
      <description>&lt;P&gt;so SAS still run fine despite the error?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 04:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845244#M334135</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-19T04:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845247#M334137</link>
      <description>&lt;P&gt;The log will tell you if it ran.&lt;/P&gt;
&lt;P&gt;But the logic is wrong so I doubt it did what you wanted if it did run.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 04:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845247#M334137</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-19T04:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845248#M334138</link>
      <description>&lt;P&gt;no worries, I will stick to IF THEN ELSE standard.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 04:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845248#M334138</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-19T04:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845251#M334141</link>
      <description>&lt;P&gt;As the log tells you, no. Syntax errors stop the compilation, so execution never happens.&lt;/P&gt;
&lt;P&gt;If you find the resulting dataset, it's from an earlier execution that worked.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 05:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845251#M334141</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-19T05:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get an error in log for No matching IF-THEN clause but SAS still able to run correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845253#M334143</link>
      <description>&lt;P&gt;omg what a rookie mistake I made.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a way to clear the result every time I ran a new code in the same tab in SAS studio?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2022 06:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-do-I-get-an-error-in-log-for-No-matching-IF-THEN-clause-but/m-p/845253#M334143</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-11-19T06:40:08Z</dc:date>
    </item>
  </channel>
</rss>

