Loading...
Searching...
No Matches
mpe_filtermaster.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief setup mpe_filtermaster macro test
4 @details requires some filter rks, so step 1 is to trigger the validatefilter
5 STP
6
7 <h4> SAS Macros </h4>
8 @li mp_abort.sas
9 @li mp_assertdsobs.sas
10 @li mpe_filtermaster.sas
11 @li mp_filterstore.sas
12
13 @author 4GL Apps Ltd
14 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
15 and may not be re-distributed or re-sold without the express permission of
16 4GL Apps Ltd.
17
18**/
19/*
20proc printto log="/tmp/dcviya/%scan(&_program,-1,/)_%sysfunc(datetime()).log";
21run;
22*/
23
24/**
25 * STEP 1 - first, make filter
26 */
27data work.inquery;
28 infile datalines4 dsd;
29 input GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32.
30 OPERATOR_NM:$10. RAW_VALUE:$4000.;
31datalines4;
32AND,AND,1,LIBREF,CONTAINS,"'DC'"
33AND,OR,2,DSN,=,"'MPE_LOCK_ANYTABLE'"
34;;;;
35run;
36%mp_filterstore(
37 libds=&dc_libref..MPE_TABLES,
38 filter_summary=&dc_libref..mpe_filteranytable,
39 filter_detail=&dc_libref..mpe_filtersource,
40 lock_table=&dc_libref..mpe_lockanytable,
41 maxkeytable=&dc_libref..mpe_maxkeyvalues,
42 queryds=work.inquery,
43 outresult=work.result,
44 outquery=work.query
45)
46data _null_;
47 set work.result;
48 call symputx('filter_rk',filter_rk);
49 putlog (_all_)(=);
50run;
51
52
53/**
54 * begin testing!
55 */
56
57/*
58 Test 1 - Expect 5 records:
59
60 ((
61 LIBREF CONTAINS 'DC'
62 ) AND (
63 DSN = 'MPE_LOCK_ANYTABLE'
64 ))
65
66*/
67%mpe_filtermaster(VIEW,&dclib..MPE_TABLES,
68 dclib=&dclib,
69 filter_rk=&filter_rk,
70 outref=qref
71)
72data work.out;
73 infile qref;
74 input;
75 put _infile_;
76run;
77%mp_assertdsobs(work.out,
78 desc=Test 1 - Five records from simple query,
79 test=EQUALS 5,
80 outds=work.test_results
81)
82
83/*
84 Test 2 - Expect 6 records from an EDIT query
85
86 ((
87 LIBREF CONTAINS 'DC'
88 ) AND (
89 DSN = 'MPE_LOCK_ANYTABLE'
90 ))
91 AND ( %sysfunc(datetime()) < TX_TO )
92
93*/
94
95%mpe_filtermaster(EDIT,&dclib..MPE_TABLES,
96 dclib=&dclib,
97 filter_rk=&filter_rk,
98 outref=qref
99)
100data work.out;
101 infile qref;
102 input;
103 put _infile_;
104run;
105%mp_assertdsobs(work.out,
106 desc=Test 2 - Six records from EDIT query,
107 test=EQUALS 6,
108 outds=work.test_results
109)
110
111/*
112 Test 3 - Empty query
113
114
115*/
116data work.class;
117 do age=1 to 19;
118 weight=age*1.3;
119 output;
120 end;
121run;
122%mpe_filtermaster(VIEW,work.class,
123 dclib=&dclib,
124 filter_rk=-1,
125 outref=qref3
126)
127data _null_;
128 infile qref3;
129 input;
130 putlog _infile_;
131run;
132data work.out3;
133 set work.class;
134 where %inc qref3;;
135run;
136%mp_abort(iftrue= (&syscc ne 0)
137 ,mac=&sysmacroname
138 ,msg=%str(syscc=&syscc in Test 3)
139)
140%mp_assertdsobs(work.out3,
141 desc=Test 3 - all records returned due to empty query,
142 test=EQUALS 19,
143 outds=work.test_results
144)