Help using Base SAS procedures

how to delete excel file when exporting

Reply
Regular Contributor
Posts: 240

how to delete excel file when exporting

HI,

I have  a data step that exports to excel . I need to delet /remove  the original file. How do I go about deleting the file  before the export process starts

I currently have this script for deleting  it's not working

filename myfile "c:\daily\GT.xlsx";

rc=fdelete(myfile);

run;

filename myfileclear;

Regular Contributor
Posts: 180

Re: how to delete excel file when exporting

Try This:

filename myfile "c:\daily\GT.xlsx";

data _null_;

rc=fdelete("myfile");

run;

filename myfileclear;

You must have permission to delete the file.

CTorres

Super User
Posts: 10,550

Re: how to delete excel file when exporting

If you are using proc export then add the REPLACE option to overwrite the existing file. No need for a separate step to delete.
proc export data=yourdate outfile="your file name" dbms=excelcs (or which ever you are using) REPLACE; run;

Regular Contributor
Posts: 240

Re: how to delete excel file when exporting

HI,

Ive tried that option an it doesn't replace the original file it happen when I convert  to xlsx format.

so deleteing it is best option since it runs every three hours..

i Have this code that deletes what I need but the cmd prompt window stays open any ideas how to close it?

%let fname =GT.xlsx;

%let dir=H:\Test\;

x del "&edit.\&fname.";

Respected Advisor
Posts: 3,124

Re: how to delete excel file when exporting

for your question: options noxwait;

Personally I prefer 's solution, as it is more OS independent.

Super User
Posts: 10,550

Re: how to delete excel file when exporting

options noxwait; before the X command.

Ask a Question
Discussion stats
  • 5 replies
  • 2130 views
  • 6 likes
  • 4 in conversation