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:Check if a directory exists

From sasCommunity
Jump to: navigation, search


As part of the decommissioning effort for sasCommunity.org this article/tip has been migrated to communities.sas.com.

The new home for this article/tip is Check if a directory exists (https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Check-if-a-directory-exists/m-p/475988#M183)



This macro returns 1 if the specified directory exists, 0 if not. It takes advantage of the fact that the fexist can check for the existence of both directories and files.

%macro DirExist(dir) ; 
   %LOCAL rc fileref return; 
   %let rc = %sysfunc(filename(fileref,&dir)) ; 
   %if %sysfunc(fexist(&fileref))  %then %let return=1;    
   %else %let return=0;
   &return
%mend DirExist;
/* Usage */
option noxwait; /* SAS 8.2 only */
%put %DirExist(C:\Documents and Settings\);
%put %DirExist(aaa);

....read more

....see also

Submitted by Adrien VALLEE. Contact me at my Discussion Page.