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

Hi,

When creating a new worksheet using contents=yes, this new worksheet is named "The Table of Contents".

Is there a way to change this name e.g. to TOC or to "Table des matières" for example ?

 

I've looked into the template but couldn't find any prespecified text for the tab name.

Using locale=FR_FR does not change the worksheet name.

 

The same problem occurs with index='yes'.

 

ods excel file="&xxtest./reporting/ods_excel_test.xlsx" 
          options(contents='yes');

ods excel options(sheet_name='Male');
proc print data=sashelp.class noobs;
    where sex='M';
run;

ods excel options(sheet_name='Female');
proc print data=sashelp.class noobs;
    where sex='F';
run;

ods excel close;

toc.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

An XLSX file is just a ZIP with special content.

So just change the name yourself.

Example:  Change sheet name to TOC.

ods excel file="c:\downloads\toc.xlsx" 
          options(contents='yes' sheet_name='TOC')
;

ods excel options(sheet_name='Male');
proc print data=sashelp.class noobs;
    where sex='M';
run;

ods excel options(sheet_name='Female');
proc print data=sashelp.class noobs;
    where sex='F';
run;

ods excel close;


filename copy temp;
data _null_;
  infile 'C:\downloads\toc.xlsx' zip member='xl/workbook.xml';
  input;
  file copy ;
  _infile_=tranwrd(_infile_,'sheet name="The Table of Contents"','sheet name="TOC"');
  put _infile_;
run;
data _null_;
  infile copy;
  file 'C:\downloads\toc.xlsx' zip member='xl/workbook.xml';
  input;
  put _infile_;
run;

Screenshot 2021-12-27 155521.jpg

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

An XLSX file is just a ZIP with special content.

So just change the name yourself.

Example:  Change sheet name to TOC.

ods excel file="c:\downloads\toc.xlsx" 
          options(contents='yes' sheet_name='TOC')
;

ods excel options(sheet_name='Male');
proc print data=sashelp.class noobs;
    where sex='M';
run;

ods excel options(sheet_name='Female');
proc print data=sashelp.class noobs;
    where sex='F';
run;

ods excel close;


filename copy temp;
data _null_;
  infile 'C:\downloads\toc.xlsx' zip member='xl/workbook.xml';
  input;
  file copy ;
  _infile_=tranwrd(_infile_,'sheet name="The Table of Contents"','sheet name="TOC"');
  put _infile_;
run;
data _null_;
  infile copy;
  file 'C:\downloads\toc.xlsx' zip member='xl/workbook.xml';
  input;
  put _infile_;
run;

Screenshot 2021-12-27 155521.jpg

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 3169 views
  • 2 likes
  • 2 in conversation