Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_getconstraints.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_getconstraints.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mf_nobs.sas
7 @li mp_getconstraints.sas
8 @li mp_assert.sas
9 @li mp_assertscope.sas
10
11**/
12
13
14%macro conditional();
15
16%if %sysfunc(exist(sashelp.vcncolu,view))=1 %then %do;
17 proc sql;
18 create table work.example(
19 TX_FROM float format=datetime19.,
20 DD_TYPE char(16),
21 DD_SOURCE char(2048),
22 DD_SHORTDESC char(256),
23 constraint pk primary key(tx_from, dd_type,dd_source),
24 constraint unq unique(tx_from, dd_type),
25 constraint nnn not null(DD_SHORTDESC)
26 );
27 %mp_assertscope(SNAPSHOT)
28 %mp_getconstraints(lib=work,ds=example,outds=work.constraints)
29 %mp_assertscope(COMPARE)
30
31 %mp_assert(
32 iftrue=(%mf_nobs(work.constraints)=6),
33 desc=Output table work.constraints created with correct number of records,
34 outds=work.test_results
35 )
36%end;
37%else %do;
38 proc sql;
39 create table work.example(
40 TX_FROM float format=datetime19.,
41 DD_TYPE char(16),
42 DD_SOURCE char(2048),
43 DD_SHORTDESC char(256)
44 );
45 %mp_assertscope(SNAPSHOT)
46 %mp_getconstraints(lib=work,ds=example,outds=work.constraints)
47 %mp_assertscope(COMPARE)
48
49 %mp_assert(
50 iftrue=(%mf_nobs(work.constraints)=0),
51 desc=Empty table created as constraints not supported,
52 outds=work.test_results
53 )
54%end;
55%mend conditional;
56
57%conditional()