Using a file reference to export a Microsoft Excel file does not automatically add the .xlsx file extension


When you use a file reference to export an Excel file in SAS® 9.4M7 (TS1M7), the .xlsx extension is not automatically added. The following code creates a class file and a class.xlsx file:

%let filename1 = C:\temp\class;
%let filename2 = C:\temp\class.xlsx;
filename one "&filename1";
filename two "&filename2";
%put %sysfunc(fdelete(one));
%put %sysfunc(fdelete(two));
proc export data=sashelp.class
dbms=xlsx
outfile=one replace;
sheet = "ABC";
run;
proc export data=sashelp.class
dbms=xlsx
outfile=two replace;
sheet = "ABC";
run;

A workaround for this issue is to use the actual file path in the outfile option as shown below:

%let filename1 = C:\temp\class;
proc export
data=sashelp.class
dbms=xlsx
outfile="&filename1"
replace;
sheet = "ABC";
run;