Hello Leonid, Thanks for your response! The reason I'm using %abort instead of %return statement is because I don't want the subsequent macro calls within the Main_Macro to execute once the QuitOnError macro is called. Please see the below example where the Main_Macro has n-number of macros, and once the QuitOnError macro is executed from any of the macros, no subsequent statements or macros should execute. In this case I have coded, both %return and %abort statement conditionally to show the execution difference. OPTIONS NOMPRINT NOMLOGIC NOSYMBOLGEN NONOTES; %Macro QuitOnError(abortOrReturn); %put &abortOrReturn. in QuitOnError macro; %if &abortOrReturn = abort %then %abort; %else %if &abortOrReturn = return %then %return; %Mend; %Macro macro_n(iteration); %put &iteration. - Macron successful; PROC SQL; SELECT * FROM SASHELP.CLASS; QUIT; %put &iteration. - Class Table count = &sqlobs.; %Mend; %Macro Macro_4(iteration); %put &iteration. - Macro4 successful; PROC SQL; SELECT * FROM SASHELP.CLASS; QUIT; %put &iteration. - Class Table count = &sqlobs.; %Mend; %Macro Macro_3(iteration); %put &iteration. - Macro3 Errored; %put &iteration. - calling QuitOnError from Macro3; %if &iteration = 2 %then %QuitOnError(abort); %else %QuitOnError(return); PROC SQL; SELECT * FROM SASHELP.CLASS; QUIT; %put &iteration. - Class Table count = &sqlobs.; %Mend; %Macro Macro_2(iteration); %put &iteration. - Macro2 started; PROC SQL; SELECT * FROM SASHELP.CLASS; QUIT; %put &iteration. - Class Table count = &sqlobs.; %Mend; %Macro Macro_1(iteration); %put &iteration. - Macro1 successful; PROC SQL; SELECT * FROM SASHELP.CLASS; QUIT; %put &iteration. - Class Table count = &sqlobs.; %Mend; %Macro Main_Macro(iteration); %Macro_1(&iteration); %Macro_2(&iteration); %Macro_3(&iteration); %Macro_4(&iteration); %Macro_n(&iteration); %Mend; DATA _NULL_; DO i = 1 TO 3; CALL EXECUTE('%NRSTR(%Main_Macro('||STRIP(i)||'))'); END; RUN; Put statement Log outputs of the above code: 1 + %Main_Macro(1) 1 - Macro1 successful 1 - Class Table count = 19 1 - Macro2 started 1 - Class Table count = 19 1 - Macro3 Errored 1 - calling QuitOnError from Macro3 return in QuitOnError macro 1 - Class Table count = 19 1 - Macro4 successful 1 - Class Table count = 19 1 - Macron successful 1 - Class Table count = 19 --------------------------------------------------------------- 2 + %Main_Macro(2) 2 - Macro1 successful 2 - Class Table count = 19 2 - Macro2 started 2 - Class Table count = 19 2 - Macro3 Errored 2 - calling QuitOnError from Macro3 abort in QuitOnError macro ERROR: Execution terminated by an %ABORT statement. ---------------------------------------------------------------- 3 + %Main_Macro(3) 3 - Macro1 successful 3 - Class Table count = 19 3 - Macro2 started 3 - Class Table count = 19 3 - Macro3 Errored 3 - calling QuitOnError from Macro3 return in QuitOnError macro 3 - Class Table count = 19 3 - Macro4 successful 3 - Class Table count = 19 3 - Macron successful 3 - Class Table count = 19 ----------------------------------------------------------- Based on the log, I'm expecting the 2nd iteration behavior in my process, so I'm using %abort statement and not %return statement. Though the 2nd iteration is aborted, it is running the 3rd iteration in interactive mode. But in the batch mode, the process works fine until 2nd iteration. 3rd iteration starts fine, but all the observations are 0. I think it is because the OBS option is set 0 when %abort statement is executed in batch mode. Below is log of the same code from batch mode: 1 + %Main_Macro(1) 1 - Macro1 successful 1 - Class Table count = 19 1 - Macro2 started 1 - Class Table count = 19 1 - Macro3 Errored 1 - calling QuitOnError from Macro3 return in QuitOnError macro 1 - Class Table count = 19 1 - Macro4 successful 1 - Class Table count = 19 1 - Macron successful 1 - Class Table count = 19 ----------------------------------------------------------- 2 + %Main_Macro(2) 2 - Macro1 successful 2 - Class Table count = 19 2 - Macro2 started 2 - Class Table count = 19 2 - Macro3 Errored 2 - calling QuitOnError from Macro3 abort in QuitOnError macro ERROR: Execution terminated by an %ABORT statement. ----------------------------------------------------------- 3 + %Main_Macro(3) 3 - Macro1 successful 3 - Class Table count = 0 3 - Macro2 started 3 - Class Table count = 0 3 - Macro3 Errored 3 - calling QuitOnError from Macro3 return in QuitOnError macro 3 - Class Table count = 0 3 - Macro4 successful 3 - Class Table count = 0 3 - Macron successful 3 - Class Table count = 0 ----------------------------------------------------------- Please note that the Main_Macro was written some back this way to use %abort statement. Now I’m just trying to run it in loop without not making much changes to code. There might be some elegant ways to check for errors at the start of each macro and go to the end if there were any errors. Now I’m trying to see if there is a possibility at all to achieve the need without making the big change as there close to couple hundred macros within the Main_Macro. Thanks again for reading this detailed note, and taking sometime to think about solution. Ramesh
... View more