Published on :
Administration CREATION_INTERNE

Extracting extended library attributes (SAS 9 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© 9 Metadata Server (host, port, user, password) to search for a specific library (by default 'Visual Analytics LASR'). It uses metadata system functions (metadata_resolve, metadata_getnasn) to iterate over extended attributes and save them into a SAS© table. Important note: This code is specifically designed for the SAS© 9.x architecture (LASR, Metadata Server) and is not standard for a native SAS© Viya 4 architecture, although it can execute if a bridge to a SAS© 9 Metadata Server is accessible.
Data Analysis

Type : CREATION_INTERNE


Data is dynamically generated by querying the Metadata Server via SAS functions, without reading flat files or external tables.

1 Code Block
OPTIONS
Explanation :
Definition of the macro variable containing the target library name and configuration of global options for connecting to the Metadata Server (authentication and server location).
Copied!
1%let LIBNAME='Visual Analytics LASR';
2 
3options
4 metaserver="meta.demo.sas.com"
5 metaport=8561
6 metauser="sasadm @saspw"
7 metapass="password"
8 metarepository=Foundation
9 metaprotocol=bridge;
2 Code Block
DATA STEP Data
Explanation :
DATA step that queries the Metadata Server to locate the 'SASLibrary' object. If found, it loops through the associated extensions (extended attributes), extracts their names and values, and writes them to the output table 'extend'.
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 : Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. SPDX-License-Identifier: Apache-2.0


Banner
Expert Advice
Expert
Stéphanie
Spécialiste Machine Learning et IA.
« Extracting extended attributes is a critical step for auditing or migrating complex SAS 9.4 environments, particularly for LASR libraries where vital parameters—such as server ports or startup options—are stored as Name/Value pairs within the metadata. The key to this technique is navigating the "Extensions" association using the metadata_getnasn function to drill down into the SASLibrary object. As a best practice, always initialize your variables and check the return code (rc) of metadata_getattr to ensure the attribute exists, preventing residual values from the Program Data Vector (PDV) from corrupting your output table. »