SAS习题集from online tutor

以下是从online tutor里选出的基础习题。虽然有一定的迷惑性,但是应该没有真题难。
[size=medium]
1. Which of the following would you use to compare the result of investing $4,000 a year for five years in three different banks that compound interest monthly? Assume a fixed rate for the five-year period.

a. DO WHILE statement
b. nested DO loops
c. DO UNTIL statement
d. a DO group

Correct answer: b
Place the monthly calculation in a DO loop within a DO loop that iterates once for each year. The DO WHILE and DO UNTIL statements are not used here because the number of required iterations is fixed. A non-iterative DO group would not be useful.

2. What is the length of the variable Type, as created in the DATA step below?

[b]data finance.newloan;
set finance.records;
TotLoan+payment;
if code='1' then Type='Fixed';
else Type='Variable';
length type $ 10;[/b]
run;

a. 5
b. 8
c. 10
d. it depends on the first value of Type

Correct answer: a
The length of a new variable is determined by the first reference in the DATA step, not by data values. In this case, the length of Type is determined by the value Fixed. The LENGTH statement is in the wrong place; it must be read before any other reference to the variable in the DATA step. The LENGTH statement cannot change the length of an existing variable

3.Which program contains an error?

a.

[b] data clinic.stress(drop=timemin timesec);
infile tests;
input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
TotalTime=(timemin*60)+timesec;
SumSec+totaltime;
run;[/b]


b.

[b] proc print data=clinic.stress;
label totaltime='Total Duration of Test';
format timemin 5.2;
drop sumsec;
run;[/b]


c.

[b] proc print data=clinic.stress(keep=totaltime timemin);
label totaltime='Total Duration of Test';
format timemin 5.2;
run;[/b]


d.

[b] data clinic.stress;
infile tests;
input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
TotalTime=(timemin*60)+timesec;
keep id totaltime tolerance;
run;[/b]


Correct answer: b
To select variables, you can use a DROP or KEEP statement in any DATA step. You can also use the DROP= or KEEP= data set options following a data set name in any DATA or PROC step. However, you cannot use DROP or KEEP statements in PROC steps.

4. Which INPUT statement reads the values for Lname, Fname, Department and Salary (in that order)?
[quote]
1---+----10---+----20---
ABRAMS THOMAS
SALES $25,209.03
BARCLAY ROBERT
MARKETING $29,180.36
COURTNEY MARK
PUBLICATIONS $24,006.16
[/quote]
a.

[b]input #1 Lname $ Fname $ /
Department $12. Salary comma10.; [/b]

b.

[b]input #1 Lname $ Fname $ /
Department : $12. Salary : comma.;[/b]

c.

[b]input #1 Lname $ Fname $
#2 Department : $12. Salary : comma.;[/b]

d. both b and c

Correct answer: d
You can use either the / or #n line pointer control to advance the input pointer to the second line, in order to read the values for Department and Salary. The colon (:) modifier is used to read the character values that are longer than eight characters (Department) and the nonstandard data values (Salary).

[/size]
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值