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

I'm trying to dynamically set the Excel tab names for a series of proc reports.  I'm looking through a set of Departments using a macro to control the loop.  I was hoping that I could use the title of the proc report as the tab name but this does not seem to be an option.  If I could do something like

 

sheet_name = &title1 then it would work.  I tried feeding a macro variable to the sheet name but it looks like since the macro variable changes throughout the loop it doesn't work.

 

My structure is 

 

ods Excel OPTIONS (embedded_titles='yes' ) ;
ods escapechar='~';
%ShowUniversityLevel();
%callEmployeeBody();
%DepartmentsDisplay();

ods Excel close;
ods Excel(id=VCU_Report_Printing1) close;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You would need a separate ODS EXCEL OPTIONS statement prior to each sheet of output.

Depending one what else is going on you likely need to be changing the sheet interval as well if you are expecting to have one tab per department with multiple report tables on each.

 

Since you don't show the looping code it is pretty hard to be more precise.

 

 

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

I think it should work, I'm pretty sure I have done this.

 

ods Excel OPTIONS (embedded_titles='yes' sheet_name="&title1") ;

There is probably a limitation on the number of characters that  can go into the sheet name.

--
Paige Miller
DavidPhillips2
Rhodochrosite | Level 12

Not sure if I can use it.  "WARNING: Apparent symbolic reference TITLE2 not resolved. "

Tom
Super User Tom
Super User

@DavidPhillips2 wrote:

Not sure if I can use it.  "WARNING: Apparent symbolic reference TITLE2 not resolved. "


You cannot use a macro variable you have not defined.

ballardw
Super User

You would need a separate ODS EXCEL OPTIONS statement prior to each sheet of output.

Depending one what else is going on you likely need to be changing the sheet interval as well if you are expecting to have one tab per department with multiple report tables on each.

 

Since you don't show the looping code it is pretty hard to be more precise.

 

 

ballardw
Super User

@DavidPhillips2 wrote:

Are you saying the idea is to close and open the ODS Excel output to the process?


No.

I don't have convenient examples as I generate little complicated ODS EXCEL output.

 

Ods excel file="something";

 

ods excel options=(sheet_interval='NONE'); to attempt to place multiple reports on one tab

 

<proc report 1>

<proc report 2>

 

ods excel options=(sheet_interval='BYGROUP'); One tab per by value

<proc report 3

   by somevariable

>

ods excel options=(sheet_interval='Table');

<something that creates multiple tables, get one per tab>

ods excel close;

 

is a basic example.

To make groups related output put you might want something like

 

ods excel options=(sheet_interval='NONE'); to attempt to place multiple reports on one tab

<proc report 1>

<proc report 2>

ods excel options=(sheet_interval='TABLE); to force a "change" so that then NEXT interval is a different tab

ods excel options=(sheet_interval='NONE'); to attempt to place multiple reports on next tab

<proc report 3>

<proc report 4>

ods excel options=(sheet_interval='TABLE); to force a "change"

 

I am not sure whether table or page might work "better" as the dummy change or not.

Of course each of those interval changes would likely be where to change the sheet_label or sheet_name as well.

varmadi
Calcite | Level 5

Thanks a lot

 

wow

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 15997 views
  • 4 likes
  • 5 in conversation