Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mf_getengine.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns the engine type of a SAS library
4 @details Usage:
5
6 %put %mf_getengine(SASHELP);
7
8 returns:
9 > V9
10
11 A note is also written to the log. The credit for this macro goes to the
12 contributors of Chris Hemedingers blog [post](
13 http://blogs.sas.com/content/sasdummy/2013/06/04/find-a-sas-library-engine/)
14
15 @param libref Library reference (also accepts a 2 level libds ref).
16
17 @return output returns the library engine for the FIRST library encountered.
18
19 @warning will only return the FIRST library engine - for concatenated
20 libraries, with different engines, inconsistent results may be encountered.
21
22 @version 9.2
23 @author Allan Bowe
24
25 <h4> Related Macros </h4>
26 @li mf_getxengine.sas
27
28**/
29/** @cond */
30
31%macro mf_getengine(libref
32)/*/STORE SOURCE*/;
33 %local dsid engnum rc engine;
34
35 /* in case the parameter is a libref.tablename, pull off just the libref */
36 %let libref = %upcase(%scan(&libref, 1, %str(.)));
37
38 %let dsid=%sysfunc(
39 open(sashelp.vlibnam(where=(libname="%upcase(&libref)")),i)
40 );
41 %if (&dsid ^= 0) %then %do;
42 %let engnum=%sysfunc(varnum(&dsid,ENGINE));
43 %let rc=%sysfunc(fetch(&dsid));
44 %let engine=%sysfunc(getvarc(&dsid,&engnum));
45 %put &libref. ENGINE is &engine.;
46 %let rc= %sysfunc(close(&dsid));
47 %end;
48
49 &engine
50
51%mend mf_getengine;
52
53/** @endcond */