Question7:ThecontentsoftherawdatafileAMOUNTarelistedbelow:
--------10-------20-------30
$1,234
ThefollowingSASprogramissubmitted:
datatest;
infile'amount';
input@1salary6.;
if_error_thendescription='Problems';
elsedescription='NoProblems';
run;
WhichoneofthefollowingisthevalueoftheDESCRIPTIONvariable?
1.Problems
2. NoProblems
3. ''(missingcharactervalue)
4.Thevaluecannotbedeterminedastheprogramfailstoexecuteduetoerrors
CorrectAnswer:1
Exp:AstheprogramhasanerrorITISDUETODATAERROR.INCOMPILATIONERRORTHEPROGRAMMSTOPNOTEXECUTED.HERETHEPROGRAMMEXECUTEFULLYWITHERRORINLOGWINDOW.
Reason:
Inputstatmentshouldbelikebelow;
input@1salarydollar6.;
or
input@1salarycomma6.;
informatprovidedinincorrectandsascannotread$and,symbolsbygiving6
Incorrectinformatintheinputstatement,salaryismissing'.'duringexecution,theifstatementexecutes,assigningthedescriptiontext,with_error_=1.
Bisruledout,foranotherreason-becausethelengthofthevariabledescriptionisdeterminedintheifstatementbythecharacterstringfirstencountered:'Problems'during
compilation,sothatif_error_=0atruncated'NoProbl'(8characters)wouldbestoredinthevariableandappearinthedatasetnot'NoProblems'
TheDOLLARw.dformatwritesnumericvalueswithaleadingdollarsign,acommathatseparateseverythreedigits,andaperiodthatseparatesthedecimalfraction.
Examples
put@3netpaydollar10.2;
Valueofnetpay
1254.71
Results
$1,254.71