Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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 -
10 https://www.linkedin.com/in/andrea-defronzo-b1a47460/
11
12 @param [in] path Full path of the file/directory to be checked
13
14 @return output returns 1 if path is a directory, 0 if it is not
15
16 @version 9.2
17**/
18
19%macro mf_isdir(path
20)/*/STORE SOURCE*/;
21 %local rc did is_directory fref_t;
22
23 %let is_directory = 0;
24 %let rc = %sysfunc(filename(fref_t, %superq(path)));
25 %let did = %sysfunc(dopen(&fref_t.));
26 %if &did. ^= 0 %then %do;
27 %let is_directory = 1;
28 %let rc = %sysfunc(dclose(&did.));
29 %end;
30 %let rc = %sysfunc(filename(fref_t));
31
32 &is_directory
33
34%mend mf_isdir;