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’ [email protected];
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。

2 thoughts on “SAS Base (5)

Leave a Reply

Your email address will not be published. Required fields are marked *