<?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 Terminating an automated script based on a condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Terminating-an-automated-script-based-on-a-condition/m-p/851266#M336442</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS script that is scheduled to run everyday. I want to terminate the script if a certain condition is satisfied. For example, if it's Sunday, I want to kill the execution of the script at a certain point, and nothing after should execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let _weekday = %sysfunc(weekday(today()));

data _null_;
    if &amp;amp;_weekday. = 1 then do;
        call execute('endsas;');
    end;
    stop;
run;
&lt;/PRE&gt;
&lt;P&gt;Would this work? Would this affect anything in the next day schedule run or will that run again fine and check the condition again?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you recommend another, more graceful way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2022 19:19:06 GMT</pubDate>
    <dc:creator>KJazem</dc:creator>
    <dc:date>2022-12-27T19:19:06Z</dc:date>
    <item>
      <title>Terminating an automated script based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-an-automated-script-based-on-a-condition/m-p/851266#M336442</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS script that is scheduled to run everyday. I want to terminate the script if a certain condition is satisfied. For example, if it's Sunday, I want to kill the execution of the script at a certain point, and nothing after should execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let _weekday = %sysfunc(weekday(today()));

data _null_;
    if &amp;amp;_weekday. = 1 then do;
        call execute('endsas;');
    end;
    stop;
run;
&lt;/PRE&gt;
&lt;P&gt;Would this work? Would this affect anything in the next day schedule run or will that run again fine and check the condition again?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you recommend another, more graceful way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 19:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-an-automated-script-based-on-a-condition/m-p/851266#M336442</guid>
      <dc:creator>KJazem</dc:creator>
      <dc:date>2022-12-27T19:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating an automated script based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-an-automated-script-based-on-a-condition/m-p/851274#M336446</link>
      <description>&lt;P&gt;Instead of using CALL EXECUTE to push ENDSAS into the execution queue, you can use the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0hp2evpgqvfsfn1u223hh9ubv3g.htm" target="_blank" rel="noopener"&gt;ABORT&lt;/A&gt;&amp;nbsp;data step statement. It also allows setting the return code of the SAS program.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 21:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-an-automated-script-based-on-a-condition/m-p/851274#M336446</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-27T21:02:33Z</dc:date>
    </item>
  </channel>
</rss>

