Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_existfunction.sas
Go to the documentation of this file.
1
/**
2
@file
3
@brief Checks if a function exists
4
@details Returns 1 if the function exists, else 0. Note that this function
5
can be slow as it needs to open the sashelp.vfuncs table.
6
7
Usage:
8
9
%put %mf_existfunction(CAT);
10
%put %mf_existfunction(DOG);
11
12
Full credit to [Bart](https://sasensei.com/user/305) for the vfunc pointer
13
and the tidy approach for pure macro data set filtering.
14
Check out his [SAS Packages](https://github.com/yabwon/SAS_PACKAGES)
15
framework! Where you can find the same [function](
16
https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionexists-macro
17
).
18
19
@param [in] name function name
20
21
@author Allan Bowe
22
@sasjslint {"maxLineLength": 90}
23
**/
24
/** @cond */
25
%macro mf_existfunction(name
26
)
/*/STORE SOURCE*/
;
27
28
%local dsid rc exist;
29
%let dsid=%sysfunc(open(sashelp.vfunc(where=(fncname=
"%upcase(&name)"
))));
30
%let exist=1;
31
%let exist=%sysfunc(fetch(&dsid, NOSET));
32
%let rc=%sysfunc(close(&dsid));
33
34
%sysevalf(0 = &exist)
35
36
%mend mf_existfunction;
37
38
/** @endcond */
base
mf_existfunction.sas
Generated by
1.15.0
For more information visit the
Macro Core library
.