Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_existfileref.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Checks whether a fileref exists
4 @details You can probably do without this macro as it is just a one liner.
5 Mainly it is here as a convenient way to remember the syntax!
6
7 @param [in] fref the fileref to detect
8
9 @return output Returns 1 if found and 0 if not found. Note - it is possible
10 that the fileref is found, but the file does not (yet) exist. If you need
11 to test for this, you may as well use the fileref function directly.
12
13 @version 8
14 @author [Allan Bowe](https://www.linkedin.com/in/allanbowe/)
15**/
16
17%macro mf_existfileref(fref
18)/*/STORE SOURCE*/;
19
20 %local rc;
21 %let rc=%sysfunc(fileref(&fref));
22 %if &rc=0 %then %do;
23 1
24 %end;
25 %else %if &rc<0 %then %do;
26 %put &sysmacroname: Fileref &fref exists but the underlying file does not;
27 1
28 %end;
29 %else %do;
30 0
31 %end;
32
33%mend mf_existfileref;