BookmarkSubscribeRSS Feed
BETO
Fluorite | Level 6

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;

5 REPLIES 5
CTorres
Quartz | Level 8

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

ballardw
Super User

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;

BETO
Fluorite | Level 6

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.";

Haikuo
Onyx | Level 15

for your question: options noxwait;

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

ballardw
Super User

options noxwait; before the X command.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 8336 views
  • 6 likes
  • 4 in conversation