SAS Base (25)

Given the following code:

proc print data=SASHELP.CLASS(firstobs=5 obs=15);
where Sex=’M’;
run;

How many observations will be displayed?

A. 11
B. 15
C. 10 or fewer
D. 11 or fewer

Check Answer
Answer: D

注解:首先只有5-11行中的数据才会被打印出来,所以最多能出现11条数据,其次这些数据还需要满足Sex为M。FIRSTOBS和OBS参考SAS Base (5)

SAS Base (19)

The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char:

Num Char
1 23
2 23
1 77

The following SAS program is submitted:

proc print data=WORK.ONE;
where Num=’1′;
run;

What is output?

A.

Obs Num Char
1 1 23

B.

Obs Num Char
1 1 23
3 1 77

C.

Obs Num Char
1 1 23
2 2 23
3 1 77

D. No output is generated.

Check Answer
Answer: D

注解:数值型无法和字符型进行逻辑运算(例如:比大小),并且WHERE statement不会自动将字符型转换成数值型。Log中会显示”ERROR: WHERE clause operator requires compatible variables.”。