Skip to content

Commit f0c5503

Browse files
authored
feat(qualify_multi_test): 自定义假设检验方法和统计量显示的字符串 (#72)
1 parent 800c209 commit f0c5503

File tree

3 files changed

+173
-12
lines changed

3 files changed

+173
-12
lines changed

docs/qualify_multi_test/readme.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
- [LABEL](#label)
2525
- [INDENT](#indent)
2626
- [SUFFIX](#suffix)
27+
- [CHISQ_NOTE](#chisq_note)
28+
- [FISHER_NOTE](#fisher_note)
29+
- [FISHER_STAT_PH](#fisher_stat_ph)
2730
- [PROCHTTP_PROXY](#prochttp_proxy)
2831

2932
### 调试参数
@@ -122,6 +125,60 @@
122125

123126
---
124127

128+
### CHISQ_NOTE
129+
130+
**Syntax** : _string_
131+
132+
指定输出结果中卡方检验方法显示的字符串,该字符串必须使用匹配的单(双)引号包围。
133+
134+
> [!NOTE]
135+
>
136+
> 该选项仅在使用卡方检验时生效。
137+
138+
**Default** : `"卡方检验"`
139+
140+
**Usage** :
141+
142+
```sas
143+
CHISQ_NOTE = "χ\super 2 \nosupersub 检验"
144+
```
145+
146+
### FISHER_NOTE
147+
148+
**Syntax** : _string_
149+
150+
指定输出结果中 Fisher 精确检验方法显示的字符串,该字符串必须使用匹配的单(双)引号包围。
151+
152+
> [!NOTE]
153+
>
154+
> 该选项仅在使用 Fisher 精确检验时生效。
155+
156+
**Default** : `"Fisher精确检验"`
157+
158+
**Usage** :
159+
160+
```sas
161+
FISHER_NOTE = "Fisher"
162+
```
163+
164+
### FISHER_STAT_PH
165+
166+
**Syntax** : _string_
167+
168+
指定输出结果中 Fisher 精确检验统计量显示的占位字符串,该字符串必须使用匹配的单(双)引号包围。
169+
170+
> [!NOTE]
171+
>
172+
> 该选项仅在使用 Fisher 精确检验时生效。
173+
174+
**Default** : `""`
175+
176+
**Usage** :
177+
178+
```sas
179+
FISHER_STAT_PH = "-"
180+
```
181+
125182
### PROCHTTP_PROXY
126183

127184
用法同 [PROCHTTP_PROXY](../qualify_multi/readme.md#prochttp_proxy)

gbk/qualify_multi_test.sas

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Version Date: 2024-01-08 0.1
1818
2025-01-08 0.13
1919
2025-01-14 0.14
2020
2025-01-15 0.15
21+
2025-01-17 0.16
2122
===================================
2223
*/
2324

@@ -36,6 +37,9 @@ Version Date: 2024-01-08 0.1
3637
LABEL = #AUTO,
3738
INDENT = #AUTO,
3839
SUFFIX = #AUTO,
40+
CHISQ_NOTE = "卡方检验",
41+
FISHER_NOTE = "Fisher精确检验",
42+
FISHER_STAT_PH = "",
3943
TOTAL = FALSE,
4044
PROCHTTP_PROXY = 127.0.0.1:7890,
4145
DEL_TEMP_DATA = TRUE)
@@ -251,6 +255,51 @@ Version Date: 2024-01-08 0.1
251255
%end;
252256
%end;
253257

258+
/*CHISQ_NOTE*/
259+
%if %superq(chisq_note) = %bquote() %then %do;
260+
%let chisq_note_sql_expr = %bquote('');
261+
%end;
262+
%else %do;
263+
%let reg_chisq_note_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
264+
%if %sysfunc(prxmatch(&reg_chisq_note_id, %superq(chisq_note))) %then %do;
265+
%let chisq_note_sql_expr = %superq(chisq_note);
266+
%end;
267+
%else %do;
268+
%put ERROR: 参数 CHISQ_NOTE 格式不正确,指定的字符串必须使用匹配的引号包围!;
269+
%goto exit;
270+
%end;
271+
%end;
272+
273+
/*FISHER_NOTE*/
274+
%if %superq(fisher_note) = %bquote() %then %do;
275+
%let fisher_note_sql_expr = %bquote('');
276+
%end;
277+
%else %do;
278+
%let reg_fisher_note_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
279+
%if %sysfunc(prxmatch(&reg_fisher_note_id, %superq(fisher_note))) %then %do;
280+
%let fisher_note_sql_expr = %superq(fisher_note);
281+
%end;
282+
%else %do;
283+
%put ERROR: 参数 FISHER_NOTE 格式不正确,指定的字符串必须使用匹配的引号包围!;
284+
%goto exit;
285+
%end;
286+
%end;
287+
288+
/*FISHER_STAT_PH*/
289+
%if %superq(fisher_stat_ph) = %bquote() %then %do;
290+
%let fisher_stat_ph_sql_expr = %bquote('');
291+
%end;
292+
%else %do;
293+
%let reg_fisher_stat_ph_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
294+
%if %sysfunc(prxmatch(&reg_fisher_stat_ph_id, %superq(fisher_stat_ph))) %then %do;
295+
%let fisher_stat_ph_sql_expr = %superq(fisher_stat_ph);
296+
%end;
297+
%else %do;
298+
%put ERROR: 参数 FISHER_STAT_PH 格式不正确,指定的字符串必须使用匹配的引号包围!;
299+
%goto exit;
300+
%end;
301+
%end;
302+
254303

255304
/*----------------------------------------------主程序----------------------------------------------*/
256305
/*1. 复制数据*/
@@ -300,6 +349,9 @@ Version Date: 2024-01-08 0.1
300349
/*定义宏变量,存储说明文字*/
301350
%let note_stat = %unquote(%superq(indent_sql_expr)) || "统计量";
302351
%let note_pvalue = %unquote(%superq(indent_sql_expr)) || "P值";
352+
%let note_chisq = %unquote(%superq(chisq_note_sql_expr));
353+
%let note_fisher = %unquote(%superq(fisher_note_sql_expr));
354+
%let placeholder_fisher = %unquote(%superq(fisher_stat_ph_sql_expr));
303355

304356
proc sql noprint;
305357
select count(distinct &var_name) into :var_nonmissing_level_n from tmp_qmt_indata_unique_var where not missing(&var_name);
@@ -326,11 +378,11 @@ Version Date: 2024-01-08 0.1
326378
%if &chisq_warn = 1 %then %do; /*卡方检验不适用*/
327379
create table tmp_qmt_stat as
328380
select
329-
1 as idt,
330-
&desc_seq_max + 1 as seq,
331-
&note_stat as item,
332-
"Fisher精确检验" as value_1,
333-
"-" as value_2
381+
1 as idt,
382+
&desc_seq_max + 1 as seq,
383+
&note_stat as item,
384+
&note_fisher as value_1,
385+
&placeholder_fisher as value_2
334386
from tmp_qmt_chisq
335387
outer union corr
336388
select
@@ -350,7 +402,7 @@ Version Date: 2024-01-08 0.1
350402
1 as idt,
351403
&desc_seq_max + 1 as seq,
352404
&note_stat as item,
353-
"卡方检验" as value_1,
405+
&note_chisq as value_1,
354406
strip(put(_PCHI_, &ts_format)) as value_2
355407
from tmp_qmt_chisq
356408
outer union corr

utf8/qualify_multi_test.sas

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Version Date: 2024-01-08 0.1
1818
2025-01-08 0.13
1919
2025-01-14 0.14
2020
2025-01-15 0.15
21+
2025-01-17 0.16
2122
===================================
2223
*/
2324

@@ -36,6 +37,9 @@ Version Date: 2024-01-08 0.1
3637
LABEL = #AUTO,
3738
INDENT = #AUTO,
3839
SUFFIX = #AUTO,
40+
CHISQ_NOTE = "卡方检验",
41+
FISHER_NOTE = "Fisher精确检验",
42+
FISHER_STAT_PH = "",
3943
TOTAL = FALSE,
4044
PROCHTTP_PROXY = 127.0.0.1:7890,
4145
DEL_TEMP_DATA = TRUE)
@@ -251,6 +255,51 @@ Version Date: 2024-01-08 0.1
251255
%end;
252256
%end;
253257

258+
/*CHISQ_NOTE*/
259+
%if %superq(chisq_note) = %bquote() %then %do;
260+
%let chisq_note_sql_expr = %bquote('');
261+
%end;
262+
%else %do;
263+
%let reg_chisq_note_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
264+
%if %sysfunc(prxmatch(&reg_chisq_note_id, %superq(chisq_note))) %then %do;
265+
%let chisq_note_sql_expr = %superq(chisq_note);
266+
%end;
267+
%else %do;
268+
%put ERROR: 参数 CHISQ_NOTE 格式不正确,指定的字符串必须使用匹配的引号包围!;
269+
%goto exit;
270+
%end;
271+
%end;
272+
273+
/*FISHER_NOTE*/
274+
%if %superq(fisher_note) = %bquote() %then %do;
275+
%let fisher_note_sql_expr = %bquote('');
276+
%end;
277+
%else %do;
278+
%let reg_fisher_note_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
279+
%if %sysfunc(prxmatch(&reg_fisher_note_id, %superq(fisher_note))) %then %do;
280+
%let fisher_note_sql_expr = %superq(fisher_note);
281+
%end;
282+
%else %do;
283+
%put ERROR: 参数 FISHER_NOTE 格式不正确,指定的字符串必须使用匹配的引号包围!;
284+
%goto exit;
285+
%end;
286+
%end;
287+
288+
/*FISHER_STAT_PH*/
289+
%if %superq(fisher_stat_ph) = %bquote() %then %do;
290+
%let fisher_stat_ph_sql_expr = %bquote('');
291+
%end;
292+
%else %do;
293+
%let reg_fisher_stat_ph_id = %sysfunc(prxparse(%bquote(/^(\x22[^\x22]*\x22|\x27[^\x27]*\x27)$/)));
294+
%if %sysfunc(prxmatch(&reg_fisher_stat_ph_id, %superq(fisher_stat_ph))) %then %do;
295+
%let fisher_stat_ph_sql_expr = %superq(fisher_stat_ph);
296+
%end;
297+
%else %do;
298+
%put ERROR: 参数 FISHER_STAT_PH 格式不正确,指定的字符串必须使用匹配的引号包围!;
299+
%goto exit;
300+
%end;
301+
%end;
302+
254303

255304
/*----------------------------------------------主程序----------------------------------------------*/
256305
/*1. 复制数据*/
@@ -300,6 +349,9 @@ Version Date: 2024-01-08 0.1
300349
/*定义宏变量,存储说明文字*/
301350
%let note_stat = %unquote(%superq(indent_sql_expr)) || "统计量";
302351
%let note_pvalue = %unquote(%superq(indent_sql_expr)) || "P值";
352+
%let note_chisq = %unquote(%superq(chisq_note_sql_expr));
353+
%let note_fisher = %unquote(%superq(fisher_note_sql_expr));
354+
%let placeholder_fisher = %unquote(%superq(fisher_stat_ph_sql_expr));
303355

304356
proc sql noprint;
305357
select count(distinct &var_name) into :var_nonmissing_level_n from tmp_qmt_indata_unique_var where not missing(&var_name);
@@ -326,11 +378,11 @@ Version Date: 2024-01-08 0.1
326378
%if &chisq_warn = 1 %then %do; /*卡方检验不适用*/
327379
create table tmp_qmt_stat as
328380
select
329-
1 as idt,
330-
&desc_seq_max + 1 as seq,
331-
&note_stat as item,
332-
"Fisher精确检验" as value_1,
333-
"-" as value_2
381+
1 as idt,
382+
&desc_seq_max + 1 as seq,
383+
&note_stat as item,
384+
&note_fisher as value_1,
385+
&placeholder_fisher as value_2
334386
from tmp_qmt_chisq
335387
outer union corr
336388
select
@@ -350,7 +402,7 @@ Version Date: 2024-01-08 0.1
350402
1 as idt,
351403
&desc_seq_max + 1 as seq,
352404
&note_stat as item,
353-
"卡方检验" as value_1,
405+
&note_chisq as value_1,
354406
strip(put(_PCHI_, &ts_format)) as value_2
355407
from tmp_qmt_chisq
356408
outer union corr

0 commit comments

Comments
 (0)