0
votes

In the following code, I would like to print an excel sheet and do not open it once the code ends, does anyone know how to do this because the ods excel close does not work. There is an option in the SAS 9.4 platform to not open the output but when I choose than and open a new SAS session the option is reverted. Anyone knows something about it? Thanks :)

ods listing close;
ods excel file="path.xlsx"
/*ods excel file="path.xlsx"*/
/* will apply an appearance style */
/*style=calibri*/
options(
/* for multiple procs/sheet */
sheet_interval="none" 
/* name the sheet tab */
sheet_name="filename"
);

/* add some formatted text */
ods escapechar='~';
ods text="~S={font_size=14pt font_weight=bold}~filename";

proc print data=data noobs;
run;

ods excel close all;
ods listing; 
2

2 Answers

2
votes

Tazz:

Problem

You should look at the SAS log for ERROR messages. In future questions be sure to add ERROR messages. Do you get this message ? (### is the source code line number)

###  ods excel close all;
                     ---
                     22
                     202
ERROR 22-322: Syntax error, expecting one of the following: ;, ANCHOR, AUTHOR, BOX_SIZING,
              CATEGORY, CLOSE, COMMENTS, CSSSTYLE, DOM, DPI, FILE, GFOOTNOTE, GTITLE, IMAGE_DPI,
              KEYWORDS, NOGFOOTNOTE, NOGTITLE, OPTIONS, SASDATE, STATUS, STYLE, TEXT, TITLE,
              WORK.
ERROR 202-322: The option or parameter is not recognized and will be ignored.

So, this statement of yours is invalid

ods excel close all;

Fix

Use instead either

ods excel close;

or

ods _all_ close;

Be forewarned, the first time you run the code Excel will open the output. If you leave the results open in Excel and run the code again you will get a different ERROR:

ERROR: File is in use, ....

because the destination will still be open and SAS will not be able to write to it.

Turn off results viewing

ODS RESULTS OFF;

The ODS destination will be written to. The automatic viewing of results and results tracking as new items in the Results tab will not happen.

0
votes

The setting is not programmed in, it's in the GUI.

Tools>Options>Preferences>Results Uncheck: View results as they are generated