Hi All,
I am trying to create an Excel file ( .xlsx) file programattically in SAS EG. I tried using PROC IMPORT with DBMS=XLSX , even though I did not get any error the file that got created is not able to open. I am wondering if I am using the right options to achieve this.
Please advise.
Thank you!
Please supply the code you are using. You need to use PROC EXPORT, not IMPORT to create an Excel workbook, and you need to have a server folder location where you have write access.
Sorry I mean PROC EXPORT.
Here is my code:
%let data_path=%str(/apps/sas/datasets/dataf/);
PROC EXPORT DATA= WORK.TEMP01
OUTFILE= "&data_path./email.xlsx"
DBMS=xlsx REPLACE;
SHEET="TEST";
RUN;
There are two possible issues I see. First is do you have write permission to that folder on the SERVER as that is likely the relative path location.
Second is the path usually works best if you describe everything from a mount point as the location SAS is actually running in may not have that relative path subordinate.
I do have write permission because I was able to write a .CSV file to the same location.
What does your log say?
Please post log and version of SAS, not EG version.
Reeza/Casey,
Please see my log notes:
NOTE: The export data set has 94 observations and 24 variables.
NOTE: "/apps/sas/datasets/data7/email.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
Thanks @renjithr. That confirms the .xlsx file was created. So, back to my previous question...
When you say, "the file that got created is not able to open", do you mean the xlsx file cannot be opened in Excel? Or, the xlsx file is created, but not added to the EG project? (If the second case, EG does not automatically add files exported via code to the EG project.)
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
When you say, "the file that got created is not able to open", do you mean the xlsx file is created, but cannot be opened in Excel? Or, the xlsx file is created, but not added to the EG project? If the second case, EG does not automatically add files exported via code to the EG project.
As suggested by others, looking at the log to determine if the xlsx was actually created is the first step. For example, do you see notes similar to the ones below in your log?
NOTE: The export data set has 19 observations and 5 variables.
NOTE: "\\d79879\c$\users\cassmi\desktop\\email.xlsx" file was successfully created.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.