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.
Tips Talk:Check if a directory exists
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;
It's true! Thanks! --Adrien VALLEE 13:57, 10 January 2011 (UTC)
Since the return values are 0/1, why not simplify as follows:
%macro DirExist(dir) ; %sysfunc(filename(fileref,&dir)) %mend DirExist;
And point out that this use of macro is simply a wrapper to hide the use of %sysfunc. --Don Henderson 01:51, 17 January 2011 (UTC)
This does not differentiate between a directory and a file. It will return 1 if a file of the specified name exists. -- Jon Williamson 15 Apr 2014
- Correct, but since the filename and the doc emphasize that use, the point of this tip is to highlight that it works for directories as well.--Don Henderson (talk) 06:52, 22 April 2014 (CDT)