There are several posts about export the project log and I came up with this solution that exports all the logs of the run tasks, which is quite close to being the project log. No automation or VB needed.
Using these 2 macros:
%macro printlog(path=,program=&_CLIENTTASKLABEL);
%let dateymd = %sysfunc(date(),yymmddn8.) ; %put &dateymd;
%let Timehm = %sysfunc(time(),tod5.) ; %*HHMM; %let Timehm = %sysfunc(compress(&Timehm,":")) ; %*HHMM; %put &Timehm;
%let logfile=&program.-&dateymd.-&Timehm..log; %put &logfile;
filename proglog "&path.&logfile";
proc printto log="&path.&logfile" new; run;
%mend printlog;
%macro pdflog(path=,program=&_CLIENTTASKLABEL);
proc printto; run;
proc document name=mydoc(write); import textfile= proglog to logfile; run;
ods listing;
/* Take a look at the entry in MYDOC */ proc document name=mydoc; list; run;
ods listing close;
/* Replay the output to the PDF destination */
%let dateymd = %sysfunc(date(),yymmddn8.) ; %put &dateymd;
%let Timehm = %sysfunc(time(),tod5.) ; %*HHMM; %let Timehm = %sysfunc(compress(&Timehm,":")) ; %*HHMM; %put &Timehm;
%let pdffile=&program.-&dateymd.-&Timehm..pdf; %put &pdffile;
filename progpdf "&path.&pdffile"; ods pdf file="&path.&pdffile" notoc; replay; run; ods pdf close;
/*options center date number;*/ run; quit;
%mend pdflog;
******************************************************************
I then put this at the end of the autoexec:
%global project;
%let project = &_CLIENTPROJECTNAME; %Let project = %SysFunc( TranWrd( %qleft(%superq(project)) ,%str(%'),%Str( ) ) ) ; %let posit = %sysfunc(FINDC(%qleft(%superq(project)), %str(.), b) ); %Let project = %Substr(%qleft(%superq(project)),1,&posit - 1); %put &=project;
%printlog(path=&qc,program=&project);
******************************************************************
so that resolves to (substitute &qc for your path of choice):
filename proglog "(path)/(project name)-20190311-1050.log";
proc printto log="(path)/(project name)-20190311-1050.log" new; run;
******************************************************************
so that each run of the project generates a date- and time-stamped log file.
now, at the end of the last task, I add this:
%pdflog(path=&qc,program=&project);
which generates (path)/(project name)-20190311-1142.pdf, which is half the size of the log file.
This is especially handy for production runs using ordered lists.
A nice side benefit is that you can see that the entire project started at 1050 and ended at 1142.
... View more