Desktop productivity for business analysts and programmers

Create multiple tabs in one workbook

Posts: 67

Create multiple tabs in one workbook

Hi members,

I am running SAS EG4.3 on the server, and trying to create an excel file with multiple tab in it, and then send this file to myself; however, I keep getting an error saying "ERROR: DBMS type XLSX not valid for export.", I did some research, but tried several suggestions online, but it still doesn't work.

Do I need to create an Excel file before I attach in the mail?

Please help.

Thank you!

/*** output an Excel with multiple tab ***/

data &server..test2;

   set &server..test;


proc export data = &server..test

   outfile = "c:/sas/test"

   dbms = excel replace;

   sheet = check1;


proc export data = &server..test2

   outfile = "c:/sas/test"

   dbms = excel replace;

   sheet = check2;


ERROR: DBMS type EXCEL not valid for export.

/*** sent an email ***/

data _null_;

file sendit email


subject='Demo Results'





ERROR: Error opening attachment file test2.xls.

ERROR: Physical file does not exist, server..test2.xls.

Please let me know if you need more information. Thanks

Super User
Posts: 23,998

Re: Create multiple tabs in one workbook

Have you tried explicitly writing your file name in the outfile?

EG 4.3 probably cant create XLSX file as it was too old at the time.


Community Manager
Posts: 3,459

Re: Create multiple tabs in one workbook

For DBMS=EXCEL to work, you need to have SAS/ACCESS to PC Files licensed and installed in your SAS environment.  It appears that you don't have that.

The alternative for SAS 9.2 is to use ODS tagsets.ExcelXP,  which creates an Excel-compatible XML file.  For SAS 9.4 users, you can use ODS EXCEL to create an XLSX file directly.  Both of these methods work in Base SAS.

You can also export to CSV and attach that in your e-mail.  It's a simple file format that opens in Excel, but you won't have the control over multiple sheets that you're looking for.  You would have to export multiple CSV files.


Posts: 67

Re: Create multiple tabs in one workbook

Thanks Reeza and Chris. It seems like this is very complicated.

I think I'm going to find a workaround and export as csv / xslx files as part of the process flow. final goal is to fit the final report template, I can use EED to read in.

Super User
Posts: 10,849

Re: Create multiple tabs in one workbook

Libname statement is a good choice .

libname x excel 'c:\temp\multi.xls';

data a_20150101 a_20150204 a_20150903;
   set sashelp.class;

proc copy in=work out=x memtype=data ;run;

libname x clear; 

Xia Keshan

Ask a Question
Discussion stats
  • 4 replies
  • 1 like
  • 4 in conversation