作者startend (Pride & Prejudice)
站内Statistics
标题[讨论] 请问这个语法哪里有问题
时间Mon Jul 19 00:09:24 2010
因为最近开始使用SAS,顺便考SAS BASE
不过太久没碰的下场就是好多东西都忘记了....
想请问以下几个题目,希望强者能够提供一些见解(跪)
1.
data work.test;
capacity = 150;
if 100 le capacity le 200 then airplanetype = 'large' and staff = 10;
else airplanetype = 'small' and staff = 5;
run;
题目希望data set 长成如下,上面这个是错的,只是我不确定错在哪里
capacity airplanetype staff
150 large 10
就题目而言,是因为else 少了一个if吗?
另外就是if-then的语法里面,如果有假设三个if-then的时候
一般都是打成if-then
else if-then
else (最後这个就不用加上?)
2.submit following
libname sasdata ' '
data allobs;
set sasdata.banks;
capital = 0;
do year = 2000 to 2020 by 5;
capital+((capital+2000)*rate);
output;
end;
run;
if sasdata.banks has five observation,how many observations will the ALLOBS
contain? Ans:25
这个我就掉到五里雾里面了....
另外一个疑问是,output的使用时机,虽然讲义上面是写prevent continuous looping,
但感觉有一点抽象,另外是不是用了output,後面一定要用stop; ?
3.submit following
data work.XXX
set work.people (in = inemp)
work.money (in = insal);
if insal = inemp;
run;
work.people has 5 observations, and work.money has 7 observations
How many obs contain in work.XXXX? Ans: 0
因为这应该是一个concatenating,为什麽不是12个 obs?
4.
在从外部抓资料的时候
input style $ @;
style是一个variable的名字,但後面的@代表什麽意义?
因为我看到的都是input @4 style $2.;类似这种的,但@在後面的有特别意义吗?
5.
data work.total;
infile where end = eof;
input name $ salary;
total + salary;
(if statement)
run;
which statement would write the last observation to the output data set?
Ans: if eof = 1;
不太了解题意,最後想问一下if如果再没有then的搭配下,跟where statement有什麽
差别呢?
我想对大家来说这些都是很简单的问题,还请大家不赐吝教,感恩
--
"When someone sees you as you really are and wants to be with you
,that's powerful."
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.47.5.122
1F:推 tew:第1题提示 do; end; 07/19 02:01
2F:→ tew:2000 2005 2010 2015 2020 都会产生5笔资料 07/19 02:02
3F:→ tew:第三题 应该用merge set只会上下放置 就不会产生交集 07/19 02:04
4F:推 tew:第五题 你自己写一个变项 令他等於eof就会知道了 07/19 02:11
5F:→ startend:谢谢!不过第一题的提示是说if then就要跟do 做合并吗? 07/23 00:20