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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.