- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Let's say that I export one data set (shoes) into one excel sheet (Via XLSX engine).
The xlsx file that was created is called "Shoes".
Now , I want to delete this file.
What is the way to do it please?
libname RRR clear;
libname RRR XLSX "/path/shoes.xlsx";
proc sql;
create table RRR.shoes as
select * from sashelp.shoes
;
quit;
data _null_;
set RRR.shoes;
rc = fdelete("/path/shoes.xlsx");
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Ronein
Thank you for your feedback! Have you tried to use a filename like below?
libname RRR clear;
filename fileref "/path/shoes.xlsx";
data _NULL_;
rc= fdelete ("fileref");
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Ronein ,
You can use a proc datasets:
proc datasets library = RRR nolist nowarn;
delete shoes;
run;
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
I run the code that you sent.
However, I have checked and the xls file was not deleted.(There is no error but the file was not deleted)
Please see the log
NOTE: PROCEDURE DATASETS used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1115.65k
OS Memory 28460.00k
Timestamp 12/01/2019 10:58:03 AM
Step Count 22 Switch Count 0
Page Faults 0
Page Reclaims 181
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Ronein
Thank you for your feedback! Have you tried to use a filename like below?
libname RRR clear;
filename fileref "/path/shoes.xlsx";
data _NULL_;
rc= fdelete ("fileref");
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much.
Now it is working but what happened is that the XLSX file was deleted but another file was created called shoes.xlsx.bak
The file that was created is a BAK file and not XLSX file
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can delete that by using the same method (assign file reference, and use fdelete()).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
Is it always the process that when I delete XLSX file then BAK file is created automatically?
Another question:
IF I run delete for non exiting file, will I get an error?
Should I run condition statement that check if the file exists before I ask to delete it?