<?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 Error while using SAS if in the main body of the program in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155766#M12155</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want my SAS program to exit if a certain error condition is met.&lt;/P&gt;&lt;P&gt;So in the program outside any proc, data, macro declarations, I write:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (&amp;amp;errCount &amp;gt; 1) then abort;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solve it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 May 2014 19:27:57 GMT</pubDate>
    <dc:creator>eagles_dare13</dc:creator>
    <dc:date>2014-05-12T19:27:57Z</dc:date>
    <item>
      <title>Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155766#M12155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want my SAS program to exit if a certain error condition is met.&lt;/P&gt;&lt;P&gt;So in the program outside any proc, data, macro declarations, I write:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (&amp;amp;errCount &amp;gt; 1) then abort;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solve it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 19:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155766#M12155</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2014-05-12T19:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155767#M12156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ABORT statement is only available in a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (&amp;amp;errCount &amp;gt; 1) then abort;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p0hp2evpgqvfsfn1u223hh9ubv3g.htm"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#p0hp2evpgqvfsfn1u223hh9ubv3g.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively you could use %ABORT but that would need conditional macro logic around it inside a macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check_error;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if&amp;nbsp; (&amp;amp;errCount &amp;gt; 1) %then %abort;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 19:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155767#M12156</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-05-12T19:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155768#M12157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I tried the first option.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (&amp;amp;errCount &amp;gt; 1) then abort;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got this in log:&lt;/P&gt;&lt;P&gt;ERROR: Execution terminated by an ABORT statement at line 34 column 31.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is ok, but then the rest of the program went on executing as if nothing had happened.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 19:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155768#M12157</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2014-05-12T19:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155769#M12158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;By gar, you're right!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABEND has different behaviours in batch and interactive. To get it to stop executing in interactive mode, use ABORT ABEND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 20:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155769#M12158</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2014-05-12T20:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155770#M12159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not a good idea to use ABORT ABEND within EG, as it will close your connection with the SAS Workspace. You'll lose your connection to work data, output, and any remaining log messages.&amp;nbsp; It's a bit like hanging up the phone in the middle of a conversation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perfectly fine to use in a batch job though!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 20:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155770#M12159</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2014-05-12T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155771#M12160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had taken from the "I want my SAS program to exit if a certain error condition is met." that this is exactly what the OP wants. However, it's worth keeping in mind that WORK datasets won't be available for further examination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 00:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155771#M12160</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2014-05-13T00:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155772#M12161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an interesting aside I have a SAS program that contains an ABORT ABEND. When run in EG I dont want it to abort - no good hanging up mid-conversation as Chris says!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when run in batch I do want it to abort. Hence I check the _CLIENTAPP macro variable and if populated assume I'm in EG, if not I am in batch. If anyone knows a better way of checking where the program is running I'd be interested. The old SYSENV option is no longer useful as it has the same value for EG and batch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 01:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155772#M12161</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-05-13T01:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155773#M12162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is structural programming like: &lt;A href="http://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram" title="http://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram"&gt;Nassi–Shneiderman diagram - Wikipedia, the free encyclopedia&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Some rules:&lt;/P&gt;&lt;P&gt;- Avoid "go to's&amp;nbsp; as leading to spaghetti coding.&amp;nbsp; &lt;/P&gt;&lt;P&gt;- Error signalling is allowed but nice clean-ups should be done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do this in SAS? Look what DI is generating a lot of steps just for checking processes and doing error recognition.&lt;BR /&gt;The abort should work but I remember there was a situation SAS failed in a nice clean-up (within macro and SAS/AF) causing a cpu-loop.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is not issue with all this when you do your code in block's and every block does a check on the error-settings before getting executed.&lt;/P&gt;&lt;P&gt;With SAS you only are able to solve this by using macro-s. Thinking in this kind of logical blocks reuse, restart are more easy to implement&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 07:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155773#M12162</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-05-13T07:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155774#M12163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your program is a macro, have you tried with %return? This instrucction stop the current macro. I use this instrucction a lot to control bad usage in macros with a command like that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if condition %then %return;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 10:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155774#M12163</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2014-05-29T10:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error while using SAS if in the main body of the program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155775#M12164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find that I'm always using %sysfunc(getoption(sysin)) if only to add it to the title.&amp;nbsp; It returns the complete path to the program in batch, but returns a dot in any form of interactive use.&amp;nbsp; As long as I am already retrieving it, that's how I distinguish batch use from interactive.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 12:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Error-while-using-SAS-if-in-the-main-body-of-the-program/m-p/155775#M12164</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-05-29T12:59:32Z</dc:date>
    </item>
  </channel>
</rss>

