BookmarkSubscribeRSS Feed
SAShole
Pyrite | Level 9

I would like to get multiple log files for my program. One overall log file for my 'driver program' that is a master log that captures everything and one for each individual report that is called within the main program.

 

I have job that runs on the SAS Scheduler Manager plug-in through SAS MC.

I've added this to the execute line:

-altlog /opt/sas/data/sas_reports/scheduler/weekly_report_$(date +%Y-%m-%d_%H%M%S).log

 

My 'driver program' calls 40 individual reports like this:

 

%include "/opt/sas/data/Prog1.sas";

%include "/opt/sas/data/Prog2.sas";

....

%include "/opt/sas/data/Prog40.sas";

 

The individual programs have a similar structure like this:

 

proc printto
log="&fname..log" new;
quit;

 

/*

body of the program

*/

 

proc printto;
quit;

 

Details:

SAS 9.4 on UNIX Grid Servers

 

According to this thread it seems like it should be possible:

https://communities.sas.com/t5/SAS-Programming/Outputting-log-to-two-locations/td-p/301336

@Astounding @zekeT_sasaholic 

 

However, when I open my ALTLOG file it stops printing as soon as it hits the proc printto in my first program.

 

What am I missing?

 

 

5 REPLIES 5
yabwon
Amethyst | Level 16

Hi @SAShole ,

 

1) your login looks like Paul Dorfman's ( @hashman ) e-mail address 🙂

 

2) why not to make code of programs just:

/*
body of a program
*/

and then add this little macro in teh main program:

%macro runMe(program);
filename myLog "/opt/sas/data/sas_reports/scheduler/weekly_report_%sysfunc(datetime(), b8601dt.).log";
proc printto log=myLOG new;
run;
 
%include "/opt/sas/data/&program..sas";

proc printto; run;
data _null_;
  infile myLog;
  input;
  put _infile_;
run;
filename myLog clear;
%mend runMe;



%runMe(Prog1)
%runMe(Prog2)
%runMe(Prog3)
...

you will get the result you need and you don't have to modify SAS session.

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAShole
Pyrite | Level 9

If I have a proc printto within the program I'm calling will that cancel out the main log? My goal is to get a 'Master log' and individual log's for each program.

yabwon
Amethyst | Level 16

Run my example and you'll see you have both.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASKiwi
PROC Star

@SAShole  - I'm curious to know why you think splitting batch logs is an improvement over a single log per job.

 

If you are looking for errors it is a whole lot easier to scan one file instead of several. Also since you are using %INCLUDE statements to bring in each program, the program boundaries in the logs are clear if you search on %INCLUDE.

 

Then there is the complication of adding and managing ALTLOGs.

 

Personally I follow the KISS (Keep It Simple) principle 😉

zekeT_sasaholic
Quartz | Level 8
Hi there. Yikes im kinda late to the game here. Did you get this to work? I'll monitor to see whats going on. Feel free to email me: info@ztorres.net - so i havent fully seen the write up here or what @Bart has replied (which i'd trust works). Hence I just wanted to apologize for a late response and see where to help. Best - z

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3113 views
  • 2 likes
  • 4 in conversation