Example: Data Step View of Visual Analytics Reports in Metadata

Follow

Overview

This example provides data step code that will query the SAS Metadata and return a list of Visual Analytics Reports.  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:

  • METASERVER
  • METAPORT
  • METAUSER
  • METAPASS
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.
 

Example

Code

data va_report_list(drop=_: label="SAS VA Report List") / view=va_report_list;
  length id $17 _uri name description _modified _created location _location $256;
  
length created modified 8;
  
format created modified datetime.;
  
label id="Metadata ID"
        name=
"VA Report Name"
        description=
"Description"
        location=
"Folder Location"
        created=
"Created"
        modified=
"Last Modified";
  _nobj=
1;
  _n=
1;
  
call missing(id, _uri, name, description, _modified, _created, _location);

  
do while(_n le _nobj);
    _nobj=metadata_getnobj("omsobj:Transformation?@PublicType='Report.BI'",_n,_uri);
    _rc=metadata_getattr(_uri,"Id",id);
    _rc=metadata_getattr(_uri,"Name",name);
    _rc=metadata_getattr(_uri,"Desc",description);
    _rc=metadata_getattr(_uri,"MetadataCreated",_created);
    _rc=metadata_getattr(_uri,"MetadataUpdated",_modified);

    created=input(_created,
anydtdtm.);
    modified=input(_modified,anydtdtm.);

    
* Get folder object the current Report is in *;
    _rc=metadata_getnasn(_uri,
"Trees",1,_uri);
    * Get folder name the current Report is in *;
    _rc=metadata_getattr(_uri,
"Name",location);
    _tree=1;
    
* Loop up the folder hierarchy *;
    
do while (_tree>0);
      * Get the parent folder object *;
      _tree=metadata_getnasn(_uri,
"ParentTree",1,_uri);
      if _tree > 0 then do;
        
* If there was a parent folder, get the name *;
        _rc=metadata_getattr(_uri,
"Name",_location);
        * Construct the path *;
        location=catx(
'/',_location,location);
      end;
    
end* Folder Hierachy *;

    location = 
'/'||location;

    
output;
    _n=_n+
1;
  
end;
run;
 
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?
0 out of 0 found this helpful

Comments

Powered by Zendesk