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_ds2cards.sas
13 @li mp_abort.sas
14 @li mp_binarycopy.sas
15 @li mp_streamfile.sas
16
17 @author 4GL Apps Ltd
18 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
19 and may not be re-distributed or re-sold without the express permission of
20 4GL Apps Ltd.
21
22**/
23
24%mpeinit()
25%let work=%sysfunc(pathname(work));
26
27/* excel does not work in all envs */
28%let mime=application/vnd.ms-excel;
29%let dbms=EXCEL;
30
31%let mime=application/csv;
32%let dbms=CSV;
33%let ext=csv;
34
35%macro conditional_export(ds);
36%if %mf_nobs(&ds)>0 %then %do;
37 PROC EXPORT DATA= &ds OUTFILE= "&work/&ds..&ext"
38 DBMS=&dbms REPLACE;
39 RUN;
40 ods package(ProdOutput) add file="&work/&ds..&ext" mimetype="&mime";
41%end;
42%mp_abort(iftrue= (&syscc ne 0)
43 ,mac=&_program
44 ,msg=%nrstr(syscc=&syscc after &ds prep)
45)
46%mend conditional_export;
47
48
49ods package(ProdOutput) open nopf;
50
51data MPE_ALERTS;
52 set &mpelib..MPE_ALERTS;
53 where &dc_dttmtfmt. le tx_to;
54 drop tx_: ;
55run;
56%conditional_export(MPE_ALERTS)
57
58
59data MPE_COLUMN_LEVEL_SECURITY;
60 set &mpelib..MPE_COLUMN_LEVEL_SECURITY;
61 where &dc_dttmtfmt. le tx_to;
62 where also CLS_LIBREF ne "&mpelib";
63 drop tx_: ;
64run;
65%conditional_export(MPE_COLUMN_LEVEL_SECURITY)
66
67data MPE_CONFIG;
68 set &mpelib..MPE_CONFIG;
69 where &dc_dttmtfmt. le tx_to;
70 drop tx_: ;
71run;
72%conditional_export(MPE_CONFIG)
73
74data MPE_DATADICTIONARY;
75 set &mpelib..MPE_DATADICTIONARY;
76 where &dc_dttmtfmt. le tx_to;
77 drop tx_: ;
78 if DD_SOURCE=:"&mpelib" then do;
79 /* nothing */
80 end;
81 else output;
82run;
83%conditional_export(MPE_DATADICTIONARY)
84
85data MPE_EMAILS;
86 set &mpelib..MPE_EMAILS;
87 where &dc_dttmtfmt. le tx_to;
88 drop tx_: ;
89run;
90%conditional_export(MPE_EMAILS)
91
92data MPE_EXCEL_CONFIG;
93 set &mpelib..MPE_EXCEL_CONFIG;
94 where &dc_dttmtfmt. le tx_to;
95 drop tx_: ;
96run;
97%conditional_export(MPE_EXCEL_CONFIG)
98
99data MPE_GROUPS;
100 set &mpelib..MPE_GROUPS;
101 where &dc_dttmtfmt. le tx_to;
102 drop tx_: ;
103run;
104%conditional_export(MPE_GROUPS)
105
106data MPE_ROW_LEVEL_SECURITY;
107 set &mpelib..MPE_ROW_LEVEL_SECURITY;
108 where &dc_dttmtfmt. le tx_to;
109 drop tx_: ;
110run;
111%conditional_export(MPE_ROW_LEVEL_SECURITY)
112
113
114data MPE_SECURITY;
115 set &mpelib..MPE_SECURITY;
116 where &dc_dttmtfmt. le TX_TO;
117 drop tx_: ;
118run;
119%conditional_export(MPE_SECURITY)
120
121data MPE_SELECTBOX;
122 set &mpelib..MPE_SELECTBOX;
123 where &dc_dttmtfmt. le ver_to_dttm;
124 where also select_lib ne "&mpelib";
125 drop ver_: selectbox_rk;
126run;
127%conditional_export(MPE_SELECTBOX)
128
129data MPE_TABLES;
130 set &mpelib..MPE_TABLES;
131 where &dc_dttmtfmt. le TX_TO;
132 where also LIBREF ne "&mpelib";
133 drop tx_: ;
134run;
135%conditional_export(MPE_TABLES)
136
137data MPE_VALIDATIONS;
138 set &mpelib..MPE_VALIDATIONS;
139 where &dc_dttmtfmt. le TX_TO;
140 where also BASE_LIB ne "&mpelib";
141 drop tx_: ;
142run;
143%conditional_export(MPE_VALIDATIONS)
144
145/* finish up zip file */
146ods package(ProdOutput) publish archive properties
147 (archive_name="DCBACKUP.zip" archive_path="&work");
148ods package(ProdOutput) close;
149
150%mp_abort(iftrue= (&syscc ne 0)
151 ,mac=&_program..sas
152 ,msg=%nrstr(syscc=&syscc after zip prep)
153)
154
155/* now serve zip file to client */
156%mp_streamfile(contenttype=ZIP
157 ,inloc=%str(&work/DCBACKUP.zip)
158 ,outname=DCBACKUP.zip
159)