130中的101题:data temp;
length a 1 b 3 x;
infile 'file reference';
input a b x;
run;
What is the result? B
A.The data set TEMP is created, but variable X is not created.
B.The data set TEMP is created and variable X has a length of 8.
C.The data set TEMP is not created because variable A has an invalid length.
D.The data set TEMP is not created because variables A and B have invalid lengths.
Answer: B 此题验证了选b而有些版本答案是选C C是错的,temp有3variables 和0 obs。由于A length 1 不合格,于是变为默认长度8
numberic varible length is 3-8之间
63题中的20题与此题类似:
20. The following SAS program is submitted:
data WORK.TEMP;
length A B 3 X;
infile RAWDATA;
input A B X;
run;
What is the length of variable A? A
A. 3
B. 8
C. WORK.TEMP is not created - X has an invalid length.
D. Unknown.
Explanation:
A: 这里考察的是LENGTH语句对变量长度的约束。
如果没有Length语句的约束,如X就是默认的长度了8个BYTE。
LENGTH语句制定了A B的长度,但是没有指定X的长度,如果X长度不需要LENGTH特别指出那么就不用LENGTH X这样的语句,因为LOG里面提示你没有设置长度值,不符合LENGTH语句语法。这里需要指出的是,程序编译时就已经设置了长度,要么是默认的,要么是指定的。在这里也许数据集WORK.TEMP没有观测; 但是通过CONTENTS依然能看到每一个变量的属性。
Warning message from SAS log:
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0 observations and 3 variables.
D: Using PROC DATASETS/CONTENTS, we can see that X has a length of 8 bytes. a