BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nannà
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ArtC
Rhodochrosite | Level 12

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

3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12

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

ArtC
Rhodochrosite | Level 12

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;

nannà
Calcite | Level 5

Thank you very much !!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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