Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mfv_getcaslib.sas
Go to the documentation of this file.
1/**
2 @file mfv_getcaslib.sas
3 @brief Returns the CAS caslib name for a given SAS libref
4 @details Pure macro function. Reads sashelp.vlibnam and returns
5 the sysvalue where sysname='Caslib' for the given libref. This
6 is useful when the caslib name and libref name may differ.
7
8 Usage:
9
10 %put %mfv_getcaslib(lib=PUBLIC);
11
12 @param [in] lib SAS libref for which to return the CAS caslib name
13
14 @return Returns the CAS caslib name, or empty string if not found
15
16**/
17
18%macro mfv_getcaslib(lib);
19
20%local dsid rc result;
21
22%let dsid=%sysfunc(open(sashelp.vlibnam(
23 where=(libname="%upcase(&lib)" and sysname="Caslib")
24)));
25
26%if &dsid %then %do;
27 %let rc=%sysfunc(fetch(&dsid));
28 %if &rc=0 %then
29 %let result=%sysfunc(
30 getvarc(&dsid,%sysfunc(varnum(&dsid,SYSVALUE)))
31 );
32 %let rc=%sysfunc(close(&dsid));
33%end;
34
35&result
36
37%mend mfv_getcaslib;