Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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 [in] tree= () the metadata folder location in which to search.
21 Leave blank for all folders. Does not search subdirectories.
22 @param [in] name= Provide the name of an STP to search for just that one. Can
23 combine with the <code>tree=</code> parameter.
24 @param [out] outds= the dataset to create that contains the list of stps.
25 @param [in] mDebug= set to 1 to show debug messages in the log
26 @param [in] showDesc= provide a non blank value to return stored process
27 descriptions
28 @param [in] showUsageVersion= ()
29 Provide a non blank value to return the UsageVersion.
30 This is either 1000000 (type 1, 9.2) or 2000000 (type2, 9.3 onwards).
31
32 @returns outds dataset containing the following columns
33 - stpuri
34 - stpname
35 - treeuri
36 - stpdesc (if requested)
37 - usageversion (if requested)
38
39 @version 9.2
40 @author Allan Bowe
41
42**/
43
44%macro mm_getstps(
45 tree=
46 ,name=
47 ,outds=work.mm_getstps
48 ,mDebug=0
49 ,showDesc=
50 ,showUsageVersion=
51)/*/STORE SOURCE*/;
52
53%local mD;
54%if &mDebug=1 %then %let mD=;
55%else %let mD=%str(*);
56%&mD.put Executing mm_getstps.sas;
57%&mD.put _local_;
58
59data &outds;
60 length stpuri stpname usageversion treeuri stpdesc $256;
61 call missing (of _all_);
62run;
63
64%if %length(&tree)>0 %then %do;
65 /* get tree info */
66 %mm_gettree(tree=&tree,inds=&outds, outds=&outds, mDebug=&mDebug)
67 %if %mf_nobs(&outds)=0 %then %do;
68 %put NOTE: Tree &tree did not exist!!;
69 %return;
70 %end;
71%end;
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;