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;
run;
The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations.
Which one of the following is the result of the above program?
A. The program fails execution due to data errors.
B. The program fails execution due to syntax errors.
C. The program executes with warnings and creates the WORK.TOTALSALES data set.
D. The program executes without errors or warnings and creates the WORK.TOTALSALES data set.
Click Comment link to get answer
Answer is B.
ReplyDeletedata monthly (keep = sales);
do i = 1 to 60;
sales = i*10;
output;
end;
run;
data work.totalsales(keep = msales{12} ) ;
set work.monthly (keep = sales);
array msales {12} ;
do i=1 to 12;
msales{i} = sales;
end;
run;
log file:
153 data work.totalsales(keep = msales{12} ) ;
-
214
23
ERROR 214-322: Variable name { is not valid.
ERROR 23-7: Invalid value for the KEEP option.
--
23
-
23
153! data work.totalsales(keep = msales{12} ) ;
--
214
ERROR 214-322: Variable name 12 is not valid.
153! data work.totalsales(keep = msales{12} ) ;
-
214
ERROR 214-322: Variable name } is not valid.
Program will run without errors if we change keep = statement as
data work.totalsales(keep = msales1-msales12 ) ;
set work.monthly (keep = sales);
array msales {12} ;
do i=1 to 12;
msales{i} = sales;
end;
run;
syntax error - coz there is no variable as monthsale{12}...the variable is monthsale12
ReplyDeleteAnswer B
ReplyDeletethe answer might be Invalid value for the KEEP option.
ReplyDeletecorrect answer B
ReplyDeleteThe answer is B
ReplyDeleteyap B is correct one bez it is d syntax error
ReplyDeleteans is B...
ReplyDeleteans is B as there is error in the first data step. no proper execution
ReplyDelete