Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_getdbml.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_getdbml macro
4
5 <h4> SAS Macros </h4>
6 @li mf_mkdir.sas
7 @li mp_getdbml.sas
8 @li mp_assert.sas
9
10**/
11
12%let root=%sysfunc(pathname(work))/dbml;
13%mf_mkdir(&root)
14libname mcdb "&root";
15
16data mcdb.customers;
17 length cust_id 8 cust_name $20;
18 cust_id=1; cust_name='one'; output;
19run;
20
21proc sql;
22 alter table mcdb.customers
23 add constraint pk_customers primary key (cust_id);
24quit;
25
26filename dbmlref "&root/model.dbml";
27
28%mp_getdbml(liblist=mcdb,outref=dbmlref)
29
30%let has_table=0;
31%let has_name=0;
32%let has_project=0;
33
34data _null_;
35 infile dbmlref truncover end=last;
36 input;
37 if index(_infile_,'Table ') > 0 then call symputx('has_table',1,'g');
38 if find(upcase(_infile_),'CUSTOMERS') then call symputx('has_name',1,'g');
39 if index(_infile_,'Project ') > 0 then call symputx('has_project',1,'g');
40run;
41
42%mp_assert(
43 iftrue=(&has_project=1),
44 desc=Checking that the dbml project header is written,
45 outds=work.test_results
46)
47
48%mp_assert(
49 iftrue=(&has_table=1),
50 desc=Checking that a table block is written for the library member,
51 outds=work.test_results
52)
53
54%mp_assert(
55 iftrue=(&has_name=1),
56 desc=Checking that the table name appears in the dbml,
57 outds=work.test_results
58)