BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

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;

View solution in original post

6 REPLIES 6
ed_sas_member
Meteorite | Level 14

Hi @Ronein ,

 

You can use a proc datasets:

proc datasets library = RRR nolist nowarn;
  delete shoes;
  run;
quit;
Ronein
Meteorite | Level 14

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

ed_sas_member
Meteorite | Level 14

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;
Ronein
Meteorite | Level 14

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 

 

Ronein
Meteorite | Level 14

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 3344 views
  • 1 like
  • 3 in conversation