DATA Step, Macro, Functions and more

how to delete all files in sas library ?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

how to delete all files in sas library ?

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.


Accepted Solutions
Solution
‎10-30-2012 03:00 PM
Valued Guide
Posts: 634

Re: how to delete all files in sas library ?

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;

View solution in original post


All Replies
Trusted Advisor
Posts: 2,115

Re: how to delete all files in sas library ?

You could use the "x" command to go out to the operating system and delete the non-sas files.

Solution
‎10-30-2012 03:00 PM
Valued Guide
Posts: 634

Re: how to delete all files in sas library ?

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;

Occasional Contributor
Posts: 12

Re: how to delete all files in sas library ?

Thank you very much !!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 495 views
  • 1 like
  • 3 in conversation