<?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: abort conditionally a sas program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782561#M249474</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%goto exit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;, you end the SAS code, no?&lt;BR /&gt;If you do not do anything after the macro call, your code stops running (as there's nothing left to run).&lt;/P&gt;
&lt;P&gt;No need for "endsas;" statement / command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Fri, 26 Nov 2021 16:17:14 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2021-11-26T16:17:14Z</dc:date>
    <item>
      <title>abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782439#M249429</link>
      <description>&lt;P&gt;I'm struggling to understand how to use correctly the abort statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The context is the following: I have a job and prompt combo which I run from SAS Studio. It works fine except the fact that the sas program starts executing again when you go to the sas code tab again, the preview sheet.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to avoid this by using a abort statement based on the existence of the macro variables that come from the user prompts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code I'd like to delete this macro variables and put the abort condition at the start of the sas code. I don't attach the real code but the code where I try to approach this funcionality.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to achieve is that the code stops restarting if the macro variables (fed by the prompt) do not exist. To guarantee this I want to delete them at the end of the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="the prompt form" style="width: 968px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66094i23FA6256B709B0D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="ok.png" alt="the prompt form" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;the prompt form&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="the resulting window after submit" style="width: 647px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66095i384DBE75C205437D/image-size/large?v=v2&amp;amp;px=999" role="button" title="ok1.png" alt="the resulting window after submit" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;the resulting window after submit&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="restart of the code execution (without calliing the form?) when coming back to the window" style="width: 634px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66096i546251624CD9C4F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="ok2.png" alt="restart of the code execution (without calliing the form?) when coming back to the window" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;restart of the code execution (without calliing the form?) when coming back to the window&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test=arne;
%let test2=nadine;

%put &amp;amp;test &amp;amp;test2;


%SYMDEL test;

%put &amp;amp;test &amp;amp;test2;

data _null_;
if %symexist(test2) then alarm="exists";
put alarm=;
run;

%macro test;
data _null_;
if %symexist(test) then %abort cancel;
put alarm=;
run;

proc freq data=sashelp.cars;
table make;
run;

%mend;

%test;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 13:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782439#M249429</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-11-25T13:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782444#M249431</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any chance you can use the below example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scroll down on this page :&lt;BR /&gt;SAS 9.4 / Viya 3.5&lt;BR /&gt;Macro Language Reference&lt;BR /&gt;%GOTO Macro Statement&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0jfeh75p72icen1ddd9una5zbmm.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0jfeh75p72icen1ddd9una5zbmm.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;to :&lt;/P&gt;
&lt;P&gt;Example: Providing Exits in a Large Macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 13:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782444#M249431</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-25T13:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782484#M249452</link>
      <description>&lt;P&gt;Please have a look at these refernces&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p074-26.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p074-26.pdf&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://proc-x.com/2021/03/how-to-conditionally-stop-sas-code-execution-and-gracefully-terminate-sas-session/" target="_blank"&gt;http://proc-x.com/2021/03/how-to-conditionally-stop-sas-code-execution-and-gracefully-terminate-sas-session/&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 21:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782484#M249452</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-11-25T21:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782529#M249465</link>
      <description>&lt;P&gt;Hi Koen,&lt;/P&gt;
&lt;P&gt;the %goto statement works in my example, now I have the challenge to wrap all the code into a macro block to be able to use it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test=arne;
%let test2=nadine;

%put &amp;amp;test &amp;amp;test2;


%SYMDEL test;

%put &amp;amp;test &amp;amp;test2;

data _null_;
if %symexist(test2) then alarm="exists";
put alarm=;
run;

%macro help;
data _null_;
%if  %symexist(test) %then %goto exit;
put alarm=;
run;

proc freq data=sashelp.cars;
table make;
run;

%exit: %mend;

%help;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Nov 2021 11:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782529#M249465</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-11-26T11:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782530#M249466</link>
      <description>&lt;P&gt;OK. Nice!&lt;/P&gt;
&lt;P&gt;Let the communities know if you encounter any obstacles in wrapping everything in a macro.&lt;BR /&gt;Maybe some of us are able to help you out in that case.&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 11:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782530#M249466</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-26T11:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782532#M249468</link>
      <description>&lt;P&gt;Thank you, I'm getting closer, but the endsas is a too restrictive option for me. It ends the session.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking for the option that ends the sas code when entering the call execute.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test=arne;
%let test2=nadine;

%put &amp;amp;test &amp;amp;test2;


%SYMDEL test;

%put &amp;amp;test &amp;amp;test2;

data _null_;
   if 1=1 then call execute('endsas;');
   stop;
run;

data _null_;
if %symexist(test2) then alarm="exists";
put alarm=;
run;

%macro help;
data _null_;
%if not %symexist(test) %then %goto exit;
put alarm=;
run;

proc freq data=sashelp.cars;
table make;
run;

%exit: %mend;

%help;

proc freq data=sashelp.cars;
table make;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Nov 2021 12:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782532#M249468</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-11-26T12:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782561#M249474</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%goto exit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;, you end the SAS code, no?&lt;BR /&gt;If you do not do anything after the macro call, your code stops running (as there's nothing left to run).&lt;/P&gt;
&lt;P&gt;No need for "endsas;" statement / command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 16:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782561#M249474</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-26T16:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782607#M249507</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;The proc freq still runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This has been a request ever since I started using SAS, which is well into the last century. See &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Create-new-statement-STOPROGRAMRIGHTHERE-or-similar/idi-p/332062" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/Create-new-statement-STOPROGRAMRIGHTHERE-or-similar/idi-p/332062&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 22:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782607#M249507</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-26T22:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782895#M249584</link>
      <description>&lt;P&gt;Within the SASjs framework we constantly have a need for conditional aborts.&amp;nbsp; So, we wrote a macro for it:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mp__abort_8sas.html" target="_blank"&gt;https://core.sasjs.io/mp__abort_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example usage:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %mp_abort(iftrue=(&amp;amp;somecondition=1)
    ,mac=&amp;amp;sysmacroname
    ,msg=%str(Some Condition Failed)
  )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 12:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/782895#M249584</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-11-29T12:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783077#M249649</link>
      <description>&lt;P&gt;This still kills the SAS session right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very nice macro library, congrats! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 07:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783077#M249649</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-30T07:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783087#M249654</link>
      <description>&lt;P&gt;It kills the session in all cases except for Stored Process sessions - as we found that this could leave orphan multibridge sessions and kill the server for some SAS 9 environments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, we take a unique approach - we open a macro but don't close it!&amp;nbsp; This means the rest of the code does not get executed (and the STP session ends "normally")&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      filename skip temp;
      data _null_;
        file skip;
        put '%macro skip();';
        comment '%mend skip; -&amp;gt; fix lint ';
        put '%macro skippy();';
        comment '%mend skippy; -&amp;gt; fix lint ';
      run;
      %inc skip;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Nov 2021 09:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783087#M249654</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-11-30T09:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: abort conditionally a sas program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783094#M249658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;..., we take a unique approach - we open a macro but don't close it!&amp;nbsp; This means the rest of the code does not get executed (and the STP session ends "normally")&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Interesting. I have never used that "trick". Something to remember.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 09:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/abort-conditionally-a-sas-program/m-p/783094#M249658</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-30T09:59:43Z</dc:date>
    </item>
  </channel>
</rss>

