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