BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LB
Quartz | Level 8 LB
Quartz | Level 8

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 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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).

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

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).

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
  • 1 reply
  • 766 views
  • 0 likes
  • 2 in conversation