Question10:WhichoneofthefollowingistruewhenSASencountersadataerrorinaDATAstep?
1.TheDATAstepstopsexecutingatthepointoftheerror,andnoSASdatasetiscreated.
2.AnoteiswrittentotheSASlogexplainingtheerror,andtheDATAstepcontinuestoexecute.
3.AnoteappearsintheSASlogthattheincorrectdatarecordwassavedtoaseparateSASfileforfurtherexamination.
4.TheDATAstepstopsexecutingatthepointoftheerror,andtheresultingDATAsetcontainsobservationsuptothatpoint.
CorrectAnswer:2
Exp:NoticewhathappenswhenSASencountersinvaliddata.
1Anerrormessageisprintedonthelog.
NOTE:InvaliddataforDOBinline69-15.
2Therawdatalineisprintedwitharuler.
RULE:----+----1----+----2----+----3----+----4----+----5----+----6
61SMITH1/23/6668144M26
Aside:Noticehowtheerrormessage"forDOBinline69-15"pointsyoutothevariablebeingread,thelinenumberandthecolumnrangewheretheinputerroroccurred.
3Theresultingvaluesofallthevariables(aftertheinputprocess)areprinted.
ID=1LASTNAME=SMITHDOB=.HEIGHT=68WEIGHT=144GENDER=MAGE=26_ERROR_=1_N_=1
Aside:Thespecialvariables_ERROR_and_N_areusedinthedataset
toindicatewhetherarun-timeerrorhasoccurredwiththisobservation,and
toindicatehowmanytimesthedatastephasexecuted.
Thesetwovariablesarenotincludedintheoutputdataset.
4Thedatastepkeepsrunning.
NOTE:ThedatasetWORK.WONTWORKhas4observationsand7variables.
AlsoseethattheProcPrintoutputshowsthatadatasetwithvalueswascreated.Allthevariableshavebeengivenvaluesforalltheobservations(amissingvalueisavalue).
DataerrorsoccurwhensomedatavaluesarenotappropriatefortheSASstatementsthatyouhavespecifiedintheprogram.Forexample,ifyoudefineavariableasnumeric,butthe
datavalueisactuallycharacter,SASgeneratesadataerror.SASdetectsdataerrorsduringprogramexecutionandcontinuestoexecutetheprogram,anddoesthefollowing:
writesaninvaliddatanotetotheSASlog.
printstheinputlineandcolumnnumbersthatcontaintheinvalidvalueintheSASlog.Unprintablecharactersappearinhexadecimal.Tohelpdeterminecolumnnumbers,SASprintsa
rulelineabovetheinputline.
printstheobservationundertheruleline.
setstheautomaticvariable_ERROR_to1forthecurrentobservation.