SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 20818 views
  • 4 likes
  • 5 in conversation