标题: SAS Base 50题一问,请高手指点!! [打印本页] 作者: shiyiming 时间: 2007-10-20 08:13 标题: SAS Base 50题一问,请高手指点!! 11. The SAS data set SASHELP.PRDSALE contains the variables REGION and SALARY with 4
observations per REGION. SASHELP.PRDSALE is sorted primarily by REGION and within REGION
by SALARY in descending order.
The following SAS program is submitted:
data one;
set sashelp.prdsale;
retain temp;
by region descending salary;
if first.region then
do;
temp = salary;
output;
end;
if last.region then
do;
range = salary - temp;
output;
end;
run;
What is the number of observation(s) written to the output data set for each region?
A. 0
B. 1
C. 2
D. 4
请问为什么选C?
16. The following program is submitted:
data numrecords;
infile cards dlm = ',';
input agent1 $ agent2 $ agent3 $;
cards;
jones,,brownjones,spencer,brown
;
run;
What is the value for the variable named AGENT2 in the second observation?
A. brown
B. spencer
C. ' ' (missing character value)
D. There is no value because only one observation is created.
请问为什么选D?有人给出解释:There is no double trail sign @@ in ‘INPUT’ statements.可是我还是不明白??请大牛指点,谢先!!!!作者: shiyiming 时间: 2007-10-23 22:29 标题: Re: SAS Base 50题一问,请高手指点!! 第一题:
主要是if first.region和if last.region的缘故,当对每个分组中的第一个和最后一个处理时进行output,由于程序中显式的使用output,所以本来在数据步结束前的隐式的output不在存在。
第二题:
显而易见是没有第二个observation的,input是一条记录一条记录进行处理的,如果没有使用@或@@,那么数据步中每个input(每一次数据步循环)其实都占据一条记录,不管它是否用完这一条。建议看看@和@@的用法就知道了。作者: shiyiming 时间: 2007-10-24 00:14 标题: Re: SAS Base 50题一问,请高手指点!! Thanks!!!