Production Ready 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
73
74data &outds ;
75 set &outds(rename=(treeuri=treeuri_compare));
76 length treeuri query stpuri $256;
77 i+1;
78%if %length(&name)>0 %then %do;
79 query="omsobj:ClassifierMap?@PublicType='StoredProcess' and @Name='&name'";
80 putlog query=;
81%end;
82%else %do;
83 query="omsobj:ClassifierMap?@PublicType='StoredProcess'";
84%end;
85%if &mDebug=1 %then %do;
86 putlog 'start' (_all_)(=);
87%end;
88 do while(0<metadata_getnobj(query,i,stpuri));
89 i+1;
90 rc1=metadata_getattr(stpuri,"Name", stpname);
91 rc2=metadata_getnasn(stpuri,"Trees",1,treeuri);
92 %if %length(&tree)>0 %then %do;
93 if treeuri ne treeuri_compare then goto exitloop;
94 %end;
95 %if %length(&showDesc)>0 %then %do;
96 rc3=metadata_getattr(stpuri,"Desc", stpdesc);
97 keep stpdesc;
98 %end;
99 %if %length(&showUsageVersion)>0 %then %do;
100 rc4=metadata_getattr(stpuri,"UsageVersion",UsageVersion);
101 keep usageversion;
102 %end;
103 output;
104 &mD.put (_all_)(=);
105 exitloop:
106 end;
107 keep stpuri stpname treeuri;
108run;
109
110%mend mm_getstps;