全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
13092 6
2015-10-19
请问SAS程序中by与class语句有什么区别?可以互换吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-10-19 23:51:22
SAS的文档里对这个问题有专门的描述,大概可以包括以下几点:
1.区别不大一般可以互换
2.用by之前必须先sort 而用class则不必
3.在proc means 中如果不使用NWAY,用by则只会给出相应的分类的汇总统计数据;而用class不仅会给出相应分类的统计数据而且还会给出不同组别所有可能组合的数据的统计数据;
4.by的结果输出多个表而class只有一个表
5.一般情况下用by比class要高效
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-10-19 23:52:03
Comparison of the BY and CLASS Statements
Using the BY statement is similar to using the CLASS statement and the NWAY option in that PROC MEANS summarizes each BY group as an independent subset of the input data. Therefore, no overall summarization of the input data is available. However, unlike the CLASS statement, the BY statement requires that you previously sort BY variables.
When you use the NWAY option, PROC MEANS might encounter insufficient memory for the summarization of all the class variables. You can move some class variables to the BY statement. For maximum benefit, move class variables to the BY statement that are already sorted or that have the greatest number of unique values.
You can use the CLASS and BY statements together to analyze the data by the levels of class variables within BY groups.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-10-20 00:07:02
zxn2011 发表于 2015-10-19 23:51
SAS的文档里对这个问题有专门的描述,大概可以包括以下几点:
1.区别不大一般可以互换
2.用by之前必须先s ...
多谢指教
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-3-21 16:16:48
受益了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-3-22 08:44:40
受教了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群