Question9:WhichoneofthefollowingstatementsistrueregardingtheSASautomatic_ERROR_variable?
1.The_ERROR_variablecontainsthevalues'ON'or'OFF'.
2.The_ERROR_variablecontainsthevalues'TRUE'or'FALSE'.
3.The_ERROR_variableisautomaticallystoredintheresultingSASdataset.
4.The_ERROR_variablecanbeusedinexpressionsorcalculationsintheDATAstep.
CorrectAnswer:4
Exp:
AutomaticVariables
AutomaticvariablesarecreatedautomaticallybytheDATAsteporbyDATAstepstatements.Thesevariablesareaddedtotheprogramdatavectorbutarenotoutputtothedataset
beingcreated.ThevaluesofautomaticvariablesareretainedfromoneiterationoftheDATAsteptothenext,ratherthansettomissing.
Automaticvariablesthatarecreatedbyspecificstatementsaredocumentedwiththosestatements.TwoautomaticvariablesarecreatedbyeveryDATAstep:_N_and_ERROR_.
_N_
isinitiallysetto1.EachtimetheDATAsteploopspasttheDATAstatement,thevariable_N_incrementsby1.Thevalueof_N_representsthenumberoftimestheDATAstephas
iterated.
_ERROR_
is0bydefaultbutissetto1wheneveranerrorisencountered,suchasaninputdataerror,aconversionerror,oramatherror,asindivisionby0orafloatingpointoverflow.
YoucanusethevalueofthisvariabletohelplocateerrorsindatarecordsandtoprintanerrormessagetotheSASlog.
Forexample,eitherofthetwofollowingstatementswritestotheSASlog,duringeachiterationoftheDATAstep,thecontentsofaninputrecordinwhichaninputerroris
encountered:
if_error_=1thenput_infile_;
if_error_thenput_infile_;