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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 471 views
  • 0 likes
  • 2 in conversation