BookmarkSubscribeRSS Feed
UniversitySas
Quartz | Level 8

I have the following macro:

 

%MACRO Loop_1;
	%DO i = 1 %TO 500 ;
		%Macro_first(&i);
	%END;
%MEND Loop_1;

The problem is that after a certain amount of loops, the log window becomes full and needs to be cleared before the code progresses.

 

I googled this, and found:

dm 'log;clear;';

But I can't seem to implement it.

If I put it outside the loop, it doesn't work (obviously).

If I put it in inside the loop, the "dm" stays black, so it seems that it's not registering properly as a SAS statement, and when I use

%dm, it's being read as a macro.

 

Any help is appreciated! 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Don't do a clear. Use PROC PRINTTO to write the log to a file. If there is an error somewhere, then you can view the log in the file. If you do a clear, errors are gone.

 
--
Paige Miller
SASKiwi
PROC Star

If your log is that big and it takes a considerable time to run then consider running your program as a batch SAS job then your log can grow as big as necessary.

Reeza
Super User
Turn off the output using NOPRINT when available and use 'option nonotes;' to only have errors and warnings printed to the log. As someone else indicated though, using BY group processing would fix this issue entirely.
ballardw
Super User

@UniversitySas wrote:

I have the following macro:

 

 

 

I googled this, and found:

dm 'log;clear;';

But I can't seem to implement it.

If I put it outside the loop, it doesn't work (obviously).

If I put it in inside the loop, the "dm" stays black, so it seems that it's not registering properly as a SAS statement, and when I use

%dm, it's being read as a macro.

 

Any help is appreciated! 


The "DM" in " dm 'log; clear'; " refers to Display Manager, the SAS interface that is sometimes referred to as Base or Foundation SAS. So if you are working in SAS Studio, Enterprise Guide or Viya I would not expect that to work.

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @UniversitySas 

 

You can route the log to a file with Proc Printto (or to "nowhere" by using the file name dummy) before you enter the loop. Remember to route it back to the log window after the loop:

 

* Disable logging;
filename mylog dummy;
proc printto log=mylog;
run;

* Useless macro generating long log;
%macro m;
	%do i = 1 %to 100;
		data test; 
			 a = 1;
		run;
	%end;
%mend;
%m;

* Enable logging;
proc printto;
run;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 999 views
  • 2 likes
  • 6 in conversation