Loading...
Searching...
No Matches
mpe_refreshlibs.sas
Go to the documentation of this file.
1/**
2 @file mpe_refreshlibs.sas
3 @brief Refreshes the library data catalog
4 @details
5
6 <h4> SAS Macros </h4>
7 @li dc_getlibs.sas
8 @li mf_getplatform.sas
9 @li bitemporal_dataloader.sas
10
11 @version 9.3
12 @author 4GL Apps Ltd
13 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
14 and may not be re-distributed or re-sold without the express permission of
15 4GL Apps Ltd.
16
17**/
18
19%macro mpe_refreshlibs(lib=0);
20
21%dc_getlibs(outds=work.mm_getLibs)
22proc sort data=mm_getlibs;
23 by libraryref libraryname;
24run;
25
26data libs0;
27 set mm_getlibs;
28 by libraryref;
29%if &lib ne 0 %then %do;
30 where upcase(libraryref)="%upcase(&lib)";
31%end;
32 if "%mf_getplatform()"="SASMETA" then do;
33 /* note - invalid libraries can result in exception errors. If this happens,
34 configure the dc_viewlib_check variable to NO in Data Controller Settings */
35 rc=libname(libraryref,,'meta',cats('library="',libraryname,'";'));
36 drop rc;
37 if rc ne 0 then do;
38 putlog "NOTE: Library " libraryname " does not exist!!";
39 putlog (_all_) (=);
40 delete;
41 end;
42 end;
43 if not first.libraryref then delete;
44run;
45
46proc sql;
47create table libs1 as
48 select distinct libname
49 ,engine
50 ,path
51 ,level
52 ,sysname
53 ,sysvalue
54 from dictionary.libnames
55 order by libname, level,engine,path;
56
57data libs2;
58 set libs1;
59 length tran $1024;
60 if missing(sysname) then sysname='Missing';
61 select(sysname);
62 when('Access Permission') tran='Permissions';
63 when('Owner Name') tran='Owner';
64 when('Schema/Owner') tran='schema';
65 otherwise tran=sysname;
66 end;
67run;
68
69proc transpose data=libs2 out=libs3;
70by libname level engine path;
71var sysvalue;
72id tran;
73run;
74
75data libs4(rename=(libname=libref));
76 length paths $8192 perms owners schemas $500 permissions owner schema $1024;
77 if _n_=1 then call missing (of _all_);
78 set libs3;
79 by libname;
80 if engine='V9' then engine='BASE';
81 if first.libname then do;
82 retain paths perms owners schemas;
83 paths='('!!quote(trim(path));
84 perms=permissions;
85 owners=owner;
86 schemas=schema;
87 end;
88 else do;
89 paths=trim(paths)!!' '!!quote(trim(path));
90 perms=trim(perms)!!','!!trim(permissions);
91 owners=trim(owners)!!','!!trim(owner);
92 schemas=trim(schemas)!!' '!!trim(schema);
93 end;
94 if last.libname then do;
95 paths=trim(paths)!!')';
96 schemas=cats(schemas);
97 output;
98 end;
99 keep libname engine paths perms owners schemas;
100run;
101
102proc sql;
103create table libs5 as
104 select a.libref
105 ,coalescec(b.engine,a.engine) as engine length=32
106 ,b.libraryname as libname
107 ,a.paths
108 ,a.perms
109 ,a.owners
110 ,a.schemas
111 ,b.libraryid as libid
112 from libs4 a
113 left join libs0 b
114 on upcase(a.libref)=upcase(b.libraryref)
115 where libref not in ('SASWORK','WORK','SASUSER','CASUSER','TEMP','STPSAMP'
116 ,'MAPSGFK');
117
118%bitemporal_dataloader(base_lib=&dc_libref
119 ,base_dsn=MPE_DATACATALOG_LIBS
120 ,append_dsn=libs5
121 ,PK=LIBREF
122 ,etlsource=&_program
123 ,loadtype=TXTEMPORAL
124 ,tech_from=TX_FROM
125 ,tech_to=TX_TO
126 ,dclib=&dc_libref
127)
128
129%mend mpe_refreshlibs;