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

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!

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
  • 2 replies
  • 1514 views
  • 2 likes
  • 2 in conversation