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 [in] libref Library reference (also accepts a 2 level libds ref).
16 
17  @return output returns the library engine (uppercase) for the FIRST library
18  encountered.
19 
20  @warning will only return the FIRST library engine - for concatenated
21  libraries, with different engines, inconsistent results may be encountered.
22 
23  @version 9.2
24  @author Allan Bowe
25 
26  <h4> Related Macros </h4>
27  @li mf_getxengine.sas
28 
29 **/
30 /** @cond */
31 
32 %macro mf_getengine(libref
33 )/*/STORE SOURCE*/;
34  %local dsid engnum rc engine;
35 
36  /* in case the parameter is a libref.tablename, pull off just the libref */
37  %let libref = %upcase(%scan(&libref, 1, %str(.)));
38 
39  %let dsid=%sysfunc(
40  open(sashelp.vlibnam(where=(libname="%upcase(&libref)")),i)
41  );
42  %if (&dsid ^= 0) %then %do;
43  %let engnum=%sysfunc(varnum(&dsid,ENGINE));
44  %let rc=%sysfunc(fetch(&dsid));
45  %let engine=%sysfunc(getvarc(&dsid,&engnum));
46  %put &libref. ENGINE is &engine.;
47  %let rc= %sysfunc(close(&dsid));
48  %end;
49 
50  %upcase(&engine)
51 
52 %mend mf_getengine;
53 
54 /** @endcond */