The following SAS program is submitted:
data WORK.TOTALSALES(keep=MonthSales{12});
set WORK.MONTHLYSALES(keep=Year Product Sales);
array MonthSales{12};
do i=1 to 12;
MonthSales{i}=Sales;
end;
drop i;
run;
The program fails execution due to syntax errors.
What is the cause of the syntax error?
A. An array cannot be referenced on a keep= data set option.
B. The keep= data set option should be (keep=MonthSales*).
C. The keep= data set option should be the statement KEEP MonthSales{12}.
D. The variable MonthSales does not exist.
注解:KEEP和DROP的对象不能是数组,只能是变量。如果希望去掉数组中的变量,可以直接引用该变量的名字。例如题目中,希望仅保留数组中第12个元素,即MonthSales{12},可以使用以下KEEP option: KEEP = MonthSales12,如果想保留整个数组:KEEP = MonthSales1 – MonthSales12。