In my sas library path I have got some data_set and some empty folder
I want delete all but if I use
proc datasets lib=output kill nolist memtype=all;
quit;
I clean only data-sets.
The X or SYSTASK statements should do the trick (as Doc@Duke suggests), however if you need more control to select certain types of files, try the FDELETE function. This function will delete any type of file, and since you are in the DATA step, this gives you a great deal of flexibility. For windows:
filename list pipe 'dir "c:\temp\sasdat" /b/o';
data _null_;
length fname $40;
infile list truncover;
input fname $;
rc=filename('abc',catt("c:\temp\sasdat\",fname));
if rc = 0 and fexist('abc') then rc=fdelete('abc');
rc=filename('abc');
run;
You could use the "x" command to go out to the operating system and delete the non-sas files.
The X or SYSTASK statements should do the trick (as Doc@Duke suggests), however if you need more control to select certain types of files, try the FDELETE function. This function will delete any type of file, and since you are in the DATA step, this gives you a great deal of flexibility. For windows:
filename list pipe 'dir "c:\temp\sasdat" /b/o';
data _null_;
length fname $40;
infile list truncover;
input fname $;
rc=filename('abc',catt("c:\temp\sasdat\",fname));
if rc = 0 and fexist('abc') then rc=fdelete('abc');
rc=filename('abc');
run;
Thank you very much !!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.