Loading...
Searching...
No Matches
mpe_refreshcatalogs.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Refreshes the data catalog
4 @details Assumes library is already assigned.
5
6 @param [in] etlsource= (0) Defaults to %mf_getuniquename(prefix=refreshcatalogs); it
7 identifies this load in the MPE_DATALOADS audit row.
8
9 Usage:
10
11 %mpe_refreshcatalogs(sashelp)
12
13 <h4> SAS Macros </h4>
14 @li mf_getuniquename.sas
15 @li mp_abort.sas
16 @li bitemporal_dataloader.sas
17
18 @version 9.3
19 @author 4GL Apps Ltd
20
21 @sasjslint {"maxLineLength": 86}
22
23**/
24
25%macro mpe_refreshcatalogs(lib,cat=#all
26 ,etlsource=0
27);
28%let lib=%upcase(&lib);
29%let cat=%upcase(&cat);
30%if "&etlsource"="0" %then %let etlsource=%mf_getuniquename(prefix=refreshcatalogs);
31
32%put running &sysmacroname &lib for &cat;
33proc sql;
34create table work.catdata as
35 select libname as libref,
36 memname,
37 objname,
38 objtype,
39 objdesc,
40 created,
41 modified,
42 alias,
43 level
44 from dictionary.catalogs
45 where upcase(libname)="&lib"
46%if &cat ne #ALL %then %do;
47 and upcase(memname)="&cat"
48%end;
49 ;
50
51%mp_abort(iftrue= (&syscc ne 0)
52 ,mac=&_program
53 ,msg=%str(syscc=&syscc afer &lib objects extraction)
54)
55
56/* load mpe_datacatalog_CATS */
57proc sql;
58create table datacats as select distinct libref,memname from catdata;
59
60%bitemporal_dataloader(base_lib=&mpelib
61 ,base_dsn=mpe_datacatalog_CATS
62 ,append_dsn=datacats
63 ,PK=LIBREF MEMNAME
64 ,etlsource=&etlsource
65 ,loadtype=TXTEMPORAL
66 ,tech_from=TX_FROM
67 ,tech_to=TX_TO
68%if &cat = #ALL %then %do;
69 ,close_vars=LIBREF
70%end;
71 ,dclib=&mpelib
72)
73
74/* load mpe_datacatalog_objsS */
75proc sql;
76create table dataobjs as
77 select distinct libref,
78 memname,
79 objname,
80 objtype,
81 objdesc,
82 alias
83 from catdata;
84quit;
85
86%bitemporal_dataloader(base_lib=&mpelib
87 ,base_dsn=mpe_datacatalog_OBJS
88 ,append_dsn=dataobjs
89 ,PK=LIBREF MEMNAME OBJNAME OBJTYPE
90 ,etlsource=&etlsource
91 ,loadtype=TXTEMPORAL
92 ,tech_from=TX_FROM
93 ,tech_to=TX_TO
94%if &cat = #ALL %then %do;
95 ,close_vars=LIBREF MEMNAME
96%end;
97 ,dclib=&mpelib
98)
99
100%put load mpe_datastatus_OBJS;
101proc sql;
102create table statusobjs as
103 select distinct libref,
104 memname,
105 objname,
106 objtype,
107 created,
108 modified,
109 level
110 from catdata;
111
112%bitemporal_dataloader(base_lib=&mpelib
113 ,base_dsn=mpe_datastatus_OBJS
114 ,append_dsn=statusobjs
115 ,PK=LIBREF MEMNAME OBJNAME OBJTYPE
116 ,etlsource=&etlsource
117 ,loadtype=TXTEMPORAL
118 ,tech_from=TX_FROM
119 ,tech_to=TX_TO
120%if &cat = #ALL %then %do;
121 ,close_vars=LIBREF MEMNAME
122%end;
123 ,dclib=&mpelib
124)
125
126%put load mpe_datastatus_cats;
127proc sql;
128create table statuscats as
129 select libref,
130 memname,
131 count(*) as nobjs,
132 min(created) as created,
133 max(modified) as modified
134 from catdata
135 group by 1,2;
136
137%bitemporal_dataloader(base_lib=&mpelib
138 ,base_dsn=mpe_datastatus_cats
139 ,append_dsn=statuscats
140 ,PK=LIBREF MEMNAME
141 ,etlsource=&etlsource
142 ,loadtype=TXTEMPORAL
143 ,tech_from=TX_FROM
144 ,tech_to=TX_TO
145%if &cat = #ALL %then %do;
146 ,close_vars=LIBREF
147%end;
148 ,dclib=&mpelib
149)
150
151
152%mend mpe_refreshcatalogs;