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 **/ /** \cond */
26 
27 %macro mf_getengine(libref
28 )/*/STORE SOURCE*/;
29  %local dsid engnum rc engine;
30 
31  /* in case the parameter is a libref.tablename, pull off just the libref */
32  %let libref = %upcase(%scan(&libref, 1, %str(.)));
33 
34  %let dsid=%sysfunc(open(sashelp.vlibnam(where=(libname="%upcase(&libref)")),i));
35  %if (&dsid ^= 0) %then %do;
36  %let engnum=%sysfunc(varnum(&dsid,ENGINE));
37  %let rc=%sysfunc(fetch(&dsid));
38  %let engine=%sysfunc(getvarc(&dsid,&engnum));
39  %put &libref. ENGINE is &engine.;
40  %let rc= %sysfunc(close(&dsid));
41  %end;
42 
43  &engine
44 
45 %mend;
46 
47 /** \endcond */