Basically as it says in the title, I have an excel list of files which can be deleted and the filepath is given. How can I delete all of these filepaths in one piece of code?
Have a look here:
You will use the FILENAME and FDELETE functions to do what you want
What does the list of files to delete look like?
Find below a sample program that shows how to use the FILENAME and FDELETE functions. This should help you understand how to use them. Additionally you have to read the documentation of does function as well.
*
* file we want to delete
*;
%let myfile = c:\temp\sugus.dat;
%put NOTE: does &myfile exists %sysfunc(fileexist(&myfile)) (1=true 0=false) ;
*
* create file for delete testing
*;
data _null_;
file "&myfile";
put "hello world";
run;
%put NOTE: does &myfile exists %sysfunc(fileexist(&myfile)) (1=true 0=false) ;
*
* delete file using FDELETE function, needs a fileref
*;
data _null_;
rc_assign_fileref = filename("_fd", "&myfile");
rc_fdelete = fdelete("_fd");
rc_deassign_fileref = filename("_fd");
putlog _all_;
run;
%put NOTE: does &myfile exists %sysfunc(fileexist(&myfile)) (1=true 0=false) ;
The documentation contains an example explaining how to use fdelete.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.