diff --git a/docs/qualify_multi_test/readme.md b/docs/qualify_multi_test/readme.md index f2b62c5..5ccca03 100644 --- a/docs/qualify_multi_test/readme.md +++ b/docs/qualify_multi_test/readme.md @@ -9,10 +9,10 @@ - [INDATA](#indata) - [VAR](#var) - [GROUP](#group) -- [GROUPBY](#groupby) ### 可选参数 +- [GROUPBY](#groupby) - [BY](#by) - [UID](#uid) - [PATTERN](#pattern) @@ -46,42 +46,13 @@ ### GROUP -**Syntax** : _variable_ - -指定分组变量。 - -> [!WARNING] -> -> - 参数 `GROUP` 不允许指定不存在于参数 `INDATA` 指定的数据集中的变量; -> - 参数 `GROUP` 不允许指定数值型变量; - -**Usage** : - -```sas -GROUP = ARM -``` - -[**Example**](#一般用法) +用法同 [GROUP](../qualify_multi/readme.md#group) --- ### GROUPBY -**Syntax** : _variable_<(ASC\ | DESC\)> - -指定分组变量的排序变量及排序方向。 - -> [!WARNING] -> -> - 参数 `GROUPBY` 不允许指定不存在于参数 `INDATA` 指定的数据集中的变量; - -**Usage** : - -```sas -GROUPBY = ARMN -``` - -[**Example**](#一般用法) +用法同 [GROUPBY](../qualify_multi/readme.md#groupby) --- diff --git a/docs/quantify_multi_test/readme.md b/docs/quantify_multi_test/readme.md index 53e939a..ebc0fc4 100644 --- a/docs/quantify_multi_test/readme.md +++ b/docs/quantify_multi_test/readme.md @@ -9,10 +9,10 @@ - [INDATA](#indata) - [VAR](#var) - [GROUP](#group) -- [GROUPBY](#groupby) ### 可选参数 +- [GROUPBY](#groupby) - [PATTERN](#pattern) - [OUTDATA](#outdata) - [STAT_FORMAT](#stat_format) @@ -41,44 +41,13 @@ ### GROUP -**Syntax** : _variable_ - -指定分组变量。 - -> [!WARNING] -> -> - 参数 `GROUP` 不允许指定不存在于参数 `INDATA` 指定的数据集中的变量; -> - 参数 `GROUP` 不允许指定数值型变量; - -**Usage** : - -```sas -GROUP = ARM -``` - -[**Example**](#一般用法) +用法同 [GROUP](../quantify_multi/readme.md#group) --- ### GROUPBY -**Syntax** : _variable_<(ASC\ | DESC\)> - -指定分组变量的排序。 - -本参数同时决定了检验统计量的正负性,若参数 `GROUP` 包含 `试验组`、`对照组` 两个分类,对应 `GROUPBY` 的值分别为 1、2,则进行差异性检验时,统计量的正负性与 `试验组-对照组` 的正负性一致。 - -> [!WARNING] -> -> - 参数 `GROUPBY` 不允许指定不存在于参数 `INDATA` 指定的数据集中的变量; - -**Usage** : - -```sas -GROUPBY = ARMN -``` - -[**Example**](#一般用法) +用法同 [GROUPBY](../quantify_multi/readme.md#groupby) --- diff --git a/gbk/qualify.sas b/gbk/qualify.sas index 0939c64..7fc1118 100644 --- a/gbk/qualify.sas +++ b/gbk/qualify.sas @@ -28,6 +28,7 @@ Version Date: 2023-03-08 1.0.1 2024-07-19 1.0.23 2024-09-18 1.0.24 2024-11-13 1.0.25 + 2024-11-14 1.0.26 =================================== */ @@ -128,6 +129,14 @@ Version Date: 2023-03-08 1.0.1 %put ERROR: &libname_in ߼ûҵ &memname_in ݼ; %goto exit_with_error; %end; + + proc sql noprint; + select count(*) into : nobs from &indata; + quit; + %if &nobs = 0 %then %do; + %put ERROR: ݼ &indata Ϊգ; + %goto exit_with_error; + %end; %end; %end; %put NOTE: ݼָΪ &libname_in..&memname_in; diff --git a/gbk/qualify_multi.sas b/gbk/qualify_multi.sas index 31dfa66..961bad6 100644 --- a/gbk/qualify_multi.sas +++ b/gbk/qualify_multi.sas @@ -13,6 +13,7 @@ Version Date: 2023-12-26 0.1 2024-06-04 0.8 2024-06-13 0.9 2024-07-15 0.10 + 2024-11-14 0.11 =================================== */ @@ -166,8 +167,19 @@ Version Date: 2023-12-26 0.1 %else %do; %let IS_GROUP_LEVEL_SPECIFIED = TRUE; %let group_level_n = %sysfunc(countw(%bquote(&group_level), %bquote(,), %bquote(sq))); + %do i = 1 %to &group_level_n; %let group_level_&i = %sysfunc(scan(%bquote(&group_level), &i, %bquote(,), %bquote(sq))); + %let group_level_unquote_&i = %sysfunc(compress(&&group_level_&i, %nrstr(%"))); + + %let group_level_freq_&i = "&&group_level_unquote_&i(Ƶ)"; + %let group_level_freq_fmt_&i = "&&group_level_unquote_&i(Ƶʽ)"; + %let group_level_n_&i = "&&group_level_unquote_&i(Ƶ)()"; + %let group_level_n_fmt_&i = "&&group_level_unquote_&i(Ƶʽ)()"; + %let group_level_times_&i = "&&group_level_unquote_&i(Ƶ)"; + %let group_level_times_fmt_&i = "&&group_level_unquote_&i(Ƶθʽ)"; + %let group_level_rate_&i = "&&group_level_unquote_&i(Ƶ)"; + %let group_level_rate_fmt_&i = "&&group_level_unquote_&i(Ƶʸʽ)"; %end; %end; %end; diff --git a/gbk/qualify_multi_test.sas b/gbk/qualify_multi_test.sas index fe61c4e..7d02214 100644 --- a/gbk/qualify_multi_test.sas +++ b/gbk/qualify_multi_test.sas @@ -14,13 +14,14 @@ Version Date: 2024-01-08 0.1 2024-06-13 0.9 2024-07-15 0.10 2024-11-13 0.11 + 2024-11-14 0.12 =================================== */ %macro qualify_multi_test(INDATA, VAR, GROUP, - GROUPBY, + GROUPBY = #AUTO, BY = #AUTO, UID = #NULL, PATTERN = %nrstr(#FREQ(#RATE)), @@ -45,8 +46,6 @@ Version Date: 2024-01-08 0.1 /*----------------------------------------------ʼ----------------------------------------------*/ /*ͳһСд*/ - %let group = %sysfunc(strip(%bquote(&group))); - %let groupby = %upcase(%sysfunc(strip(%bquote(&groupby)))); %let del_temp_data = %upcase(%sysfunc(strip(%bquote(&del_temp_data)))); /*ȫֱ*/ diff --git a/gbk/quantify_multi.sas b/gbk/quantify_multi.sas index d9a3250..0a79e14 100644 --- a/gbk/quantify_multi.sas +++ b/gbk/quantify_multi.sas @@ -7,6 +7,7 @@ Version Date: 2023-12-21 0.1 2023-12-25 0.2 2024-01-05 0.3 2024-01-19 0.4 + 2024-11-14 0.5 =================================== */ @@ -168,6 +169,7 @@ Version Date: 2023-12-21 0.1 %if %superq(groupby) ^= %bquote() and %superq(groupby) ^= #AUTO %then %do; %put WARNING: ͨ GROUP ָ˷򣬲 GROUPBY ѱԣ; %end; + %let groupby_criteria = &group_var; %end; %else %do; %if %superq(groupby) = %bquote() %then %do; @@ -183,15 +185,15 @@ Version Date: 2023-12-21 0.1 %else %do; %let reg_groupby_id = %sysfunc(prxparse(%bquote(/^([A-Za-z_][A-Za-z_\d]*)(?:\(((?:ASC|DESC)(?:ENDING)?)\))?$/))); %if %sysfunc(prxmatch(®_groupby_id, %superq(groupby))) %then %do; - %let groupby_var = %sysfunc(prxposn(®_groupby_id, 1, %superq(groupby))); + %let groupby_criteria = %sysfunc(prxposn(®_groupby_id, 1, %superq(groupby))); %let groupby_direction = %sysfunc(prxposn(®_groupby_id, 2, %superq(groupby))); /**/ proc sql noprint; - select type into :type from DICTIONARY.COLUMNS where libname = "&libname_in" and memname = "&memname_in" and upcase(name) = "&groupby_var"; + select type into :type from DICTIONARY.COLUMNS where libname = "&libname_in" and memname = "&memname_in" and upcase(name) = "&groupby_criteria"; quit; %if &SQLOBS = 0 %then %do; /*ݼûҵ*/ - %put ERROR: &libname_in..&memname_in ûҵ &groupby_var; + %put ERROR: &libname_in..&memname_in ûҵ &groupby_criteria; %goto exit_with_error; %end; @@ -200,8 +202,8 @@ Version Date: 2023-12-21 0.1 select distinct &group_var, - &groupby_var - from %superq(indata) where not missing(&group_var) order by &groupby_var &groupby_direction, &group_var; + &groupby_criteria + from %superq(indata) where not missing(&group_var) order by &groupby_criteria &groupby_direction, &group_var; select quote(strip(&group_var)) into : group_level_1- from tmp_quantify_m_groupby_sorted; select count(distinct &group_var) into : group_level_n from tmp_quantify_m_groupby_sorted; quit; diff --git a/gbk/quantify_multi_test.sas b/gbk/quantify_multi_test.sas index d64d1fc..f9e9473 100644 --- a/gbk/quantify_multi_test.sas +++ b/gbk/quantify_multi_test.sas @@ -8,13 +8,14 @@ Version Date: 2024-01-05 0.1 2024-01-23 0.3 2024-05-29 0.4 2024-06-14 0.5 + 2024-11-14 0.6 =================================== */ %macro quantify_multi_test(INDATA, VAR, GROUP, - GROUPBY, + GROUPBY = #AUTO, OUTDATA = RES_&VAR, PATTERN = %nrstr(#N(#NMISS)|#MEAN#STD|#MEDIAN(#Q1, #Q3)|#MIN, #MAX), STAT_FORMAT = #AUTO, @@ -38,7 +39,7 @@ Version Date: 2024-01-05 0.1 /*ȫֱ*/ %global qtmt_exit_with_error - groupby_var; + groupby_criteria; %let qtmt_exit_with_error = FALSE; /*ֲ*/ @@ -211,7 +212,7 @@ Version Date: 2024-01-05 0.1 /*̬Լ*/ proc univariate data = tmp_qmt_indata normaltest noprint; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; output out = tmp_qmt_nrmtest normaltest = normaltest probn = probn; run; @@ -239,7 +240,7 @@ Version Date: 2024-01-05 0.1 %put NOTE: һ𲻷̬ԣʹ Wilcoxon 飡; proc npar1way data = tmp_qmt_indata wilcoxon noprint; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; output out = tmp_qmt_wcxtest wilcoxon; run; proc sql noprint; @@ -261,7 +262,7 @@ Version Date: 2024-01-05 0.1 ods output TTests = tmp_qmt_ttests Equality = tmp_qmt_equality; proc ttest data = tmp_qmt_indata plots = none; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; run; ods html; diff --git a/utf8/qualify.sas b/utf8/qualify.sas index a060770..ea87031 100644 --- a/utf8/qualify.sas +++ b/utf8/qualify.sas @@ -28,6 +28,7 @@ Version Date: 2023-03-08 1.0.1 2024-07-19 1.0.23 2024-09-18 1.0.24 2024-11-13 1.0.25 + 2024-11-14 1.0.26 =================================== */ @@ -128,6 +129,14 @@ Version Date: 2023-03-08 1.0.1 %put ERROR: 在 &libname_in 逻辑库中没有找到 &memname_in 数据集!; %goto exit_with_error; %end; + + proc sql noprint; + select count(*) into : nobs from &indata; + quit; + %if &nobs = 0 %then %do; + %put ERROR: 分析数据集 &indata 为空!; + %goto exit_with_error; + %end; %end; %end; %put NOTE: 分析数据集被指定为 &libname_in..&memname_in; diff --git a/utf8/qualify_multi.sas b/utf8/qualify_multi.sas index 4d6286b..93520b7 100644 --- a/utf8/qualify_multi.sas +++ b/utf8/qualify_multi.sas @@ -13,6 +13,7 @@ Version Date: 2023-12-26 0.1 2024-06-04 0.8 2024-06-13 0.9 2024-07-15 0.10 + 2024-11-14 0.11 =================================== */ @@ -166,8 +167,19 @@ Version Date: 2023-12-26 0.1 %else %do; %let IS_GROUP_LEVEL_SPECIFIED = TRUE; %let group_level_n = %sysfunc(countw(%bquote(&group_level), %bquote(,), %bquote(sq))); + %do i = 1 %to &group_level_n; %let group_level_&i = %sysfunc(scan(%bquote(&group_level), &i, %bquote(,), %bquote(sq))); + %let group_level_unquote_&i = %sysfunc(compress(&&group_level_&i, %nrstr(%"))); + + %let group_level_freq_&i = "&&group_level_unquote_&i(频数)"; + %let group_level_freq_fmt_&i = "&&group_level_unquote_&i(频数格式化)"; + %let group_level_n_&i = "&&group_level_unquote_&i(频数)(兼容)"; + %let group_level_n_fmt_&i = "&&group_level_unquote_&i(频数格式化)(兼容)"; + %let group_level_times_&i = "&&group_level_unquote_&i(频次)"; + %let group_level_times_fmt_&i = "&&group_level_unquote_&i(频次格式化)"; + %let group_level_rate_&i = "&&group_level_unquote_&i(频率)"; + %let group_level_rate_fmt_&i = "&&group_level_unquote_&i(频率格式化)"; %end; %end; %end; diff --git a/utf8/qualify_multi_test.sas b/utf8/qualify_multi_test.sas index 875e974..b0c8e9a 100644 --- a/utf8/qualify_multi_test.sas +++ b/utf8/qualify_multi_test.sas @@ -14,13 +14,14 @@ Version Date: 2024-01-08 0.1 2024-06-13 0.9 2024-07-15 0.10 2024-11-13 0.11 + 2024-11-14 0.12 =================================== */ %macro qualify_multi_test(INDATA, VAR, GROUP, - GROUPBY, + GROUPBY = #AUTO, BY = #AUTO, UID = #NULL, PATTERN = %nrstr(#FREQ(#RATE)), @@ -45,8 +46,6 @@ Version Date: 2024-01-08 0.1 /*----------------------------------------------初始化----------------------------------------------*/ /*统一参数大小写*/ - %let group = %sysfunc(strip(%bquote(&group))); - %let groupby = %upcase(%sysfunc(strip(%bquote(&groupby)))); %let del_temp_data = %upcase(%sysfunc(strip(%bquote(&del_temp_data)))); /*声明全局变量*/ diff --git a/utf8/quantify_multi.sas b/utf8/quantify_multi.sas index eacdbf2..6be1f10 100644 --- a/utf8/quantify_multi.sas +++ b/utf8/quantify_multi.sas @@ -7,6 +7,7 @@ Version Date: 2023-12-21 0.1 2023-12-25 0.2 2024-01-05 0.3 2024-01-19 0.4 + 2024-11-14 0.5 =================================== */ @@ -168,6 +169,7 @@ Version Date: 2023-12-21 0.1 %if %superq(groupby) ^= %bquote() and %superq(groupby) ^= #AUTO %then %do; %put WARNING: 已通过参数 GROUP 指定了分组的排序,参数 GROUPBY 已被忽略!; %end; + %let groupby_criteria = &group_var; %end; %else %do; %if %superq(groupby) = %bquote() %then %do; @@ -183,15 +185,15 @@ Version Date: 2023-12-21 0.1 %else %do; %let reg_groupby_id = %sysfunc(prxparse(%bquote(/^([A-Za-z_][A-Za-z_\d]*)(?:\(((?:ASC|DESC)(?:ENDING)?)\))?$/))); %if %sysfunc(prxmatch(®_groupby_id, %superq(groupby))) %then %do; - %let groupby_var = %sysfunc(prxposn(®_groupby_id, 1, %superq(groupby))); + %let groupby_criteria = %sysfunc(prxposn(®_groupby_id, 1, %superq(groupby))); %let groupby_direction = %sysfunc(prxposn(®_groupby_id, 2, %superq(groupby))); /*检查排序变量存在性*/ proc sql noprint; - select type into :type from DICTIONARY.COLUMNS where libname = "&libname_in" and memname = "&memname_in" and upcase(name) = "&groupby_var"; + select type into :type from DICTIONARY.COLUMNS where libname = "&libname_in" and memname = "&memname_in" and upcase(name) = "&groupby_criteria"; quit; %if &SQLOBS = 0 %then %do; /*数据集中没有找到变量*/ - %put ERROR: 在 &libname_in..&memname_in 中没有找到分组排序变量 &groupby_var; + %put ERROR: 在 &libname_in..&memname_in 中没有找到分组排序变量 &groupby_criteria; %goto exit_with_error; %end; @@ -200,8 +202,8 @@ Version Date: 2023-12-21 0.1 select distinct &group_var, - &groupby_var - from %superq(indata) where not missing(&group_var) order by &groupby_var &groupby_direction, &group_var; + &groupby_criteria + from %superq(indata) where not missing(&group_var) order by &groupby_criteria &groupby_direction, &group_var; select quote(strip(&group_var)) into : group_level_1- from tmp_quantify_m_groupby_sorted; select count(distinct &group_var) into : group_level_n from tmp_quantify_m_groupby_sorted; quit; diff --git a/utf8/quantify_multi_test.sas b/utf8/quantify_multi_test.sas index 37cdefa..202b0cb 100644 --- a/utf8/quantify_multi_test.sas +++ b/utf8/quantify_multi_test.sas @@ -8,13 +8,14 @@ Version Date: 2024-01-05 0.1 2024-01-23 0.3 2024-05-29 0.4 2024-06-14 0.5 + 2024-11-14 0.6 =================================== */ %macro quantify_multi_test(INDATA, VAR, GROUP, - GROUPBY, + GROUPBY = #AUTO, OUTDATA = RES_&VAR, PATTERN = %nrstr(#N(#NMISS)|#MEAN±#STD|#MEDIAN(#Q1, #Q3)|#MIN, #MAX), STAT_FORMAT = #AUTO, @@ -38,7 +39,7 @@ Version Date: 2024-01-05 0.1 /*声明全局变量*/ %global qtmt_exit_with_error - groupby_var; + groupby_criteria; %let qtmt_exit_with_error = FALSE; /*声明局部变量*/ @@ -211,7 +212,7 @@ Version Date: 2024-01-05 0.1 /*正态性检验*/ proc univariate data = tmp_qmt_indata normaltest noprint; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; output out = tmp_qmt_nrmtest normaltest = normaltest probn = probn; run; @@ -239,7 +240,7 @@ Version Date: 2024-01-05 0.1 %put NOTE: 至少一个组别不符合正态性,使用 Wilcoxon 检验!; proc npar1way data = tmp_qmt_indata wilcoxon noprint; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; output out = tmp_qmt_wcxtest wilcoxon; run; proc sql noprint; @@ -261,7 +262,7 @@ Version Date: 2024-01-05 0.1 ods output TTests = tmp_qmt_ttests Equality = tmp_qmt_equality; proc ttest data = tmp_qmt_indata plots = none; var %superq(VAR); - class &groupby_var; + class &groupby_criteria; run; ods html;