Base SAS 3

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?
A. Problems
B. No Problems
C. ' ' (missing character value)
D. The value can not be determined as the program fails to execute due to errors.
Click Comment link to get answer

32 comments:

  1. The Answer will be A. as the program has an error which is compilation error so this will falg _ERROR_ to 1.

    i think the error occurs in "infile" statement.

    Any suggestions!!!!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. yes A us answer, if we follow informat dollar8. what is value of desc variable ?

    ReplyDelete
  4. yes A us answer, if we follow informat dollar8. what is value of desc variable ?

    ReplyDelete
  5. Answer is A. But if use the informat COMMA6.0 in input function then it will not give any error.

    ReplyDelete
  6. The Answer is ultimately A. Problems

    Reason:
    Input statment should be like below;
    input @1 salary dollar6.;
    or
    input @1 salary comma6.;

    ReplyDelete
  7. The answer is A if your SAS environment allows variable names longer than 8 characters. If not (like mine) then the answer is D as it fails to execute.

    ReplyDelete
  8. The Answer is "A" as the informat provided in incorrect & sas cannot read $ and , symbols by giving 6. informat.....

    so, it gives _error_ = 1
    so it will take the value to be "problem" for the description variable..

    ReplyDelete
  9. the answer is A
    it is data error so the program executes and salary will have a missing numeric value which is period and description as problems

    ReplyDelete
  10. Salary is in non-standard numeric format and hence SAS cannot read without using informat. SAS generates error and print the decription as problems in list file and sets salary as missing value.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. ans is D.....

    ReplyDelete
  13. Answer is D ; As infile 'amout" says physical file doesnot exist

    ReplyDelete
  14. D is the correct answer

    ReplyDelete
  15. Its A, SAS will throw an error in compiling the statement , there is a "Problem" in the code

    ReplyDelete
  16. My friends here he ask about variable description so answer is "A"........ :)

    ReplyDelete
  17. yes ans is B coz programe is successully run. but salary is missing their not issue

    ReplyDelete
  18. I think I agree with hayder, that the ans is B It is a data error and that won;t stop the program from executing.

    Can the admin plz comment

    ReplyDelete
  19. correct answer is D

    ReplyDelete
  20. Answer A:

    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'.
    (That's almost funny. :-/)

    The statement:

    length description $ 11;

    prior to the if statement is required to avoid this.

    Nigel

    ReplyDelete