As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
Difference between revisions of "Does the Directory Exist"
Revision as of 00:32, 22 April 2014
There are several ways to check to see if a directory (or a file) exists. These include the use of functions and often, though not necessarily, the macro language.
Additional discussion of that tip includes other approaches.
The FILEEXIST function eliminates the need to create the FILEREF first (which should then be cleared)
%if %sysfunc(fileexist(&dir)) %then %let return=1; %else %let return=0;
--Art Carpenter 18:02, 7 January 2011 (UTC)
Since the return values are 0/1, we can further simplify as follows:
%macro DirExist(dir) ; %sysfunc(filename(fileref,&dir)) %mend DirExist;
Here the use of macro is simply a wrapper to hide the use of %sysfunc. --Don Henderson 01:51, 17 January 2011 (UTC)
In this final case the parameter could be a file as well as a directory.