Macros for SAS Application Developers
https://github.com/sasjs/core
mm_getstps.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns a dataset with all Stored Processes, or just those in a
4 particular folder / with a particular name.
5 @details Leave blank to get all stps. Provide a Tree (path or uri) or a
6 name (not case sensitive) to filter that way also.
7 usage:
8
9 %mm_getstps()
10
11 %mm_getstps(name=My STP)
12
13 %mm_getstps(tree=/My Folder/My STPs)
14
15 %mm_getstps(tree=/My Folder/My STPs, name=My STP)
16
17 <h4> SAS Macros </h4>
18 @li mm_gettree.sas
19
20 @param tree= the metadata folder location in which to search. Leave blank
21 for all folders. Does not search subdirectories.
22 @param name= Provide the name of an STP to search for just that one. Can
23 combine with the <code>tree=</code> parameter.
24 @param outds= the dataset to create that contains the list of stps.
25 @param mDebug= set to 1 to show debug messages in the log
26 @param showDesc= provide a non blank value to return stored process
27 descriptions
28 @param showUsageVersion= provide a non blank value to return the UsageVersion.
29 This is either 1000000 (type 1, 9.2) or 2000000 (type2, 9.3 onwards).
30
31 @returns outds dataset containing the following columns
32 - stpuri
33 - stpname
34 - treeuri
35 - stpdesc (if requested)
36 - usageversion (if requested)
37
38 @version 9.2
39 @author Allan Bowe
40
41**/
42
43%macro mm_getstps(
44 tree=
45 ,name=
46 ,outds=work.mm_getstps
47 ,mDebug=0
48 ,showDesc=
49 ,showUsageVersion=
50)/*/STORE SOURCE*/;
51
52%local mD;
53%if &mDebug=1 %then %let mD=;
54%else %let mD=%str(*);
55%&mD.put Executing mm_getstps.sas;
56%&mD.put _local_;
57
58data &outds;
59 length stpuri stpname usageversion treeuri stpdesc $256;
60 call missing (of _all_);
61run;
62
63%if %length(&tree)>0 %then %do;
64 /* get tree info */
65 %mm_gettree(tree=&tree,inds=&outds, outds=&outds, mDebug=&mDebug)
66 %if %mf_nobs(&outds)=0 %then %do;
67 %put NOTE: Tree &tree did not exist!!;
68 %return;
69 %end;
70%end;
71
72
73data &outds ;
74 set &outds(rename=(treeuri=treeuri_compare));
75 length treeuri query stpuri $256;
76 i+1;
77%if %length(&name)>0 %then %do;
78 query="omsobj:ClassifierMap?@PublicType='StoredProcess' and @Name='&name'";
79 putlog query=;
80%end;
81%else %do;
82 query="omsobj:ClassifierMap?@PublicType='StoredProcess'";
83%end;
84%if &mDebug=1 %then %do;
85 putlog 'start' (_all_)(=);
86%end;
87 do while(0<metadata_getnobj(query,i,stpuri));
88 i+1;
89 rc1=metadata_getattr(stpuri,"Name", stpname);
90 rc2=metadata_getnasn(stpuri,"Trees",1,treeuri);
91 %if %length(&tree)>0 %then %do;
92 if treeuri ne treeuri_compare then goto exitloop;
93 %end;
94 %if %length(&showDesc)>0 %then %do;
95 rc3=metadata_getattr(stpuri,"Desc", stpdesc);
96 keep stpdesc;
97 %end;
98 %if %length(&showUsageVersion)>0 %then %do;
99 rc4=metadata_getattr(stpuri,"UsageVersion",UsageVersion);
100 keep usageversion;
101 %end;
102 output;
103 &mD.put (_all_)(=);
104 exitloop:
105 end;
106 keep stpuri stpname treeuri;
107run;
108
109%mend mm_getstps;