Production Ready Macros for SAS Application Developers
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> Dependencies </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  @showDesc= provide a non blank value to return stored process descriptions
27  @showUsageVersion= provide a non blank value to return the UsageVersion. This
28  is either 1000000 (type 1, 9.2) or 2000000 (type2, 9.3 onwards).
29 
30  @returns outds dataset containing the following columns
31  - stpuri
32  - stpname
33  - treeuri
34  - stpdesc (if requested)
35  - usageversion (if requested)
36 
37  @version 9.2
38  @author Allan Bowe
39 
40 **/
41 
42 %macro mm_getstps(
43  tree=
44  ,name=
45  ,outds=work.mm_getstps
46  ,mDebug=0
47  ,showDesc=
48  ,showUsageVersion=
49 )/*/STORE SOURCE*/;
50 
51 %local mD;
52 %if &mDebug=1 %then %let mD=;
53 %else %let mD=%str(*);
54 %&mD.put Executing mm_getstps.sas;
55 %&mD.put _local_;
56 
57 data &outds;
58  length stpuri stpname usageversion treeuri stpdesc $256;
59  call missing (of _all_);
60 run;
61 
62 %if %length(&tree)>0 %then %do;
63  /* get tree info */
64  %mm_gettree(tree=&tree,inds=&outds, outds=&outds, mDebug=&mDebug)
65  %if %mf_nobs(&outds)=0 %then %do;
66  %put NOTE: Tree &tree did not exist!!;
67  %return;
68  %end;
69 %end;
70 
71 
72 
73 data &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;
107 run;
108 
109 %mend;