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

I use sas studio and mistakenly created a weird directory by a wrong sas statement as

 

options dlcreatedir

libname  myname "output;

 

and the directory created is

 

output;OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;ODS HTML CLOSE;GOPTIONS NOACCESSIBLE;; ;*';*

 

my question is, how to possibly delete this directory from within SAS?

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

You can try the FDELETE() function:

filename testdir 'physical-filename';
data _null_;
   rc=fdelete('testdir');
   put rc=;
   msg=sysmsg();
   put msg=;
run;

Example is from the documentation:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0h945u5r0cv6yn1u6qs35hiqt9t.h...

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in March 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

View solution in original post

7 REPLIES 7
Newlifewithegg
Calcite | Level 5
please ignore the syntax error coming with a missing ; following dlcreatedir
Reeza
Super User
Do you have the log? It should have the path the folder is created/assigned.

If so, navigate to that location using Servers Files Folders Pane and delete the folder created.
Newlifewithegg
Calcite | Level 5

Thanks, I definitely am able to remove it with system operations outside of SAS. But the purpose here is to practice with SAS, thus am asking whether there is way to deal with this case within SAS.

Quentin
Super User

You can try the FDELETE() function:

filename testdir 'physical-filename';
data _null_;
   rc=fdelete('testdir');
   put rc=;
   msg=sysmsg();
   put msg=;
run;

Example is from the documentation:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0h945u5r0cv6yn1u6qs35hiqt9t.h...

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in March 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Reeza
Super User

You mean using code rather than the GUI I assume?

 

In that case, FDELETE is the simplest way as shown by @Quentin 

Kurt_Bremser
Super User

Make sure no datasets exist in the library, then de-assign the libname first:

proc datasets lib=output kill;
quit;
libname myname clear;

Then run:

data _null_;
rc= fdelete("output;OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;ODS HTML CLOSE;GOPTIONS NOACCESSIBLE;; ;*';*");
run;

 

Newlifewithegg
Calcite | Level 5

Thank you all for your help. Seems the issue is more fundamental and nearly irrelevant to sas programming. The weird filename cannot be be copy/pasted to sas studio environment, it can only be pasted into word/textbox etc environments.

 

Another more complete solution can be found at

https://communities.sas.com/t5/SAS-Programming/delete-a-folder-directory-and-all-files-on-it/td-p/58...

if the directory contains files

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1137 views
  • 0 likes
  • 4 in conversation