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?
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:
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.
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:
You mean using code rather than the GUI I assume?
In that case, FDELETE is the simplest way as shown by @Quentin
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;
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
if the directory contains files
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.
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.