BookmarkSubscribeRSS Feed
ssitharath0420
Quartz | Level 8

Hello,

 

I am creating a report with ODS Excel.  I used proc report and it generate an excel output.  The Excel open but doesn't automatically closed.  I have to close out the excel manually.  Is there a command to close the excel automatically once the ODS Proc Report is generated?

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:
This is what I tell my students...if you open it, you have to close it. This ALWAYS works for me:
ods excel file='c:\temp\makereport.xlsx';
   proc report data=sashelp.shoes(obs=5);
   run;
ods excel close;

So I'm not sure what you mean when you say "The Excel open but doesn't automatically closed". Can you post your code or your log?

Cynthia

ssitharath0420
Quartz | Level 8

@Cynthia_sas ,

 

This is the code I am using.

 

ods excel file="\\fenrir\DEVL\sam_s\Standard Opioid ODS Conversion\Summary1.xlsx" options(start_at="1,13"
frozen_headers="5"
frozen_rowheaders="3"
/*autofilter="1-5"*/
sheet_name="Summary"
row_repeat="1"
embedded_titles="yes");

proc report split='~' data=Table1_Final out=Table1_Final_1 spanrows style(header)=[fontweight=bold background=lightblue foreground=black]
style(column)={font_face='Calibri' fontsize=11pt};
column Status P4 P3 P2 P1;
define Status / Display "";
define P1 / Analysis "7/1/20 -~ 12/31/2020" style(column)={cellwidth=15% textalign=center just=decimal};
define P2 / Analysis "4/1/20 -~ 09/30/2020" style(column)={cellwidth=15% textalign=center just=decimal};
define P3 / Analysis "1/1/20 -~ 06/30/2020" style(column)={cellwidth=15% textalign=center just=decimal};
define P4 / Analysis "10/1/19 -~ 03/31/2020" style(column)={cellwidth=15% textalign=center just=decimal};
title1 '# of Members Filling Opioids';
rbreak after / summarize;
compute status;
if _break_ in ('_RBREAK_') then do;
Status = 'Total';
end;
endcomp;
run;

ods excel close;

 

It is supposed to open the excel and close but for some reason the excel output would not closed.

Cynthia_sas
SAS Super FREQ
Hi:
Without your data, no one can test the code. However you say that "IT is supposed to open the excel and close..." but I am confused by what you mean when you say "it". Do you think that SAS is supposed to launch Excel when the output XLSX file is created? Whether Excel opens or not really depends on your interface -- how you are submitting the code.

As mentioned by @ballardw, if you are creating output using the standard Windowing Environment (or Display Manager) then this is controlled by a setting that you (or your Administrator) sets. If you are using Enterprise Guide or SAS Studio, then Excel output does NOT automatically open within those interfaces.

Cynthia
ssitharath0420
Quartz | Level 8

@Cynthia_sas , thank you I got it to work by using ODS NORESULT;

ballardw
Super User

You don't say which interface you are using.

 

In Foudation (or Base SAS) there is a system setting that says "View results as generated". If you turn that off then the Excel file, or other destinations, won't open automatically.

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 1904 views
  • 0 likes
  • 3 in conversation