BookmarkSubscribeRSS Feed
mcook
Quartz | Level 8

I have a program that is called quite often during the running of other programs. Its a solid piece of code and very rarely have I had any troubles with it.  However it can be quite long and add quite a bit to the log, especially if mlogic is on, making it all the more tedious trying to debug the current program I am working on.  

 

Is it possible to prevent the output of this code to the log when it is called?  

3 REPLIES 3
Reeza
Super User

Is it code that's within a data step or comprised of several steps?

 

Either way, look into the NONOTES option.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/p1n9y0vee2emq9n1gotajyxubz3x.htm

 

Turn if off before the section and then on after. If it's needed, you can also test the status before hand to decide whether to turn it back on after the code has executed as well using the getoption function. 

SASKiwi
PROC Star

If you are using %INCLUDE to run this program just add the NOSOURCE2 option to remove source statements from your log. Notes and errors will still be included and I think it would be poor practice to also exclude these:

%include 'MyProgram.sas' / nosource2;

There is also a NOSOURCE option that will do the same thing in your main program.

 

My personal preference is to retain full logs but turn off macro options like MLOGIC and MPRINT with regular production jobs. I never use NOSOURCE/2 as I don't  think it is good practice. I've been caught out too many times with unexpected processing problems and not knowing where it might have happened.

 

EDIT: If you are running programs on a regular basis, run them as batch jobs which write SAS logs as text files. I find size is unimportant with batch logs, as you can simply look at the end of the file to see if any errors were reported anywhere within the job. If not you can assume the job ran correctly and there is no need to look further. 

FreelanceReinh
Jade | Level 19

You can also redirect parts of the log with PROC PRINTTO.

 

Example:

filename otherlog 'C:\Temp\routine_macro.log';

... code of main program ...

proc printto log=otherlog;
run;

%routine_macro_call(1)

proc printto;
run;

... more code of main program ...

proc printto log=otherlog;
run;

%routine_macro_call(2)

proc printto;
run;

... more code of main program ...

This would write the parts of the log created by your "routine program" (I've used a macro call as an example) to the external file C:\Temp\routine_macro.log and the more interesting "main" parts of the log to the default destination, so you can read both parts separately.

 

To suppress the code and notes from the PROC PRINTTO steps, you can add the NONOTES and NOSOURCE options suggested by Reeza and SAS_Kiwi:

options nonotes nosource;
proc printto log=otherlog;
run;

%routine_macro_call(...)

proc printto;
run;
options notes source;

Then only the first line of the above block of code will appear in the main log. EDIT: This would, of course, suppress the notes and source code of the "routine program" as well. So, depending on how much you want to see from the "otherlog", you may want to wrap the two OPTIONS statements only around the PROC PRINTTO steps.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1412 views
  • 6 likes
  • 4 in conversation