Question:5ThefollowingSASprogramissubmitted:
datawork.totalsales(keep=monthsales{12});
setwork.monthlysales(keep=yearproductsales);
arraymonthsales{12};
doi=1to12;
monthsales{i}=sales;
end;run;
ThedatasetnamedWORK.MONTHLYSALEShasoneobservationpermonthforeachoffiveyearsforatotalof60observations.
Whichoneofthefollowingistheresultoftheaboveprogram?
1.Theprogramfailsexecutionduetodataerrors.
2.Theprogramfailsexecutionduetosyntaxerrors.
3.TheprogramexecuteswithwarningsandcreatestheWORK.TOTALSALESdataset.
4.TheprogramexecuteswithouterrorsorwarningsandcreatestheWORK.TOTALSALESdataset.
CorrectAnswer:2
Exp::datamonthly(keep=sales);
doi=1to60;sales=i*10;output;
end;run;
datawork.totalsales(keep=msales{12});
setwork.monthly(keep=sales);
arraymsales{12};
doi=1to12;msales{i}=sales;end;run;
logfile:
153datawork.totalsales(keep=msales{12});
214
23
ERROR214-322:Variablename{isnotvalid.
ERROR23-7:InvalidvaluefortheKEEPoption.
23
23
153!datawork.totalsales(keep=msales{12});
214
ERROR214-322:Variablename12isnotvalid.
153!datawork.totalsales(keep=msales{12});
214
ERROR214-322:Variablename}isnotvalid.
Programwillrunwithouterrorsifwechangekeep=statementas
datawork.totalsales(keep=msales1-msales12);
setwork.monthly(keep=sales);
arraymsales{12};doi=1to12;msales{i}=sales;
end;run;
wecan'tusearrayvariablesinthekeep/dropoptionsbecausearrayvariablesaretemporaryandavailableonlyatthetimeofexecution.wehavetomentionthenameofthevariables
createdbyarrayifrequiredinthekeepoption