Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_dictionary.sas
Go to the documentation of this file.
1/**
2 @file mp_dictionary.sas
3 @brief Creates a portal (libref) into the SQL Dictionary Views
4 @details Provide a libref and the macro will create a series of views against
5 each view in the special PROC SQL dictionary libref.
6
7 This is useful if you would like to visualise (navigate) the views in a SAS
8 client such as Base SAS, Enterprise Guide, or Studio (or [Data Controller](
9 https://datacontroller.io)).
10
11 It works by extracting the dictionary.dictionaries view into
12 YOURLIB.dictionaries, then uses that to create a YOURLIB.{viewName} for every
13 other dictionary.view, eg:
14
15 proc sql;
16 create view YOURLIB.columns as select * from dictionary.columns;
17
18 Usage:
19
20 libname demo "/lib/directory";
21 %mp_dictionary(lib=demo)
22
23 Or, to just create them in WORK:
24
25 %mp_dictionary()
26
27 If you'd just like to browse the dictionary data model, you can also check
28 out [this article](https://rawsas.com/dictionary-of-dictionaries/).
29
30 ![](https://user-images.githubusercontent.com/4420615/188278365-2987db97-0594-4a39-ac81-dbacdef5cdc8.png)
31
32 @param [in] lib= (WORK) The libref in which to create the views
33
34 <h4> Related Files </h4>
35 @li mp_dictionary.test.sas
36
37 @version 9.2
38 @author Allan Bowe
39
40**/
41
42%macro mp_dictionary(lib=WORK)/*/STORE SOURCE*/;
43 %local list i mem;
44 proc sql noprint;
45 create view &lib..dictionaries as select * from dictionary.dictionaries;
46 select distinct memname into: list separated by ' ' from &lib..dictionaries;
47 %do i=1 %to %sysfunc(countw(&list,%str( )));
48 %let mem=%scan(&list,&i,%str( ));
49 create view &lib..&mem as select * from dictionary.&mem;
50 %end;
51 quit;
52%mend mp_dictionary;