Published on :
Administration INTERNAL_CREATION

Extracting Extended Library Attributes via Metadata

This code is also available in: Deutsch Français
Awaiting validation
Attention : This code requires administrator privileges.
This program configures a connection to a SAS© metadata server (SAS© 9 architecture) and uses metadata interface functions to search for a library (by default 'Visual Analytics LASR'). It then iterates over the extensions defined for this library to create a table containing the name/value pairs of these attributes. Note: This code is specific to interoperability with SAS© 9 or legacy environments, as native SAS© Viya does not use this type of metadata server.
Data Analysis

Type : INTERNAL_CREATION


Data is generated via calls to metadata system functions (metadata_resolve, metadata_getnasn) without reading external tables.

1 Code Block
MACRO VARIABLE
Explanation :
Definition of the target library name.
Copied!
1%let LIBNAME='Visual Analytics LASR';
2 Code Block
OPTIONS
Explanation :
Configuration of SAS 9 metadata server connection parameters (contains sensitive information/credentials).
Copied!
1options
2 metaserver="meta.demo.sas.com"
3 metaport=8561
4 metauser="sasadm @saspw"
5 metapass="password"
6 metarepository=Foundation
7 metaprotocol=bridge;
3 Code Block
DATA STEP Data
Explanation :
Data Step performing the main logic: searching for the library object via a metadata XML query, looping over found objects, extracting associated extensions, and writing to the 'extend' output table.
Copied!
1DATA extend;
2 LENGTH type id lib_uri ext_uri ext_name $ 50 ext_val $ 256;
3 call missing(of _CHARACTER_);
4 
5 obj="omsobj:SASLibrary? @Name=&libname";
6 
7 libcount=metadata_resolve(obj,type,id);
8 IF libcount > 0 THEN DO n=1 to libcount;
9 rc=metadata_getnobj(obj,n,lib_uri);
10 ext_count=metadata_getnasn(lib_uri,"Extensions",1,ext_uri);
11 
12 IF ext_count > 0 THEN DO m=1 to ext_count;
13 rc=metadata_getnasn(lib_uri,"Extensions",m,ext_uri);
14 rc=metadata_getattr(ext_uri,"Name",ext_name);
15 rc=metadata_getattr(ext_uri,"Value",ext_val);
16 OUTPUT;
17 END; ELSE put "NOTE: No Extended Attributes found for library &libname";
18 END;
19 ELSE put "NOTE: No library &libname found.";
20 
21 keep ext_name ext_val;
22RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 16MAY2017