Question 7 : The contents of the raw data file AMOUNT are listed below:
--------10-------20-------30
$1,234
The following SAS program is submitted:
data test;
infile 'amount';
input @1 salary 6.;
if _error_ then description = 'Problems';
else description = 'No Problems';
run;
Which one of the following is the value of the DESCRIPTION variable?
1. Problems
2. No Problems
3. ' ' (missing character value)
4. The value can not be determined as the program fails to execute due to errors
Correct Answer : 1
Exp :As the program has an error IT IS DUE TO DATA ERROR. IN COMPILATION ERROR THE PROGRAMM STOP NOT EXECUTED. HERE THE PROGRAMM EXECUTE FULLY WITH ERROR IN LOG WINDOW.
Reason:
Input statment should be like below;
input @1 salary dollar6.;
or
input @1 salary comma6.;
informat provided in incorrect and sas cannot read $ and , symbols by giving 6
Incorrect informat in the input statement, salary is missing '.' during execution, the if statement executes, assigning the description text, with _error_ = 1.
B is ruled out, for another reason - because the length of the variable description is determined in the if statement by the character string first encountered: 'Problems' during compilation, so that if _error_ = 0 a truncated 'No Probl' (8 characters) would be stored in the variable and appear in the dataset not 'No Problems'
The DOLLARw.d format writes numeric values with a leading dollar sign, a comma that separates every three digits, and a period that separates the decimal fraction.
Examples
put @3 netpay dollar10.2;
Value of netpay
1254.71
Results
$1,254.71
Don't forget to create account on our site to get access to more material made only for free registered user.
![]() |
![]() |
![]() |
![]() |
![]() |
- Details
- Written by Raj Shah
- Details
- Hits: 4259