Base SAS 4

The contents of the raw data file NAMENUM are listed below:
--------10-------20-------30
Joe xx
The following SAS program is submitted:
data test;
infile 'namenum';
input name $ number;
run;
Which one of the following is the value of the NUMBER variable?
A. xx
B. Joe
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.
Click Comment link to get answer

19 comments:

  1. Answer is C, missing value, since a numeric value is expected for the variable been read, and a character value was found.

    ReplyDelete
  2. Answer is C.

    You have given name as character and there was no delimiter. so it will read 1st characters including the space i.e Joe xx and number seems to be missing. So output will be missing..

    Correct it if am wrong

    ReplyDelete
  3. Kiruba, there was no delimiter means default space will be used as delimiter here. So name will read Joe and number is expecting numeric value but it reads xx, so number is set to missing.

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

    ReplyDelete
  5. Answer is C

    ReplyDelete
  6. answer is c because variable is character not the numeric and hence $ was not given it ll be missing

    ReplyDelete
  7. SAS encounters character data for numeric data and sets _error_=1. However, SAS still runs the code and generates an list file with name=Jeo and number is set to a missing value

    ReplyDelete
  8. how can the answer be c? the program will not execute if you give infile 'namenum';we cannot use a name in quotes in infile statement.it didn't execute when i tried.i think the answer is D

    ReplyDelete
  9. Sakar;

    Please focus on logic, in input we have name $ ( which is defined a character variable) number ( a numeric variable),
    When we execute the sas program it reads in data vector name as character variable looks for numeric variable as assigned in input statement. But is does not find numeric but xx is character so in data vector it writes 1 and which is missing numeric value.
    Who ever said a or be needed to grasp the logical side of SAS program. Do not get confused as well do not confuse others too.
    Thank you.

    ReplyDelete