请选择 进入手机版 | 继续访问电脑版
楼主: xn2xn
12295 6

请问SAS程序中by与class语句的区别? [推广有奖]

  • 1关注
  • 1粉丝

小学生

50%

还不是VIP/贵宾

-

威望
0
论坛币
18 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
102 点
帖子
6
精华
0
在线时间
5 小时
注册时间
2015-10-18
最后登录
2020-4-1

xn2xn 发表于 2015-10-19 23:25:23 |显示全部楼层 |坛友微信交流群

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问SAS程序中by与class语句有什么区别?可以互换吗?
二维码

扫码加我 拉你入群

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

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

关键词:sas程序 程序

zxn2011 发表于 2015-10-19 23:51:22 |显示全部楼层 |坛友微信交流群
SAS的文档里对这个问题有专门的描述,大概可以包括以下几点:
1.区别不大一般可以互换
2.用by之前必须先sort 而用class则不必
3.在proc means 中如果不使用NWAY,用by则只会给出相应的分类的汇总统计数据;而用class不仅会给出相应分类的统计数据而且还会给出不同组别所有可能组合的数据的统计数据;
4.by的结果输出多个表而class只有一个表
5.一般情况下用by比class要高效
已有 1 人评分学术水平 热心指数 收起 理由
mandyfervor + 1 + 1 分析的有道理

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

使用道具

zxn2011 发表于 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.

使用道具

xn2xn 发表于 2015-10-20 00:07:02 |显示全部楼层 |坛友微信交流群
zxn2011 发表于 2015-10-19 23:51
SAS的文档里对这个问题有专门的描述,大概可以包括以下几点:
1.区别不大一般可以互换
2.用by之前必须先s ...
多谢指教

使用道具

欢薯er 发表于 2016-3-21 16:16:48 |显示全部楼层 |坛友微信交流群
受益了

使用道具

受教了

使用道具

ShawnLee42 发表于 2016-7-5 21:04:43 |显示全部楼层 |坛友微信交流群
最大的区别还是在于by语句对原始数据分组之前需要用sort by先排序,而class不需要。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-28 18:46