Macros for SAS Application Developers
https://github.com/sasjs/core
mp_coretable.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Create the permanent Core tables
4  @details Several macros in the [core](https://github.com/sasjs/core) library
5  make use of permanent tables. To avoid duplication in definitions, this
6  macro provides a central location for managing the corresponding DDL.
7 
8  Note - this macro is likely to be deprecated in future in favour of a
9  dedicated "datamodel" folder (prefix mddl)
10 
11  Any corresponding data would go in a seperate repo, to avoid this one
12  ballooning in size!
13 
14  Example usage:
15 
16  %mp_coretable(LOCKTABLE,libds=work.locktable)
17 
18  @param [in] table_ref The type of table to create. Example values:
19  @li DIFFTABLE
20  @li FILTER_DETAIL
21  @li FILTER_SUMMARY
22  @li LOCKANYTABLE
23  @li MAXKEYTABLE
24  @param [in] libds= (0) The library.dataset reference used to create the table.
25  If not provided, then the DDL is simply printed to the log.
26 
27  <h4> SAS Macros </h4>
28  @li mddl_dc_difftable.sas
29  @li mddl_dc_filterdetail.sas
30  @li mddl_dc_filtersummary.sas
31  @li mddl_dc_locktable.sas
32  @li mddl_dc_maxkeytable.sas
33  @li mf_getuniquename.sas
34 
35  <h4> Related Macros </h4>
36  @li mp_filterstore.sas
37  @li mp_lockanytable.sas
38  @li mp_retainedkey.sas
39  @li mp_storediffs.sas
40  @li mp_stackdiffs.sas
41 
42  @version 9.2
43  @author Allan Bowe
44 
45 **/
46 
47 %macro mp_coretable(table_ref,libds=0
48 )/*/STORE SOURCE*/;
49 %local outds ;
50 %let outds=%sysfunc(ifc(&libds=0,%mf_getuniquename(),&libds));
51 proc sql;
52 %if &table_ref=DIFFTABLE %then %do;
53  %mddl_dc_difftable(libds=&outds)
54 %end;
55 %else %if &table_ref=LOCKTABLE %then %do;
56  %mddl_dc_locktable(libds=&outds)
57 %end;
58 %else %if &table_ref=FILTER_SUMMARY %then %do;
59  %mddl_dc_filtersummary(libds=&outds)
60 %end;
61 %else %if &table_ref=FILTER_DETAIL %then %do;
62  %mddl_dc_filterdetail(libds=&outds)
63 %end;
64 %else %if &table_ref=MAXKEYTABLE %then %do;
65  %mddl_dc_maxkeytable(libds=&outds)
66 %end;
67 
68 %if &libds=0 %then %do;
69  proc sql;
70  describe table &syslast;
71  drop table &syslast;
72 %end;
73 %mend mp_coretable;