Did you ever encountered with an issue where you need to check the existence of a directory with a SAS code. Here is the code which let you do the same.
If directory exists macro will return 1 else 0.
If directory exists macro will return 1 else 0.
%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(Test);
No comments:
Post a Comment