<?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 Stop the program from continuing to run in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670160#M201135</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My program is divided so that there is a main program called 000_batch that&amp;nbsp;running all other programs, look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let pgm=C:\Users\freet\Desktop\SAS;&lt;/P&gt;&lt;P&gt;%include &amp;amp;pgm.010_batch;&lt;/P&gt;&lt;P&gt;%include &amp;amp;pgm.020_batch;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to give IF conditions in the program&amp;nbsp;010_batch that if the condition will met the SAS program will be stopped completely and not continue to 020_batch program.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your assistance&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 16:37:03 GMT</pubDate>
    <dc:creator>shlomiohana</dc:creator>
    <dc:date>2020-07-17T16:37:03Z</dc:date>
    <item>
      <title>Stop the program from continuing to run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670160#M201135</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My program is divided so that there is a main program called 000_batch that&amp;nbsp;running all other programs, look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let pgm=C:\Users\freet\Desktop\SAS;&lt;/P&gt;&lt;P&gt;%include &amp;amp;pgm.010_batch;&lt;/P&gt;&lt;P&gt;%include &amp;amp;pgm.020_batch;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to give IF conditions in the program&amp;nbsp;010_batch that if the condition will met the SAS program will be stopped completely and not continue to 020_batch program.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your assistance&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 16:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670160#M201135</guid>
      <dc:creator>shlomiohana</dc:creator>
      <dc:date>2020-07-17T16:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Stop the program from continuing to run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670161#M201136</link>
      <description>&lt;P&gt;It depends a bit on &lt;A href="https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/" target="_self"&gt;your version of SAS but assuming you're 9.4M5+&lt;/A&gt; something like this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if insertCondition %then %do;
    %include .....;
%end;

%else %if insertCondition2 %then %do;
    insert other code;
%end;

%else %do;
       insert other code here;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My program is divided so that there is a main program called 000_batch that&amp;nbsp;running all other programs, look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let pgm=C:\Users\freet\Desktop\SAS;&lt;/P&gt;
&lt;P&gt;%include &amp;amp;pgm.010_batch;&lt;/P&gt;
&lt;P&gt;%include &amp;amp;pgm.020_batch;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to give IF conditions in the program&amp;nbsp;010_batch that if the condition will met the SAS program will be stopped completely and not continue to 020_batch program.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I would appreciate your assistance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 16:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670161#M201136</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-17T16:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Stop the program from continuing to run</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670206#M201150</link>
      <description>&lt;P&gt;Stopping a sas to run depends on what kind of condition is and what exactly you want to stop::&lt;/P&gt;
&lt;P&gt;(1)&amp;nbsp;In case the condition is based on &lt;STRONG&gt;input data&lt;/STRONG&gt; then use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If &amp;lt;condition&amp;gt; then stop run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or if you want to cancel the batch job,or the sas sesssion you can use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if &amp;lt;condition&amp;gt; then abort [abend] &amp;lt;return code&amp;gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better check the full documentation of ABORT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2) In case condition depends on outer arguments (suppose some macro variable or a return code from a sas step, then use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;'s suggestion or code the macro program as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro &amp;lt;macro_name&amp;gt;(...arguments ...);
       %if &amp;lt;condition&amp;gt; %then ...

      %else %if &amp;lt;condition to exit macro &amp;gt;
                      %then %goto exit;

     .......

%exit:
%mend &amp;lt;macro_name&amp;gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-the-program-from-continuing-to-run/m-p/670206#M201150</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-07-17T20:09:56Z</dc:date>
    </item>
  </channel>
</rss>

