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