楼主: zenith1107
13241 33

[原创博文] SAS 计算平均值问题 [推广有奖]

21
crackman 发表于 2010-2-28 12:18:22
18# zenith1107
楼主的程序有点问题哦

22
醉_清风 发表于 2010-3-1 13:11:06
bobguy 的解答总是那么简洁实用 呵呵
从来不需要想起 永远也不会忘记

23
lqyrendajinji 发表于 2010-3-2 01:10:27
sort by day

first.day
last.day

24
sdu0632 发表于 2010-3-2 03:30:25
DATA test;
input Week $ Day Price;
CARDS;
111 1 1
111 1 2
112 1 3
112 1 4
111 2 5
111 2 6
112 2 7
112 2 8
;
run;

proc sql;
create table means as
select distinct *, mean(price) as mean_price
from test
group by week, day;
quit;

25
yanqh 发表于 2010-4-21 11:03:23
如果有好多个组怎么弄?比如有10年的每日死亡人数,我想计算每天的平均死亡数,怎么弄?

26
ling1212 发表于 2010-4-21 16:55:46
牛人,学习了

27
liyimin88 发表于 2012-5-7 18:34:54
谢谢分享!

28
pl172231 发表于 2012-5-7 19:15:21
bobguy 发表于 2010-2-26 07:35
It can be much simplified as,

DATA test;
bobguy搞错了吧,你这个代码跑出来不是楼主想要的o,你看看楼主想要的是什么,仔细看

29
nernernini 发表于 2012-5-7 23:09:57
thanks, good to learn.

30
ntsean 发表于 2012-5-8 05:27:10
试试这个,只是不知道数据大的时候速度如何

proc sql;
select week, day, price,
       (select mean(price) from test b where b.day=a.day and b.week ne a.week)  as meanp
from test as a
;quit;

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 16:53