Is there a way to export the log at the end of a program run in the ods excel destination file?
I can export using proc printto and then reimport but it is simply onerous and would miss the last part of the program-
ods excel file="//sam1/sss/test.xlsx" style=Seaside options(sheet_name="Lab Statistics" SHEET_INTERVAL= 'NONE' autofilter='NONE' FROZEN_ROWHEADERS='no' GRIDLINES='ON' embedded_titles='yes' embedded_footnotes='yes'); ods escapechar="\"; proc report data=graphs headline headskip nowd spanrows style(report)={font_size=8pt cellpadding=1pt cellspacing=1pt} style(column) = {font = ("arial",8pt) just=center} style(header) = {font = ("arial",9pt) just=center};; columns dt negative_tests positive ct pos_rate; define dt /"Date Ending" group; define negative_tests/"Negative/Tests"; define positive/"Positive/Tests"; define ct/"Total/Tests"; define pos_rate/"Positivity/Rate" format=percent10.; run; ods excel close;
Thanks
Lawrence
Use proc printto to reroute the log. After ending the reroute with a second proc printto, read the log into a dataset and use proc print and some ods options to create an extra sheet in your workbook:
filename mylog temp;
proc printto log=mylog;
run;
ods excel
file="/folders/myfolders/test.xlsx"
style=Seaside
options(
sheet_name="Lab Statistics"
SHEET_INTERVAL='NONE'
autofilter='NONE'
FROZEN_ROWHEADERS='no'
GRIDLINES='ON'
embedded_titles='yes'
embedded_footnotes='yes'
)
;
proc print data=sashelp.class;
run;
proc printto;
run;
data log;
infile mylog truncover;
input logline $80.;
;
run;
ods excel options(sheet_name='Log' sheet_interval='now');
proc print data=log noobs;
run;
ods excel close;
The contents of the log are determined by the placement of the proc printto steps; the second proc printto must come before you read the log (otherwise, the file may be locked).
Use proc printto to reroute the log. After ending the reroute with a second proc printto, read the log into a dataset and use proc print and some ods options to create an extra sheet in your workbook:
filename mylog temp;
proc printto log=mylog;
run;
ods excel
file="/folders/myfolders/test.xlsx"
style=Seaside
options(
sheet_name="Lab Statistics"
SHEET_INTERVAL='NONE'
autofilter='NONE'
FROZEN_ROWHEADERS='no'
GRIDLINES='ON'
embedded_titles='yes'
embedded_footnotes='yes'
)
;
proc print data=sashelp.class;
run;
proc printto;
run;
data log;
infile mylog truncover;
input logline $80.;
;
run;
ods excel options(sheet_name='Log' sheet_interval='now');
proc print data=log noobs;
run;
ods excel close;
The contents of the log are determined by the placement of the proc printto steps; the second proc printto must come before you read the log (otherwise, the file may be locked).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.