Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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> SAS Macros </h4>
12
13 @param [in] 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;
28data _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');
33run;
34%if &type ne Document %then %do;
35 %put %str(WARN)ING: No Document found at &target;
36 %return;
37%end;
38
39filename __in temp lrecl=10000;
40filename __out temp lrecl=10000;
41data _null_ ;
42 file __in ;
43 put "<DeleteMetadata><Metadata><Document Id='&stpuri'/>";
44 put "</Metadata><NS>SAS</NS><Flags>268436480</Flags><Options/>";
45 put "</DeleteMetadata>";
46run ;
47proc metadata in=__in out=__out verbose;run;
48
49/* list the result */
50data _null_;infile __out; input; list; run;
51
52filename __in clear;
53filename __out clear;
54
55/**
56 * Check deletion
57 */
58%local isgone;
59data _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');
64run;
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 mm_deletedocument;