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;
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;
Hi @Ronein ,
You can use a proc datasets:
proc datasets library = RRR nolist nowarn;
delete shoes;
run;
quit;
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
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;
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
You can delete that by using the same method (assign file reference, and use fdelete()).
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?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.