sas - 在 SAS 中对变量执行测试

标签 sas

我想知道是否可以对 SAS 数据集中的所有变量执行 ttest (proc ttest)。可能通过循环数据?

这是我目前拥有的,但它没有正确运行:

data test;
set work.wisc;
array Avar(30) V1-V30;
do variable = 1 to 30;
    proc ttest data = work.wisc;
    class Diagnosis;
    var Avar(variable);
    end;
run;

非常感谢任何帮助。谢谢!

最佳答案

这样的事情可能会奏效。在循环中调用 &&name&i. 将引用每个变量名称。您可能需要在 proc ttest 中进行一些调整,因为我不熟悉该功能。

/* -- Get the names of the variables --*/
proc contents data = work.wisc out = names noprint;  run;

/*--- Make macro vars needed ---*/
proc sql noprint;
 select
   count(distinct name) into :name_count from names;
 select
   distinct name into :name1 - :name9999 from names;
quit;

/*--- Strip spaces from name_count ---*/
%let name_count = &name_count.;

%put There are &name_count. variables in the data set;

/*--- Run the test for all variables ---*/
%macro testAll();
%do i = 1 %to &name_count.;
   proc ttest data = work.wisc;
       class Diagnosis;
       var Avar(&&name&i.);
   run;
%end;
%mend;
%testAll();

关于sas - 在 SAS 中对变量执行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7591149/

相关文章:

sas - 在 SAS 中按组处理

arrays - 如何计算SAS中连续值的最大数量

sql - SAS 表字符串长度(限制)

oracle - 通过SAS将新表写入Oracle数据库,写入时锁定表

sas - 使用压缩去除字符

sas - 在 SAS 中创建带有条件的子表

SAS:比较两个数据集,但需要从一组数据中删除额外的观察结果

javascript - 从 HTML 输入数据生成 CSV 文件

date - 计算第一周的天数 sas

parameters - 如何定义具有不同数量参数的函数?