-
Notifications
You must be signed in to change notification settings - Fork 90
/
test_util_boxplot_block_ranges.sas
253 lines (202 loc) · 14.6 KB
/
test_util_boxplot_block_ranges.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/***
Qualification tests for PhUSE CS utility macro <MACRO-NAME>
SETUP: Ensure that PhUSE CS utilities are in the AUTOCALL path
TEST PLAN:
https://github.com/phuse-org/phuse-scripts/blob/master/whitepapers/qualification/testplan_<MACRO-NAME>.docx
***/
*--- SETUP ---*;
*--- Expected response strings can be quite long, so avoid meaningless log warnings ---*;
OPTIONS NOQUOTELENMAX;
%let macroname = util_boxplot_block_ranges;
%put WARNING: (TEST_%upcase(¯oname)) User must ensure PhUSE CS utilities are in the AUTOCALL path.;
/*** EXECUTE ONE TIME only as needed
Ensure PhUSE CS utilities are in the AUTOCALL path
NB: This line is not necessary if PhUSE CS utilities are in your default AUTOCALL paths
OPTIONS mrecall sasautos=(%sysfunc(getoption(sasautos)) "C:\CSS\phuse-scripts\whitepapers\utilities") ls=max ps=max;
***/
*--- SAVE TEST RESULTS as XML filename ---*;
*--- NB: if this filename is blank, do NOT save xml test results ---*;
%let XML_FILENAME = .\outputs_sas\testresults_%lowcase(¯oname).xml;
*--- Test Definitions ---*;
*--- Full Specs for test definitions: https://github.com/phuse-org/phuse-scripts/blob/master/whitepapers/utilities/util_passfail.sas ---*;
proc sql;
create table my_test_definitions
( test_mac char(32) label='Name of macro to test'
, test_id char(15) label="Test ID for %upcase(¯oname)"
, test_dsc char(80) label='Test Description'
, test_type char(1) label='Test Type (Macro var, String-<B|C|L|T>, Data set, In data step)'
, Pparm_ds char(50) label='Test values for the Positional parameter DS'
, Kparm_blockvar char(50) label='Test values for the Keyword parameter BLOCKVAR'
, Kparm_catvars char(50) label='Test values for the Keyword parameter CATVARS'
, test_expect char(1) label="EXPECTED test results for each call to %upcase(¯oname)"
, test_expect_sym char(500) label='TEST_PDLIM-delim Name=Value pairs of EXPECTED global syms created'
, test_wrap char(120) label="Set MAX_BOXES_PER_PAGE and symdel BEFORE/AFTER each call to %upcase(¯oname)"
, test_pdlim char(1) label="OVERRIDE default test delimiter (|) which %upcase(¯oname) also uses in results"
)
;
*--- TEST 1 (invalid/missing values): SASHELP.HEART var BP_STATUS has no missing values, but SMOKING_STATUS does. ---*;
insert into my_test_definitions
values("%lowcase(¯oname)", '1.a.1', 'Invalid DSet', 'M', 'dset_DNE', 'visvar', 'trtvar',
'', 'BOXPLOT_BLOCK_RANGES=',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.a.2', 'Invalid VIS var', 'M', 'sashelp.heart', 'visvar_DNE', 'bp_status',
'', 'BOXPLOT_BLOCK_RANGES=',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.a.3', 'Invalid TRT var', 'M', 'sashelp.heart', 'bp_status', 'trtvar_DNE',
'', 'BOXPLOT_BLOCK_RANGES=',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.a.4', 'Invalid VIS and TRT vars', 'M', 'sashelp.heart', 'visvar_DNE', 'trtvar_DNE',
'', 'BOXPLOT_BLOCK_RANGES=',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.b.1', 'Missing CHAR VISIT values', 'M', 'sashelp.heart', 'smoking_status', 'bp_status',
'', 'BOXPLOT_BLOCK_RANGES=""<=smoking_status<="Light (1-5)"|"Moderate (6-15)"<=smoking_status<="Very Heavy (> 25)"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.b.2', 'Missing CHAR TREATMENT values', 'M', 'sashelp.heart', 'bp_status', 'smoking_status',
'', 'BOXPLOT_BLOCK_RANGES="High"<=bp_status<="High"|"Normal"<=bp_status<="Normal"|"Optimal"<=bp_status<="Optimal"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.b.3', 'Missing CHAR VISIT and TREATMENT values', 'M', 'sashelp.heart', 'weight_status', 'smoking_status',
'', 'BOXPLOT_BLOCK_RANGES=""<=weight_status<="Normal"|"Overweight"<=weight_status<="Overweight"|"Underweight"<=weight_status<="Underweight"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.c.1', 'Missing NUM VISIT values', 'M', 'rectangular', 'visnum_miss', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=.<=visnum_miss<=10|13<=visnum_miss<=16|19<=visnum_miss<=25|28<=visnum_miss<=34|37<=visnum_miss<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.c.2', 'Missing NUM TREATMENT values', 'M', 'rectangular', 'visitnum', 'trtnum_miss',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=13|16<=visitnum<=19|22<=visitnum<=25|28<=visitnum<=31|34<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '1.c.3', 'Missing NUM VISIT and TREATMENT values', 'M', 'rectangular', 'visnum_miss', 'trtnum_miss',
'', 'BOXPLOT_BLOCK_RANGES=.<=visnum_miss<=10|13<=visnum_miss<=16|19<=visnum_miss<=25|28<=visnum_miss<=34|37<=visnum_miss<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.a.1', 'MBPP=3, numeric vars, consistent visits x treatments', 'M', 'rectangular', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=13|16<=visitnum<=19|22<=visitnum<=25|28<=visitnum<=31|34<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.a.2', 'MBPP=3, char vars, consistent visits x treatments', 'M', 'alph_rec', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="five"|"four"<=visitcd<="nine"|"one"<=visitcd<="seven"|"six"<=visitcd<="ten"|"three"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.b.1', 'MBPP=3, numeric vars, some missing visits & treatments', 'M', 'gaps', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=13|16<=visitnum<=22|25<=visitnum<=28|31<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.b.2', 'MBPP=3, char vars, some missing visits & treatments', 'M', 'alph_gap', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="four"|"nine"<=visitcd<="seven"|"six"<=visitcd<="three"|"two"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.c.1', 'MBPP=3, numeric vars, consistent visits x treatments', 'M', 'rectangular', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=10|13<=visitnum<=13|16<=visitnum<=16|19<=visitnum<=19|22<=visitnum<=22|
25<=visitnum<=25|28<=visitnum<=28|31<=visitnum<=31|34<=visitnum<=34|37<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=3; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.c.2', 'MBPP=3, char vars, consistent visits x treatments', 'M', 'alph_rec', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="eight"|"five"<=visitcd<="five"|"four"<=visitcd<="four"|"nine"<=visitcd<="nine"|
"one"<=visitcd<="one"|"seven"<=visitcd<="seven"|"six"<=visitcd<="six"|"ten"<=visitcd<="ten"|"three"<=visitcd<="three"|"two"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=3; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.d.1', 'MBPP=3, numeric vars, some missing visits & treatments', 'M', 'gaps', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=10|13<=visitnum<=13|16<=visitnum<=16|19<=visitnum<=19|22<=visitnum<=22|
25<=visitnum<=25|28<=visitnum<=28|31<=visitnum<=31|34<=visitnum<=34|37<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=3; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.d.2', 'MBPP=3, char vars, some missing visits & treatments', 'M', 'alph_gap', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="eight"|"five"<=visitcd<="five"|"four"<=visitcd<="four"|"nine"<=visitcd<="nine"|
"one"<=visitcd<="one"|"seven"<=visitcd<="seven"|"six"<=visitcd<="six"|"ten"<=visitcd<="ten"|"three"<=visitcd<="three"|"two"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=3; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.e.1', 'MBPP=20, numeric vars, consistent visits x treatments', 'M', 'rectangular', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=22|25<=visitnum<=37|40<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=20; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.e.2', 'MBPP=20, char vars, consistent visits x treatments', 'M', 'alph_rec', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="one"|"seven"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=20; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.f.1', 'MBPP=20, numeric vars, some missing visits & treatments', 'M', 'gaps', 'visitnum', 'treatnum',
'', 'BOXPLOT_BLOCK_RANGES=10<=visitnum<=22|25<=visitnum<=40',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=20; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.f.2', 'MBPP=20, char vars, some missing visits & treatments', 'M', 'alph_gap', 'visitcd', 'treatcd',
'', 'BOXPLOT_BLOCK_RANGES="eight"<=visitcd<="seven"|"six"<=visitcd<="two"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=20; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.g.1', '2 CAT vars, missing CHAR VISIT vals', 'M', 'sashelp.heart', 'smoking_status', 'bp_status status',
'', 'BOXPLOT_BLOCK_RANGES=""<=smoking_status<="Heavy (16-25)"|"Light (1-5)"<=smoking_status<="Moderate (6-15)"|"Non-smoker"<=smoking_status<="Very Heavy (> 25)"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=15; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.g.2', '2 CAT vars, missing CHAR TREATMENT values', 'M', 'sashelp.heart', 'bp_status', 'smoking_status status',
'', 'BOXPLOT_BLOCK_RANGES="High"<=bp_status<="High"|"Normal"<=bp_status<="Normal"|"Optimal"<=bp_status<="Optimal"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=10; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
values("%lowcase(¯oname)", '2.g.3', '2 CAT vars, missing CHAR VISIT and TREATMENT values', 'M', 'sashelp.heart', 'weight_status', 'smoking_status status',
'', 'BOXPLOT_BLOCK_RANGES=""<=weight_status<="Normal"|"Overweight"<=weight_status<="Overweight"|"Underweight"<=weight_status<="Underweight"',
'%GLOBAL MAX_BOXES_PER_PAGE; %LET MAX_BOXES_PER_PAGE=20; _MACCALL1_; %SYMDEL MAX_BOXES_PER_PAGE;',
'~')
/* NB: UTIL_BOXPLOT_BLOCK_RANGES creates a |-delim string. So override the default UTIL_PASSFAIL delimiter | with ~
values("%lowcase(¯oname)", '', '', 'M', '', '', '',
'', 'BOXPLOT_BLOCK_RANGES=',
'~')
values("%lowcase(¯oname)", '', '', 'M', '', '', '',
'', 'BOXPLOT_BLOCK_RANGES=',
'~')
values("%lowcase(¯oname)", '', '', 'M', '', '', '',
'', 'BOXPLOT_BLOCK_RANGES=',
'~')
values("%lowcase(¯oname)", '', '', 'M', '', '', '',
'', 'BOXPLOT_BLOCK_RANGES=',
'~')
*/
;
quit;
*--- Setup test environment here (dsets, macro vars, etc) ---*;
data rectangular;
*--- 44 vis*trt combinations ---*;
do visitnum = 10 to 40 by 3;
do treatnum = 1, 2, 3, 4;
if ranuni(64785) < 0.1 then visnum_miss = .;
else visnum_miss = visitnum;
if ranuni(16047) < 0.1 then trtnum_miss = .;
else trtnum_miss = treatnum;
output;
end;
end;
run;
data gaps;
set rectangular;
if (13 = visitnum and 3 = treatnum) or
(19 = visitnum and treatnum in (2, 3)) or
(28 = visitnum and 1 = treatnum) or
(37 = visitnum and treatnum in (3, 4)) or
(40 = visitnum and treatnum in (1, 2))
then delete;
run;
*--- TEST BEHAVIOR GIVEN ALPHANUMERIC VARS, as well ---*;
data alph_rec;
*--- 40 vis*trt combinations ---*;
length visitcd $ 5;
do visitcd = 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten';
do treatcd = 'a1', 'a2', 'b1', 'b2';
output;
end;
end;
run;
data alph_gap;
set alph_rec;
if ('two' = visitcd and 'b1' = treatcd) or
('four' = visitcd and treatcd in ('a2', 'b1')) or
('seven' = visitcd and 'a1' = treatcd) or
('nine' = visitcd and treatcd in ('b1', 'b2')) or
('ten' = visitcd and treatcd in ('a1', 'a2'))
then delete;
run;
*--- Create EXPECTED test results ---*;
*--- Execute & evaluate tests, and report & store test results ---*;
%util_passfail (my_test_definitions, savexml= &xml_filename, debug=N);