楼主: mingfeng07
20654 16

[问答] 关于class语句和by语句的区别 [推广有奖]

11
spta 发表于 2015-6-10 15:14:35 |只看作者 |坛友微信交流群
非常好! 学习了

使用道具

12
是我的海 发表于 2016-6-14 09:10:10 |只看作者 |坛友微信交流群
jingju11 发表于 2014-2-20 12:07
在SAS过程里,BY 和 CLASS 是两个完全不同的概念,即使在某些地方结果或许有巧合。BY 的本质是划分切割数据 ...
by.png
图一:class数据集
class.png

图二:运行结果

proc means data =sashelp.class;
    by sex notsorted;
    var age;
run;

proc means data =sashelp.class;
    class sex;  
    var age;  
run;

by.png (13.45 KB)

by.png

使用道具

13
abc591623342 发表于 2016-12-6 09:16:47 |只看作者 |坛友微信交流群
BY语句在过程中一般用来指定一个或几个分组变量,根据这些分组变量值把观测分组,然后 对每一组观测分别进行本过程指定的分析。在使用带有BY语句的过程步之前一般先用SORT过 程对数据集排序。
在一些过程(如方差分析)中,使用CLASS语句指定一个或几个分类变量,它实际 相当于因变量。而在另一些过程(如MEANS)中,CLASS语句作用与BY语句类似,可以指定分 类变量,把观测按分类变量分类后分别进行分析。使用CLASS时不需要先按分类变量排序

使用道具

14
ruhuasong 发表于 2017-4-3 15:06:06 |只看作者 |坛友微信交流群
学习了!

使用道具

15
swei007 发表于 2018-1-31 13:43:43 |只看作者 |坛友微信交流群
有道理

使用道具

16
下小雨2018 发表于 2019-1-16 15:09:49 |只看作者 |坛友微信交流群
abc591623342 发表于 2016-12-6 09:16
BY语句在过程中一般用来指定一个或几个分组变量,根据这些分组变量值把观测分组,然后 对每一组观测分别进行 ...
学习了,谢谢!

使用道具

17
yunnandlg 在职认证  学生认证  发表于 2019-8-25 23:10:20 |只看作者 |坛友微信交流群
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.
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
玩于股涨之中 + 1 + 1 + 1 精彩帖子

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

使用道具

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

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

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

GMT+8, 2024-4-25 13:14