您的位置:首页 > 其它

PROC MEANS AND PROC SUMMARY

2011-04-17 21:04 267 查看
两者最大的不同是MEANS结果是print table,而SUMMARY的结果是一个数据集。

利用output选项二者可以实现同样的功能。

例如:

proc means data=sashelp.class noprint;
var weight;
output out=summrydat1;
run;
proc summary data=sashelp.class;
var weight;
output out=summrydat2;
run;

另外,可以对统计量重命名

例如:

proc summary data=sashelp.class;
var weight;
output out=summrydat n=number mean=average std=std_deviation;
run;

proc summary data=sashelp.class;
var height weight;
output out =summrydat
n =ht_n wt_n
mean(weight)= wt_mean
std(height) = ht_std;
run;

还有,CLASS语句,类似于FREQ的CLASS语句

title1 'CLASS and a Printed Table';
proc means data=sashelp.class;
class age sex;
var height;
output out=clsummry1 n=ht_n mean=ht_mean std=ht_sd;
run;

使用CLASS语句,MEANS和SUMMARY自动生成的_TYPE_值不同,它们用来区别统计量。



_TYPE_ = 0 Summarize across all classification variables

总结所有分类变量
_TYPE_ = 1 Summarize as if the right most classification variable was the only one
对将数据最右边的分类变量作总结

_TYPE_ = 2 Summarize as if the next to the right most classification variable was the only one

对数据右边第二个分类变量作总结
_TYPE_ = 3 Interaction of the two classification variables.

两分类变量间交互作用



比如上面代码的结果为:



_type_=0,统计量对所有变量计算所得
_type_=1,对满足分类变量sex计算所得
_type_=2,对满足分类变量age计算所得
_type_=3,则是同时对满足分类变量sex,age计算所得
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: