Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mmx_spkexport.sas
Go to the documentation of this file.
1/**
2 @file mmx_spkexport.sas
3 @brief Exports everything in a particular metadata folder
4 @details Will export everything in a metadata folder to a specified location.
5 Note - the batch tools require a username and password. For security,
6 these are expected to have been provided in a protected directory.
7
8Usage:
9
10 %* import the macros (or make them available some other way);
11 filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
12 %inc mc;
13
14 %* create sample text file as input to the macro;
15 filename tmp temp;
16 data _null_;
17 file tmp;
18 put '%let mmxuser=sasdemo;';
19 put '%let mmxpass=Mars321';
20 run;
21
22 filename outref "%sysfunc(pathname(work))";
23 %mmx_spkexport(
24 metaloc=%str(/30.Projects/3001.Internal/300115.DataController/dc1)
25 ,secureref=tmp
26 ,outspkpath=%str(/tmp)
27 )
28
29 <h4> SAS Macros </h4>
30 @li mf_loc.sas
31 @li mm_tree.sas
32 @li mf_getuniquefileref.sas
33 @li mp_abort.sas
34
35 @param [in] metaloc= the metadata folder to export
36 @param [in] secureref= () fileref containing the username / password
37 (should point to a file in a secure location)
38 @param [in] outspkname= name of the spk to be created (default is mmxport).
39 @param [in] outspkpath= ((%sysfunc(pathname(WORK)))
40 directory in which to create the SPK.
41
42 @version 9.4
43 @author Allan Bowe
44
45**/
46
47%macro mmx_spkexport(metaloc=
48 ,secureref=
49 ,outspkname=mmxport
50 ,outspkpath=%sysfunc(pathname(work))
51);
52
53%local host port platform_object_path connx_string;
54%let host=%sysfunc(getoption(metaserver));
55%let port=%sysfunc(getoption(metaport));
56%let platform_object_path=%mf_loc(POF);
57
58/* get creds */
59%inc &secureref/nosource;
60
61%let connx_string=
62 %str(-host &host -port &port -user '&mmxuser' -password '&mmxpass');
63
64%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=exportable)
65
66%local fref1;
67%let fref1=%mf_getuniquefileref();
68data ;
69 set exportable end=last;
70 file &fref1 lrecl=32767;
71 length str $32767;
72 if _n_=1 then do;
73 put 'data _null_;';
74 put 'infile "cd ""&platform_object_path"" %trim(';
75 put ') cd ""&platform_object_path"" %trim(';
76 put '); ./ExportPackage &connx_string -disableX11 %trim(';
77 put ') -package ""&outspkpath/&outspkname..spk"" %trim(';
78 end;
79 str=') -objects '!!cats('""',path,'/',name,"(",publictype,')"" %trim(');
80 put str;
81 if last then do;
82 put ') -log ""&outspkpath/&outspkname..log"" 2>&1" pipe lrecl=10000;';
83 put 'input;putlog _infile_;run;';
84 end;
85run;
86
87%mp_abort(iftrue= (&syscc ne 0)
88 ,mac=&sysmacroname
89 ,msg=%str(syscc=&syscc)
90)
91
92%inc &fref1;
93
94%mend mmx_spkexport;