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