SAS Base (39)

The following SAS program is submitted:

array Favorites{3} $ 8 (‘Shakespeare’,’Hemingway’,’McCaffrey’);

What is the value of the second variable in the dataset WORK.AUTHORS?
A. Hemingway
B. Hemingwa
C. ‘ ‘ (a missing value)
D. The program contains errors. No variables are created.

Check Answer
Answer: B

注解:ARRAY statement中,Favorites为数组名字,{3}表示数组中有3个元素,$表示数组中的元素为字符型,8表示数组内的值最长为8个字节,(‘Shakespeare’,’Hemingway’,’McCaffrey’)设定数组元素的初始值。第二个数组元素,即 Favorites{2},得到的初始值为’Hemingway’,但由于定义了最长8个字符,所以其值为Hemingwa。

Leave a Reply

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