Published on :
Administration INTERNAL_CREATION

Extraction of Stored Process Source Paths (SAS 9 Metadata)

This code is also available in: Español Français
Awaiting validation
Attention : This code requires administrator privileges.
This program connects to a SAS© 9 metadata server via META* options. It uses metadata interface functions (metadata_resolve, metadata_getattr, etc.) to search for all 'Stored Processes' defined with external source code (physical file). It then retrieves the process name, file name, and associated directory to construct and store the full path in an output table. This code is specific to the SAS© 9 architecture and is not native to the SAS© Viya architecture (which no longer uses this type of metadata server), except in migration or bridging contexts.
Data Analysis

Type : INTERNAL_CREATION


Data is dynamically generated by querying the metadata server via SAS system functions (metadata_*).

1 Code Block
OPTIONS
Explanation :
Configuration of the SAS 9 metadata server connection (address, port, credentials, repository).
Copied!
1options metaserver="meta.demo.sas.com"
2 metaport=8561
3 metauser="sasadm @saspw"
4 metapass="password"
5 metarepository=Foundation
6 metaprotocol=bridge;
2 Code Block
DATA STEP Data
Explanation :
Main DATA step that queries metadata to find 'StoredProcess' objects with 'File' type source code. It iterates over the results to extract name and path attributes, concatenating the directory and file name.
Copied!
1DATA SOURCE;
2 
3 keep stp_name SOURCE; /* Retain only the stored process name and it's source code full path. */
4 
5/* Initialize variables. */
6 
7 LENGTH type id stp_uri stp_name file_uri file_name dir_uri path $ 50;
8 call missing (of _character_);
9 
10 obj="omsobj:ClassifierMap?ClassifierMap[ @PublicType='StoredProcess'][SourceCode/File]"; /* Search critera for Stored Processes that have an external file source. */
11 
12 stp_count=metadata_resolve(obj,type,id); /* Count all stored processes that meet our criteria. Only run loop if at least one exists. */
13 
14 IF stp_count > 0 THEN DO i=1 to stp_count; /* Loop: For each stp found, get attributes and associations. */
15 rc=metadata_getnobj(obj,i,stp_uri);
16 rc=metadata_getattr(stp_uri,"Name",stp_name); /* Get stp name. */
17 rc=metadata_getnasn(stp_uri,"SourceCode",1,file_uri); /* Get file Metadata object id. */
18 rc=metadata_getattr(file_uri,"FileName",file_name); /* Get file name. */
19 rc=metadata_getnasn(file_uri,"Directories",1,dir_uri); /* Get directory Metadata object id. */
20 rc=metadata_getattr(dir_uri,"DirectoryName",path); /* Get path to directory. */
21 SOURCE=catx('/',path,file_name); /* combine directory path and file name to create full path to file.*/
22 OUTPUT;
23 END; /* End loop. */
24 ELSE put "WARN: No Stored Processes with external source code files found in Metadata."; /* If no jobs are found, write a message to the log. */
25RUN;
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.