BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Afshin
Calcite | Level 5

I am using CALL EXECUTE to run a macro in a DATA STEP. 

NOMPRINT is not working when the macro run. When I run the macro without the CALL EXECUTE, the NOMPRINT works.

 

 

%macro HFEQ;


	options nomprint ;

	data make;  set &dayt; 

		%do i=1 %to 10000; 
			mm=&i; output; 
		%end;
	run;


%mend HFEQ;


data _null_; set  dates;

call symput( 'dayt', date); 

call execute('%HFEQ');

/*%HFEQ*/
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

 

Since your CALL EXECUTE is generating a call to a macro it will help if you wrap the macro name inside %NRSTR() so that the actual macro call is pushed onto the stack to run after the data step, instead of the text that the macro generates. At least then the CALL EXECUTE will only generate one line into the log.

call execute('%nrstr(%HFEQ);');

 

The NOMPRINT option suppresses the lines of code generate by the MACRO code. But if you run the macro while pushing the code onto the stack to run after the data step it looks to SAS like the code it generates is the lines that you pushed with CALL EXECUTE() so they are echoed with plus sign in front of them.

 

To suppress all of the lines generated by CALL EXECUTE() use NOSOURCE.  I am actually surprised that you cannot suppress it with NOSOURCE2.  Another reason why I normally prefer to write generated code to a file and then %INCLUDE the file. Then you can use the  /NOSOURCE2 option on the %INCLUDE statement if you don't want the generated code printed to the log.

 

1    data _null_;
2     call execute('data _null_; put "generated code ran"; run;');
3    run;

NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


NOTE: CALL EXECUTE generated line.
1   + data _null_; put "generated code ran"; run;

generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.00 seconds


4    options nosource2;
5    data _null_;
6     call execute('data _null_; put "generated code ran"; run;');
7    run;

NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1   + data _null_; put "generated code ran"; run;

generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds

8    options nosource;

NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds



generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

 

Since your CALL EXECUTE is generating a call to a macro it will help if you wrap the macro name inside %NRSTR() so that the actual macro call is pushed onto the stack to run after the data step, instead of the text that the macro generates. At least then the CALL EXECUTE will only generate one line into the log.

call execute('%nrstr(%HFEQ);');

 

The NOMPRINT option suppresses the lines of code generate by the MACRO code. But if you run the macro while pushing the code onto the stack to run after the data step it looks to SAS like the code it generates is the lines that you pushed with CALL EXECUTE() so they are echoed with plus sign in front of them.

 

To suppress all of the lines generated by CALL EXECUTE() use NOSOURCE.  I am actually surprised that you cannot suppress it with NOSOURCE2.  Another reason why I normally prefer to write generated code to a file and then %INCLUDE the file. Then you can use the  /NOSOURCE2 option on the %INCLUDE statement if you don't want the generated code printed to the log.

 

1    data _null_;
2     call execute('data _null_; put "generated code ran"; run;');
3    run;

NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


NOTE: CALL EXECUTE generated line.
1   + data _null_; put "generated code ran"; run;

generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.00 seconds


4    options nosource2;
5    data _null_;
6     call execute('data _null_; put "generated code ran"; run;');
7    run;

NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1   + data _null_; put "generated code ran"; run;

generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds

8    options nosource;

NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds



generated code ran
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1217 views
  • 1 like
  • 2 in conversation