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).
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!
data extend;
length type id lib_uri ext_uri ext_name $ 50 ext_val $ 256;
call missing(of _CHARACTER_);
obj="omsobj:SASLibrary? @Name=&libname";
libcount=metadata_resolve(obj,type,id);
if libcount > 0 then do n=1 to libcount;
rc=metadata_getnobj(obj,n,lib_uri);
ext_count=metadata_getnasn(lib_uri,"Extensions",1,ext_uri);
if ext_count > 0 then do m=1 to ext_count;
rc=metadata_getnasn(lib_uri,"Extensions",m,ext_uri);
rc=metadata_getattr(ext_uri,"Name",ext_name);
rc=metadata_getattr(ext_uri,"Value",ext_val);
output;
end; else put "NOTE: No Extended Attributes found for library &libname";
end;
else put "NOTE: No library &libname found.";
keep ext_name ext_val;
run;
1
DATA extend;
2
LENGTH type id lib_uri ext_uri ext_name $ 50 ext_val $ 256;
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;
22
RUN;
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.
« 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. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.