<?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: MPRINT not being changed -- CALL EXECUTE macro invocation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/757771#M239224</link>
    <description>&lt;P&gt;It is just another symptom of timing issue when submitting macro calls via CALL EXECUTE().&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You used single quotes to prevent the macro from running while the data step is compiled.&amp;nbsp; But becuase you did not wrap the macro call in %NRSTR() the macro actually ran while the data step was executing and the resulting code was pushed onto the stack to run.&lt;/P&gt;
&lt;P&gt;You left out the key part of the SAS log that shows that:&lt;/P&gt;
&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1    + options nomprint;
1    +                        data _null_;     * not quite inception level oddness;     set sashelp.cars(obs=1);     if make = 'x'
then       put 'really?';   run;

NOTE: There were 1 observations read from the data set SASHELP.CARS.
&lt;/PRE&gt;
&lt;P&gt;So just fix your CALL EXECUTE() string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute ('%nrstr(%foo);');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And now the lines of generated code that CALL EXECUTE() shows are also clearer, showing the macro call you actually passed, not the code that the macro you called generated.&lt;/P&gt;
&lt;PRE&gt;MPRINT(DOIT):   %foo;
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1    + %foo;
MPRINT(FOO):   options nomprint;

NOTE: There were 1 observations read from the data set SASHELP.CARS.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 16:10:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-28T16:10:43Z</dc:date>
    <item>
      <title>MPRINT not being changed -- CALL EXECUTE macro invocation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/757766#M239219</link>
      <description>&lt;P&gt;In this sample program, the deepest invoked macro has an options statement to turn off mprinting.&amp;nbsp; However, the macro is invoked via CALL EXECUTE, and not sure why the MPRINT continues anyway.&amp;nbsp; Why would that be ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro foo;
  options nomprint;  /* mprint continues anyway ? */

  data _null_;
    * not quite inception level oddness;
    set sashelp.cars(obs=1);
    if make = 'x' then 
      put 'really?';
  run;

  options mprint;
%mend;

%macro doit;
  data _null_;
    call execute ('%foo;');
  run;
%mend;

options mprint;
%doit;
options nomprint;&lt;/PRE&gt;
&lt;P&gt;Will log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MPRINT(DOIT):   data _null_;
MPRINT(DOIT):   call execute ('%foo;');
MPRINT(DOIT):   run;

MPRINT(FOO):   options nomprint;
MPRINT(FOO):   data _null_;
MPRINT(FOO):   * not quite inception level oddness;
MPRINT(FOO):   set sashelp.cars(obs=1);
MPRINT(FOO):   if make = 'x' then put 'really?';
MPRINT(FOO):   run;
MPRINT(FOO):   options mprint;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 15:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/757766#M239219</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2021-07-28T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: MPRINT not being changed -- CALL EXECUTE macro invocation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/757771#M239224</link>
      <description>&lt;P&gt;It is just another symptom of timing issue when submitting macro calls via CALL EXECUTE().&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You used single quotes to prevent the macro from running while the data step is compiled.&amp;nbsp; But becuase you did not wrap the macro call in %NRSTR() the macro actually ran while the data step was executing and the resulting code was pushed onto the stack to run.&lt;/P&gt;
&lt;P&gt;You left out the key part of the SAS log that shows that:&lt;/P&gt;
&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1    + options nomprint;
1    +                        data _null_;     * not quite inception level oddness;     set sashelp.cars(obs=1);     if make = 'x'
then       put 'really?';   run;

NOTE: There were 1 observations read from the data set SASHELP.CARS.
&lt;/PRE&gt;
&lt;P&gt;So just fix your CALL EXECUTE() string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute ('%nrstr(%foo);');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And now the lines of generated code that CALL EXECUTE() shows are also clearer, showing the macro call you actually passed, not the code that the macro you called generated.&lt;/P&gt;
&lt;PRE&gt;MPRINT(DOIT):   %foo;
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1    + %foo;
MPRINT(FOO):   options nomprint;

NOTE: There were 1 observations read from the data set SASHELP.CARS.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 16:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/757771#M239224</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T16:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: MPRINT not being changed -- CALL EXECUTE macro invocation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/759308#M239937</link>
      <description>&lt;P&gt;To add to the confusion, any symbol (macro variable) resolutions in macro calls invoked via the EXECUTE are resolved during the DATA Step run-time, not during the normally presumed stacked code submission time.&amp;nbsp; This can cause EXCUTE invoked macro calls to behave unintuitive ways.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%NRSTR can be used to stack macro invocation for submission after the step completes.&amp;nbsp; That is why you might see&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  call execute ('%nrstr(%myMacro(arg=' || data-step-var || '))' );&lt;/PRE&gt;
&lt;P&gt;Such a call forces macro logic and evaluations within the macro and step code it generates to occur linearly at macro invocation time.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 12:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MPRINT-not-being-changed-CALL-EXECUTE-macro-invocation/m-p/759308#M239937</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2021-08-04T12:48:00Z</dc:date>
    </item>
  </channel>
</rss>

