Example: Data Step View of Libraries Registered in Metadata



This example provides data step code that will query the SAS Metadata and return a list of registered Library References.  The code as-is will create a data step view in the work library, so each time it is accessed it will dynamically query the SAS Metadata.

How to use it

The data step code below assumes that the connection to your Metadata Server has already been configured using the following System Options:

If you are running this code via an IOM client (e.g. Enterprise Guide, DI Studio, etc.) then these options will already be set to the user you have logged into SAS with.  If you are running this code from Base SAS you will need to issue an OPTIONS statement to set them.
Because access to the SAS Metadata requires security authorisation, the list of Libraries returned will be dependent on what the user specified in the METAUSER/METAPASS options can access.


List of Libraries in Metadata



* Purpose: Create a dynamic view of Libraries registered in Metadata
* Notes  : You must establish a Metadata connection prior to running
data work.liblist(drop=_: label="SAS Library List") / view=work.liblist;
  length id $17 _uri _liburi _extensionuri name description libref engine preassigned hidden
    extension_name extension_value _modified _created location _location $256;
  length created modified 8;
  format created modified datetime.;
  label id="Metadata ID"
        name="Library Name"
        location="Folder Location"
        libref="Library Reference"
        preassigned="Pre-Assigned Flag"
        hidden="Hidden Flag"
        extension_count="Extension Count"
        extension_name="Extension Name"
        extension_value="Extension Value"
        modified="Last Modified";
  call missing(id, _uri, _liburi, _extensionuri, name, description, libref, engine, preassigned, hidden, 
       _modified, _created, _location);
  do while(_n le _nobj);
    call missing(extension_name, extension_value, extension_count);
    _nobj=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",_n,_uri);
    * Get folder object the current Library is in *;
    * Get folder name the current Library is in *;
    * Loop up the folder hierarchy *;
    do while (_tree>0);
      * Get the parent folder object *;
      if _tree > 0 then do;
        * If there was a parent folder, get the name *;
        * Construct the path *;
    end* Folder Hierachy *;
    location = '/'||location;
    /* Get extensions */
    do while(_extensionrc>0);
      if (_extensionrc>0then do;
      if (_arc=0then do;
    if _libwithextension=1 then _libwithextension=0;
    else output;
Sample files and code examples are provided by Scorpio Software Services "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that Scorpio Software Services shall not be liable for any damages whatsoever arising out of their use of this material.
Was this article helpful?
1 out of 1 found this helpful


Powered by Zendesk