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

Hi All,

 

I have a simple proc tabulate and ODS EXCEL to export to MS Excel. The result has a sheet by every segment. 

 

How I configure the ODS Excel statement to have a segment name as sheet name?

 

My current SAS code is:

 

ods excel file="/path/File_Test.xlsx"  options(sheet_interval='page');
    PROC TABULATE DATA=WORK.Test ; 
         CLASS Name Segment  &columnas / ORDER=UNFORMATTED MISSING;
         TABLE Segment, &columnas, Name*ColPctN ;
    RUN;
ods excel close;

But as results each sheet is named: Tabulate 1 - Table 1, Tabulate 2 - Table 1, etc. Please see the attached file.

 

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi, if you switch to BY group processing and use a BY instead of a page, then you can use the #byval for the sheet_name, as shown in this previous posting: https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excelxp-PROC-TABULATE-multiple-sheets/m-p/... -- there is an ODS EXCEL example in the posting on 5-17 that shows using #BYVAL to name the sheets.

cynthia

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi, if you switch to BY group processing and use a BY instead of a page, then you can use the #byval for the sheet_name, as shown in this previous posting: https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excelxp-PROC-TABULATE-multiple-sheets/m-p/... -- there is an ODS EXCEL example in the posting on 5-17 that shows using #BYVAL to name the sheets.

cynthia
MariaD
Barite | Level 11

Thanks @Cynthia_sas, works perfect!

Reeza
Super User

Try the Sheet_Label and Sheet_name options in the ODS EXCEL statement. 

You can find a lot of examples online using ODS TAGSETS which is the same approach you need for ODS EXCEL.

 

https://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html#data

 

http://documentation.sas.com/?docsetId=odsug&docsetTarget=p09n5pw9ol0897n1qe04zeur27rv.htm&docsetVer...

 

I'm getting some weird behaviour but maybe this will work for you:

 

proc sort data=sashelp.cars out=cars;
by origin;
run;

ods excel file="c:\_localdata\temp.xlsx" options(sheet_interval="bygroup" sheet_label='');

proc print data=cars;
by origin;
run;

ods excel close;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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