- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content