Usage Note 35746: Microsoft Excel worksheets might be corrupted and an error might occur when you export a SASĀ® data set that contains no observerations
When you use the EXPORT procedure on an Excel workbook, the workbook might be corrupted and the following error message generated:
ERROR: The MS Excel table (worksheetname) has been opened for OUTPUT.
This table already exists, or there is a name conflict with an
existing object. This table will not be replaced. This engine
does not support the REPLACE option.
ERROR: Export unsuccessful. See SAS Log for details.
This problem can occur if a previous EXPORT procedure attempts to export a SAS data set in the workbook that does not contain any observations. The following example illustrates an export procedure on such a data set:
%macro blowup;
data a;
a=1;
stop;
run;
%do i=1 %to 2;
proc export data=a outfile="c:\temp\test.xls"
dbms=excel2000 replace;
run;
%end;
%mend;
%blowup;
The problem occurs because the SAS data set does not contain any data to export. As a result, a corrupted structure is created.
To circumvent the problem, do one of the following:
- Use the SQL procedure with a DROP TABLE statement to drop the empty data set before replacing it, as shown in the following example:
%macro blowup;
data a;
a=1;
stop;
run;
%do i=1 %to 2;
libname test excel 'c:\sastest\test2.xls';
proc sql;
drop table test.a;
quit;
libname test clear;
proc export data=a outfile="c:\sastest\test2.xls"
dbms=excel2000 replace;
run;
%end;
%mend;
%blowup;
- If you intend to create an empty Excel workbook, use a LIBNAME statement with the EXCEL engine and a new Excel workbook name, as shown here:
libname test excel 'c:\sastest\test2.xls';
libname test clear;
This example creates a blank Excel workbook that you can use later.
Operating System and Release Information
SAS System | SAS/ACCESS Interface to PC Files | Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 | |
Microsoft Windows XP Professional | 9.1 TS1M3 | |
Windows Vista | 9.1 TS1M3 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Usage Note |
Priority: | |
Topic: | Data Management ==> Data Sources ==> External Databases ==> MS Excel
|
Date Modified: | 2009-10-21 13:00:06 |
Date Created: | 2009-04-30 09:21:36 |