Loading...
Searching...
No Matches
exportconfig.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Downloads zip file of DC customer configurations
4 @details Zip contains several excel files, containing the customer specific
5 (non-DC) configurations. Useful when migrating to a new instance of
6 Data Controller.
7
8
9 <h4> SAS Macros </h4>
10 @li mf_getuser.sas
11 @li mf_nobs.sas
12 @li mp_abort.sas
13 @li mp_binarycopy.sas
14 @li mp_ds2cards.sas
15 @li mp_ds2csv.sas
16 @li mp_streamfile.sas
17 @li mp_validatecol.sas
18
19 @author 4GL Apps Ltd
20 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
21 and may not be re-distributed or re-sold without the express permission of
22 4GL Apps Ltd.
23
24**/
25
26%global dclib islib newlib;
27%mpeinit()
28
29data _null_;
30 newlib=coalescec(symget('dclib'),"&mpelib");
31 %mp_validatecol(newlib,ISLIB,islib)
32 call symputx('islib',islib);
33 call symputx('newlib',upcase(newlib));
34 putlog (_all_)(=);
35run;
36
37%mp_abort(iftrue= (&islib ne 1)
38 ,mac=&_program
39 ,msg=%nrstr(&newlib is not a valid libref)
40)
41
42%let work=%sysfunc(pathname(work));
43%let mime=application/csv;
44%let dbms=CSV;
45%let ext=csv;
46
47%macro conditional_export(ds);
48%if %mf_nobs(&ds)>0 %then %do;
49 /* cannot use PROC EXPORT as we need to wrap all csv char values in quotes */
50 /* cannot use excel as it does not work consistently in all SAS envs */
51 %mp_ds2csv(&ds,outfile="&work/&newlib..&ds..csv",headerformat=NAME)
52 ods package(ProdOutput) add file="&work/&newlib..&ds..&ext" mimetype="&mime";
53%end;
54%mp_abort(iftrue= (&syscc ne 0)
55 ,mac=&_program
56 ,msg=%nrstr(syscc=&syscc after &ds prep)
57)
58%mend conditional_export;
59
60
61ods package(ProdOutput) open nopf;
62
63data MPE_ALERTS;
64 set &mpelib..MPE_ALERTS;
65 where &dc_dttmtfmt. le tx_to;
66 drop tx_: ;
67 if alert_lib="&mpelib" then alert_lib="&newlib";
68run;
69%conditional_export(MPE_ALERTS)
70
71
72data MPE_COLUMN_LEVEL_SECURITY;
73 set &mpelib..MPE_COLUMN_LEVEL_SECURITY;
74 where &dc_dttmtfmt. le tx_to;
75 where also CLS_LIBREF ne "&mpelib";
76 drop tx_: ;
77 CLS_LIBREF="&newlib";
78run;
79%conditional_export(MPE_COLUMN_LEVEL_SECURITY)
80
81data MPE_CONFIG;
82 set &mpelib..MPE_CONFIG;
83 where &dc_dttmtfmt. le tx_to;
84 drop tx_: ;
85 if var_name='DC_MACROS' then var_value=tranwrd(var_value,"&mpelib","&newlib");
86run;
87%conditional_export(MPE_CONFIG)
88
89data MPE_DATADICTIONARY;
90 set &mpelib..MPE_DATADICTIONARY;
91 where &dc_dttmtfmt. le tx_to;
92 drop tx_: ;
93 if DD_SOURCE=:"&mpelib" then do;
94 /* nothing */
95 end;
96 else output;
97run;
98%conditional_export(MPE_DATADICTIONARY)
99
100data MPE_EMAILS;
101 set &mpelib..MPE_EMAILS;
102 where &dc_dttmtfmt. le tx_to;
103 drop tx_: ;
104run;
105%conditional_export(MPE_EMAILS)
106
107data MPE_EXCEL_CONFIG;
108 set &mpelib..MPE_EXCEL_CONFIG;
109 where &dc_dttmtfmt. le tx_to;
110 drop tx_: ;
111 if xl_libref="&mpelib" then xl_libref="&newlib";
112run;
113%conditional_export(MPE_EXCEL_CONFIG)
114
115data MPE_GROUPS;
116 set &mpelib..MPE_GROUPS;
117 where &dc_dttmtfmt. le tx_to;
118 drop tx_: ;
119run;
120%conditional_export(MPE_GROUPS)
121
122data MPE_ROW_LEVEL_SECURITY;
123 set &mpelib..MPE_ROW_LEVEL_SECURITY;
124 where &dc_dttmtfmt. le tx_to;
125 drop tx_: ;
126 if rls_libref="&mpelib" then rls_libref="&newlib";
127run;
128%conditional_export(MPE_ROW_LEVEL_SECURITY)
129
130
131data MPE_SECURITY;
132 set &mpelib..MPE_SECURITY;
133 where &dc_dttmtfmt. le TX_TO;
134 drop tx_: ;
135 if libref="&mpelib" then libref="&newlib";
136run;
137%conditional_export(MPE_SECURITY)
138
139data MPE_SELECTBOX;
140 set &mpelib..MPE_SELECTBOX;
141 where &dc_dttmtfmt. le ver_to_dttm;
142 where also select_lib ne "&mpelib";
143 drop ver_: selectbox_rk;
144run;
145%conditional_export(MPE_SELECTBOX)
146
147data MPE_TABLES;
148 set &mpelib..MPE_TABLES;
149 where &dc_dttmtfmt. le TX_TO;
150 where also LIBREF ne "&mpelib";
151 drop tx_: ;
152run;
153%conditional_export(MPE_TABLES)
154
155data MPE_VALIDATIONS;
156 set &mpelib..MPE_VALIDATIONS;
157 where &dc_dttmtfmt. le TX_TO;
158 where also BASE_LIB ne "&mpelib";
159 drop tx_: ;
160run;
161%conditional_export(MPE_VALIDATIONS)
162
163data MPE_XLMAP_INFO;
164 set &mpelib..MPE_XLMAP_INFO;
165 where &dc_dttmtfmt. le TX_TO;
166 drop tx_: ;
167 if XLMAP_TARGETLIBDS=:"&mpelib.." then
168 XLMAP_TARGETLIBDS=tranwrd(XLMAP_TARGETLIBDS,"&mpelib..","&newlib..");
169run;
170%conditional_export(MPE_XLMAP_INFO)
171
172data MPE_XLMAP_RULES;
173 set &mpelib..MPE_XLMAP_RULES;
174 where &dc_dttmtfmt. le TX_TO;
175 drop tx_: ;
176run;
177%conditional_export(MPE_XLMAP_RULES)
178
179
180/* finish up zip file */
181ods package(ProdOutput) publish archive properties
182 (archive_name="DCBACKUP.zip" archive_path="&work");
183ods package(ProdOutput) close;
184
185%mp_abort(iftrue= (&syscc ne 0)
186 ,mac=&_program..sas
187 ,msg=%nrstr(syscc=&syscc after zip prep)
188)
189
190/* now serve zip file to client */
191%mp_streamfile(contenttype=ZIP
192 ,inloc=%str(&work/DCBACKUP.zip)
193 ,outname=DCBACKUP.zip
194)