Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mm_deletestp.sas
Go to the documentation of this file.
1 /**
2  @file mm_deletestp.sas
3  @brief Deletes a Stored Process using path as reference
4  @details Will only delete the metadata, not any physical files associated.
5 
6  Usage:
7 
8  %mm_deletestp(target=/some/meta/path/myStoredProcess)
9 
10  <h4> Dependencies </h4>
11 
12  @param target= full path to the STP being deleted
13 
14  @version 9.4
15  @author Allan Bowe
16 
17 **/
18 
19 %macro mm_deletestp(
20  target=
21 )/*/STORE SOURCE*/;
22 
23 /**
24  * Check STP does exist
25  */
26 %local cmtype;
27 data _null_;
28  length type uri $256;
29  rc=metadata_pathobj("","&target",'StoredProcess',type,uri);
30  call symputx('cmtype',type,'l');
31  call symputx('stpuri',uri,'l');
32 run;
33 %if &cmtype ne ClassifierMap %then %do;
34  %put NOTE: No Stored Process found at &target;
35  %return;
36 %end;
37 
38 filename __in temp lrecl=10000;
39 filename __out temp lrecl=10000;
40 data _null_ ;
41  file __in ;
42  put "<DeleteMetadata><Metadata><ClassifierMap Id='&stpuri'/>";
43  put "</Metadata><NS>SAS</NS><Flags>268436480</Flags><Options/>";
44  put "</DeleteMetadata>";
45 run ;
46 proc metadata in=__in out=__out verbose;run;
47 
48 /* list the result */
49 data _null_;infile __out; input; list; run;
50 
51 filename __in clear;
52 filename __out clear;
53 
54 /**
55  * Check deletion
56  */
57 %local isgone;
58 data _null_;
59  length type uri $256;
60  call missing (of _all_);
61  rc=metadata_pathobj("","&target",'Note',type,uri);
62  call symputx('isgone',type,'l');
63 run;
64 %if &isgone = ClassifierMap %then %do;
65  %put %str(ERR)OR: STP not deleted from &target;
66  %let syscc=4;
67  %return;
68 %end;
69 
70 %mend;