SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hello,

 

I am using the below code to export a sas dataset to an Excel worksheet.  If the workbook doesn't exist then it is created along with the sheet and everything works as intended.  However, if I change the work.HAVE dataset and re-run the export the SAS log tells me that "'WANT' range/sheet was successfully created" but the data in the sheet doesn't actually change and neither does the modified date on the Excel file.  I am working in SAS Enterprise Guide 7.15 and Excel 2016.  Any insight is greatly appreciated.  Thanks in advance.

 

proc export data= work.HAVE

outfile = "&path\test.xlsx"

dbms= EXCEL replace;

sheet= "WANT";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Suggest you try DBMS = XLSX since that is the actual workbook type.

View solution in original post

10 REPLIES 10
SASKiwi
PROC Star

Suggest you try DBMS = XLSX since that is the actual workbook type.

GeorgeBonanza
Quartz | Level 8
Yes, I am using EG but the job is running on the local machine.
andreas_lds
Jade | Level 19

Which SAS version is in use? Are latest updates installed?

GeorgeBonanza
Quartz | Level 8
I am using Enterprise Guide 7.1 and to the best of my knowledge updates are current.
andreas_lds
Jade | Level 19

I asked which version of the sas-software is used: use

%put &=Sysvlong;

to write version number to the log.

GeorgeBonanza
Quartz | Level 8
I misunderstood your question. Apologies. The version is
SYSVLONG=9.04.01M7P080520
andreas_lds
Jade | Level 19

@GeorgeBonanza wrote:
I misunderstood your question. Apologies. The version is
SYSVLONG=9.04.01M7P080520

The latest release, so i don't think that the sas version is the culprit. The following steps work as intended:

data narf;
   set sashelp.class;
run;

proc export data=work.narf dbms=xlsx outfile="&Benutzer\data\narf.xlsx" replace;
   sheet= 'narf';
run;


data narf;
   set sashelp.class;
   Age = Age + 10;
run;

proc export data=work.narf dbms=xlsx outfile="&Benutzer\data\narf.xlsx" replace;
   sheet= 'narf';
run;

So have you tried changing dbms to "xlsx" as recommended by @SASKiwi ?

GeorgeBonanza
Quartz | Level 8
I tried running the code you shared and it does work as intended to create the file on the first export. However, after changing the age and rerunning the export step it does overwrite the existing "narf" sheet but it also creates another file called "narf.xlsx.bak". I tried exporting to both the desktop and shared folder on a LAN and got the same results. I haven't seen this before as it didn't happen using dbms = EXCEL
Sajid01
Meteorite | Level 14

Proc export does create a backup of existing xlsx workbook before over writing it. This is the normal behavior.
It does this both on Windows and Linux.
If you do not want this back this can be deleted or by running a macro to delete it. This forum post has the details  https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/td-p/787216 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 6136 views
  • 4 likes
  • 5 in conversation