I'm running the below code to copy an Excel template, then replace the two tables aHeader and aException in the output file, to which I assign the libname wbkOut. When I run this, I get the following error message from the data step which creates the table aHeader:
ERROR: The MS Excel table aHeader 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.
However, the data step creating the table aException runs fine:
There were 1305 observations read from the data set WORK.EXC_DEF_WO_LINK.
NOTE: The data set WBKOUT.aException has 1305 observations and 9 variables.
%let report = &path.\®ref.\output\DV_42_Day_Monitoring_&cms_d_fmt..xls ;
%let template = &path.\®ref.\excel\Report_Template.xls ;
filename template "&template" ;
filename outfile "&report";
data _null_;
infile template recfm=n;
input one_byte $char1. @@;
file outfile recfm=n;
put one_byte $char1. @@;
run;
libname wbkOut EXCEL "&report" ver=2002 scan_text=no;
proc datasets lib=wbkOut;
delete aHeader;
delete aException;
run;
quit;
data Headers ;
format startdate enddate refreshdate reportdate date9.;
progpath="®ref.\sasprogs\&pgmname";
startdate=&startdate.d;
enddate=&enddate.d;
refreshdate="&cms_d_fmt"d;
reportdate="&sysdate9"d;
run;
data wbkOut.aHeader ;
set Headers;
run;
data Exc_Def_WO_Link (keep=region case_current_court case_officer
case_number doc_type doc_number doc_filed_due_d
doc_id case_first_app_filed_d);
set defended_fam_wo_app_link;
case_current_court=put(case_current_court_code, $crtcs.);
case_officer=put(case_officer_id, dfcuser.);
doc_type=put(doc_type_code, $doctyp.);
label region = 'Region'
case_current_court = 'Current Court'
case_officer = 'Case Officer'
case_number = 'Case Number'
doc_type = 'Doc Type'
doc_number = 'Doc Number'
doc_filed_due_d = 'Doc Filing Date'
doc_id = 'Document Id'
case_first_app_filed_d = 'First App Filing Date';
run;
data wbkOut.aException (dblabel=yes);
set Exc_Def_WO_Link;
retain region case_current_court case_officer case_number doc_type doc_number doc_filed_due_d
doc_id case_first_app_filed_d;
run;
libname wbkOut clear;
Can anyone spot anything in here that could be causing this error? I've tried assigning the libname separately first for replacing aHeader, then clearing and assigning again to replace aException - when I did this the aHeader table was replaced ok and replacing the aException table threw an identical error. Both of these tables can be seen from the Server List in Enterprise Guide when the libname is assigned - after the above code runs wbkOut.aHeader can be seen as the 5 columns F1-F5 with 0 rows.
I'm using SAS Enterprise Guide v4.1 on Windows XP - the SAS version is 9.1 and the Excel file format is Excel 97/2003 (but the file was created using Excel 2007).