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 (5)

Which statement specifies that records 1 through 10 are to be read from the raw data file customer.txt?

A. infile ‘customer.txt’ 1-10;
B. input ‘customer.txt’ stop@10;
C. infile ‘customer.txt’ obs=10;
D. input ‘customer.txt’ stop=10;

Check Answer
Answer: C

注解:OBS用于指定所需读取的最后一行数据的位置。与之相反的是FIRSTOBS,用于指定读取数据的启示位置。需要注意的是,OBS和FIRSTOBS对应的是INFILE数据源中record的行数,而非observation。比如以下这种情况:
data d;
infile datalines firstobs = 2 obs = 5;
input x;
input y;
datalines;
1
2
3
4
5
6
7
8
9
10
;
run;
两行record组成一个observation。生成的data set应为:

Obs x y
1 2 3
2 4 5

最后,INPUT statement中不存在STOP这个argument。