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