Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mf_isdir.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Checks whether a path is a valid directory
4  @details
5  Usage:
6 
7  %let isdir=%mf_isdir(/tmp);
8 
9  With thanks and full credit to Andrea Defronzo - https://www.linkedin.com/in/andrea-defronzo-b1a47460/
10 
11  @param path full path of the file/directory to be checked
12 
13  @return output returns 1 if path is a directory, 0 if it is not
14 
15  @version 9.2
16 **/
17 
18 %macro mf_isdir(path
19 )/*/STORE SOURCE*/;
20  %local rc did is_directory fref_t;
21 
22  %let is_directory = 0;
23  %let rc = %sysfunc(filename(fref_t, %superq(path)));
24  %let did = %sysfunc(dopen(&fref_t.));
25  %if &did. ^= 0 %then %do;
26  %let is_directory = 1;
27  %let rc = %sysfunc(dclose(&did.));
28  %end;
29  %let rc = %sysfunc(filename(fref_t));
30 
31  &is_directory
32 
33 %mend;