由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教SAS BASE 70题里的第53题
相关主题
请教base 11 月真题的第一题请教版上高人一个SAS编程问题
请教SAS BASE 70题里的第35题Ask a SAS Base question?
请教SAS BASE 70题里的第42题BASE 70题一问
Use SAS to fill in missing values?一道SAS BASE题,HELP!
SAS questionsas一问
##问一个SAS BASE 问题##请教SAS BASE 70题里的第17题
SAS question请教SAS BASE 70题里的第59题
SAS questoin请教sas base 70题里的44题
相关话题的讨论汇总
话题: total话题: retain话题: missing话题: salary话题: department
进入Statistics版参与讨论
1 (共1页)
s*****p
发帖数: 299
1
data Work.Total_Salary;
retain Total;
set Work.Salary;
by Department;
if First.Department
then total=0;
Total=sum(Total,Wagerate);
if Last.Total;
run;
what is the initial value of the variable Total?
Answer:Missing
为什么会是这个答案呢?我一直都以为是0。
哪位大侠能帮我扫扫retain的盲,一直对这个命令很疑惑。
多谢!!
d*******o
发帖数: 493
2
这个是经典的Data step classified aggregation . 用SQL写是
proc sql;
create table Total_Salary as
select sum(Wagerate) as total,department
from Salary
group by department
;quit;
Retain before by Set statement can be 'missing' or 'zero'.
s*****p
发帖数: 299
3
Retain before by Set statement can be 'missing' or 'zero'.
能具体说说什么时候是missing什么时候是zero吗?
谢谢!
s*****p
发帖数: 299
4
data Work.Total_Salary;
retain Total;
set Work.Salary;
by Department;
if First.Department
then total=0;
Total=sum(Total,Wagerate);
if Last.Total;
run;
what is the initial value of the variable Total?
Answer:Missing
为什么会是这个答案呢?我一直都以为是0。
哪位大侠能帮我扫扫retain的盲,一直对这个命令很疑惑。
多谢!!
d*******o
发帖数: 493
5
这个是经典的Data step classified aggregation . 用SQL写是
proc sql;
create table Total_Salary as
select sum(Wagerate) as total,department
from Salary
group by department
;quit;
Retain before by Set statement can be 'missing' or 'zero'.
s*****p
发帖数: 299
6
Retain before by Set statement can be 'missing' or 'zero'.
能具体说说什么时候是missing什么时候是zero吗?
谢谢!
s********1
发帖数: 54
7

Do you think the correct code should be "if Last.Department;" rather than "
if Last.Total;"? Thank you!!!!

【在 s*****p 的大作中提到】
: data Work.Total_Salary;
: retain Total;
: set Work.Salary;
: by Department;
: if First.Department
: then total=0;
: Total=sum(Total,Wagerate);
: if Last.Total;
: run;
: what is the initial value of the variable Total?

w********y
发帖数: 371
8
retain total;
如果不给初值,就是missing
s********1
发帖数: 54
9
Yes, I know what you said. But note that first.total and last.total should
be applied with by total statement. Since the question has "by Department",
I think it should be last.Department rather than last.total. Also, the
question never states by total.
Thanks!!!

【在 w********y 的大作中提到】
: retain total;
: 如果不给初值,就是missing

1 (共1页)
进入Statistics版参与讨论
相关主题
请教sas base 70题里的44题SAS question
请教SAS 123题中的17, 57, 68, 72题##问一个SAS BASE 问题##
[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?SAS question
请教SAS问题SAS questoin
请教base 11 月真题的第一题请教版上高人一个SAS编程问题
请教SAS BASE 70题里的第35题Ask a SAS Base question?
请教SAS BASE 70题里的第42题BASE 70题一问
Use SAS to fill in missing values?一道SAS BASE题,HELP!
相关话题的讨论汇总
话题: total话题: retain话题: missing话题: salary话题: department