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
**/
23
/** @cond */
24
%macro mf_existfunction(name
25
)
/*/STORE SOURCE*/
;
26
27
%local dsid rc exist;
28
%let dsid=%sysfunc(open(sashelp.vfunc(where=(fncname=
"%upcase(&name)"
))));
29
%let exist=1;
30
%let exist=%sysfunc(fetch(&dsid, NOSET));
31
%let rc=%sysfunc(close(&dsid));
32
33
%sysevalf(0 = &exist)
34
35
%mend mf_existfunction;
36
37
/** @endcond */
base
mf_existfunction.sas
Generated by
1.9.8
For more information visit the
Macro Core library
.