<?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: Usage of  %abort statement with CALL EXECUTE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586314#M167369</link>
    <description>&lt;P&gt;Thanks for replying. The code I posted is an example code, and %return may work for the example code I posted.&lt;/P&gt;&lt;P&gt;My actual program has other macros calls after the macro that could %abort. So using %return would allow the flow of the program to call other macros which in my case is not needed.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2019 06:44:30 GMT</pubDate>
    <dc:creator>Ramesh_165</dc:creator>
    <dc:date>2019-09-05T06:44:30Z</dc:date>
    <item>
      <title>Usage of  %abort statement with CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586273#M167349</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to run a set of macros(some are nested) in loop even when one/all of the occurrence fails/aborted conditionally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I decided to use CALL EXECUTE with %NRSTR option as below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below code the main macro is XYZ1 which calls XYZ2.&amp;nbsp; The XYZ2 macro is conditionally aborted. My need is to continue running the next occurance of XYZ1 even when the XYZ2 fails/aborts. But for some reason, the entire run stops when the code encounters %abort statement in XYZ2. I also tried %abort cancel in place of %abort in XYZ2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running the below program using SASEG.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro XYZ1(mi_stopCount);
	%local i j k;
	%do i = 1 %to 5;
		%put XYZ1 &amp;amp;i;
		%XYZ2(&amp;amp;mi_stopCount.);
		%put -------------;
	%end;
%Mend;
%Macro XYZ2(mi_stopCount);
	%local i j k;
	%do i = 1 %to 5;
		%put XYZ2 &amp;amp;i;
		%if &amp;amp;i = &amp;amp;mi_stopCount. %then %do;
			%put XYZ2 Aborting at &amp;amp;i.;
			%abort;
		%end;
	%end;
%Mend;
%Macro Driver();
	options nomlogic nomprint nosymbolgen nonotes;
	%local i j k;
	data _null_;
		retain s_no;
		set sashelp.class end=eof;
		if _n_ = 1 then s_no = 0;
		s_no = s_no + 1;
		put 'Before calling macro = ' s_no;
		call execute('%nrstr(%xyz1('||strip(4)||'));');
		put 'After calling macro  = ' s_no;
		if s_no = 2 then stop;
	run;
%Mend;
%Driver&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; I was able to do this earlier with the same approach but I'm missing something now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 21:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586273#M167349</guid>
      <dc:creator>Ramesh_165</dc:creator>
      <dc:date>2019-09-04T21:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of  %abort statement with CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586287#M167356</link>
      <description>&lt;P&gt;If my understanding is correct, no matter you declare macro var i as local separately, the i in the inner macro call is local to both inner and outer macro. Therefore it aborts. If you remove the %local in the outer macro, that would still abort.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tested changing the index variable i to t in the outer macro to see if my understanding is correct, and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
dm log 'clear';
%Macro XYZ1(mi_stopCount);
	%local i j k;
	%do t = 1 %to 5;
		%put XYZ1 t=&amp;amp;t;
		%XYZ2(&amp;amp;mi_stopCount.);
		%put -------------;
	%end;
%Mend;
%Macro XYZ2(mi_stopCount);
	%local i j k;
	%do i = 1 %to 5;
		%put XYZ2 i=&amp;amp;i;
		%if &amp;amp;t = &amp;amp;mi_stopCount. %then %do;
			%put XYZ2 Aborting at &amp;amp;i.;
			%abort;
		%end;
	%end;
%Mend;
%Macro Driver();
	options nomlogic nomprint nosymbolgen nonotes;
	%local i j k;
	data _null_;
		retain s_no;
		set sashelp.class end=eof;
		if _n_ = 1 then s_no = 0;
		s_no = s_no + 1;
		put 'Before calling macro = ' s_no;
		call execute('%nrstr(%xyz1('||strip(4)||'));');
		put 'After calling macro  = ' s_no;
		if s_no = 2 then stop;
	run;
%Mend;
%Driver
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Before calling macro = 1
After calling macro  = 1
Before calling macro = 2
After calling macro  = 2
1   +  %xyz1(4);
XYZ1 t=1
XYZ2 i=1
XYZ2 i=2
XYZ2 i=3
XYZ2 i=4
XYZ2 i=5
-------------
XYZ1 t=2
XYZ2 i=1
XYZ2 i=2
XYZ2 i=3
XYZ2 i=4
XYZ2 i=5
-------------
XYZ1 t=3
XYZ2 i=1
XYZ2 i=2
XYZ2 i=3
XYZ2 i=4
XYZ2 i=5
-------------
XYZ1 t=4
XYZ2 i=1
XYZ2 Aborting at 1
ERROR: Execution terminated by an %ABORT statement.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 23:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586287#M167356</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-04T23:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of  %abort statement with CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586293#M167359</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&amp;nbsp;My need is to continue running the next occurance of XYZ1 even when the XYZ2 fails/aborts&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would using&amp;nbsp; %return;&amp;nbsp; instead of&amp;nbsp; %abort;&amp;nbsp; not serve this purpose?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 02:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586293#M167359</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-05T02:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of  %abort statement with CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586312#M167368</link>
      <description>&lt;P&gt;I was able to fix the problem by removing the macro wrapper from the data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below code, I've removed %Macro Driver(); , %Mend; and %Drivers statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro XYZ1(mi_stopCount);
	%local i j k;
	%do i = 1 %to 5;
		%put XYZ1 &amp;amp;i;
		%XYZ2(&amp;amp;mi_stopCount.);
		%put -------------;
	%end;
%Mend;
%Macro XYZ2(mi_stopCount);
	%local i j k;
	%do i = 1 %to 5;
		%put XYZ2 &amp;amp;i;
		%if &amp;amp;i = &amp;amp;mi_stopCount. %then %do;
			%put XYZ2 Aborting at &amp;amp;i.;
			%abort;
		%end;
	%end;
%Mend;

	data _null_;
		retain s_no;
		set sashelp.class end=eof;
		if _n_ = 1 then s_no = 0;
		s_no = s_no + 1;
		put 'Before calling macro = ' s_no;
		call execute('%nrstr(%xyz1('||strip(4)||'));');
		put 'After calling macro  = ' s_no;
		if s_no = 2 then stop;
	run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 06:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586312#M167368</guid>
      <dc:creator>Ramesh_165</dc:creator>
      <dc:date>2019-09-05T06:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of  %abort statement with CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586314#M167369</link>
      <description>&lt;P&gt;Thanks for replying. The code I posted is an example code, and %return may work for the example code I posted.&lt;/P&gt;&lt;P&gt;My actual program has other macros calls after the macro that could %abort. So using %return would allow the flow of the program to call other macros which in my case is not needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 06:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Usage-of-abort-statement-with-CALL-EXECUTE/m-p/586314#M167369</guid>
      <dc:creator>Ramesh_165</dc:creator>
      <dc:date>2019-09-05T06:44:30Z</dc:date>
    </item>
  </channel>
</rss>

