Published on :

Extracting Stored Process Prompts (Metadata API)

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
This program uses SAS© Metadata Interface Functions to list all registered 'StoredProcess' objects. It then navigates the XML structure of the metadata to identify associated prompt groups and extract the names of individual prompts. Important note: This code is designed for the SAS© 9 architecture (using a metadata server). On SAS© Viya, it will only work if configured to connect to a remote SAS© 9 metadata server via the BRIDGE protocol, as Viya no longer uses a metadata server for its own content.
Data Analysis

Type : EXTERNE


Querying the SAS Metadata Server via metadata_resolve, metadata_getnobj, etc. functions.

1 Code Block
OPTIONS
Explanation :
Configuration of SAS 9 metadata server connection options. The <hostname> and <password> values must be replaced.
Copied!
1options
2 metaserver="<hostname>"
3 metaport=8561
4 metauser="sasadm @saspw"
5 metapass="<password>"
6 metarepository=Foundation
7 metaprotocol=BRIDGE;
2 Code Block
DATA STEP Data
Explanation :
This Data Step iterates through metadata objects. It first resolves the query to find 'StoredProcess' objects, then loops through each process to retrieve its name and follow the 'Prompts' association to list the input parameters.
Copied!
1DATA work.prompts;
2 
3 /* define and initialize variables */
4 
5 LENGTH
6 type $ 13
7 id $ 17
8 stp_uri $ 39
9 stp_name $ 255
10 pge_uri $ 37
11 p_uri $ 50
12 p_name $ 50
13 ;
14 
15 call missing(type,id,stp_uri,stp_name,pge_uri,p_uri,p_name);
16 
17 /* Query definition: ClassifierMap of type "StoredProcess" */
18 
19 stp_obj="omsobj:ClassifierMap?ClassifierMap[ @PublicType='StoredProcess']";
20 
21 /* Count the number of stored processes defined in Metadata. */
22 
23 stp_count=metadata_resolve(stp_obj,type,id);
24 
25 put "Found " stp_count "Stored Processes.";
26 
27 IF stp_count > 0 THEN DO n=1 to stp_count;
28 
29 rc1=metadata_getnobj(stp_obj,n,stp_uri);
30 /* Get the name of the stored process. */
31 rc2=metadata_getattr(stp_uri,"Name",stp_name);
32 /* Get the stored process' associated embedded prompt group. */
33 rc3=metadata_getnasn(stp_uri,"Prompts",1,pge_uri);
34 /* Count the number of prompts in that prompt group. */
35 prompt_count=metadata_getnasn(pge_uri,"ReferencedPrompts",1,p_uri);
36 /* If any prompts are in the group, pull the name of them. */
37 IF prompt_count > 0 THEN DO m=1 to prompt_count;
38 rc4=metadata_getnasn(pge_uri,"ReferencedPrompts",m,p_uri);
39 rc5=metadata_getattr(p_uri,"Name",p_name);
40 OUTPUT;
41 END;
42 ELSE put "No prompts found, nothing to do.";
43 END;
44 ELSE put "No stored processes found, nothing to do.";
45 keep stp_name p_name;
46RUN;
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 : Author: Greg Wootton Date: 10JAN2017