Base SAS 7

Which one of the following is true when SAS encounters a data error in a DATA step?
A. The DATA step stops executing at the point of the error, and no SAS data set is created.
B. A note is written to the SAS log explaining the error, and the DATA step continues to execute.
C. A note appears in the SAS log that the incorrect data record was saved to a separate SAS file for further examination.
D. The DATA step stops executing at the point of the error, and the resulting DATA set contains observations up to that point.
Click Comment link to get answer

12 comments:

  1. Answer is B.
    Explanation:

    Notice what happens when SAS encounters invalid data.
    1 An error message is printed on the log.

    NOTE: Invalid data for DOB in line 6 9-15.
    2 The raw data line is printed with a ruler.

    RULE:----+----1----+----2----+----3----+----4----+----5----+----6
    6 1 SMITH 1/23/66 68 144 M 26
    Aside: Notice how the error message "for DOB in line 6 9-15" points you to the variable being read, the line number and the column range where the input error occurred.

    3 The resulting values of all the variables (after the input process) are printed.

    ID=1 LASTNAME=SMITH DOB=. HEIGHT=68 WEIGHT=144 GENDER=M AGE=26 _ERROR_=1 _N_=1
    Aside: The special variables _ERROR_ and _N_ are used in the data set
    to indicate whether a run-time error has occurred with this observation, and
    to indicate how many times the data step has executed.
    These two variables are not included in the output dataset.

    4 The data step keeps running.

    NOTE: The data set WORK.WONTWORK has 4 observations and 7 variables.
    Also see that the Proc Print output shows that a dataset with values was created. All the variables have been given values for all the observations (a missing value is a value).

    ReplyDelete
  2. Answer is B. In the below example though the program encountered a problem with the 3rd observation but still the data step continued to process till the end.

    Just observe the below sas program and its output.

    data temp;
    input name $ no;
    datalines;
    AppaRao 10
    subbarao 20
    12 papa rao 30
    Kiran 25
    ;
    run;
    proc print data=temp;
    run;

    Log Window Output:
    54 data temp;
    55 input name $ no;
    56 datalines;

    NOTE: Invalid data for no in line 59 4-7.
    RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
    59 12 papa rao 30
    name=12 no=. _ERROR_=1 _N_=3
    NOTE: The data set WORK.TEMP has 4 observations and 2 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.00 seconds


    61 ;
    62 run;
    63 proc print data=temp;
    64 run;

    NOTE: There were 4 observations read from the data set WORK.TEMP.
    NOTE: PROCEDURE PRINT used (Total process time):
    real time 0.01 seconds
    cpu time 0.01 seconds

    ReplyDelete
  3. the answer is D.as it can be used in datastep.

    ReplyDelete
  4. The answer is B. data errors occur in data step but it is a execution time error, so it continues to execute. Most of the syntax errors that occur during the compilation phase stop the execution of sas program

    ReplyDelete
  5. It depends upon the error.
    If it's a syntax error then the A occurs.
    If it's an error with invalid data then B will occur .
    If it's a problem with merging two or more datasets, then D will occur.

    ReplyDelete
  6. it specifically ask for data error not syntax or merge issue.

    ReplyDelete
  7. ans is B , it becos when ther is data error it will disply as _error_ =1 and it will exicute wher Ques was only error then it would had been A. thats becose when ther is error in statment it will display in red and for such output is not exicuted.

    ReplyDelete
  8. when SAS encounters syntax errors then it gives a note in the SAS log saying: The SAS system stopped processing this step because of errors. and when SAS encounters data errors a note is written to the SAS log explaining the error, and the DATA step continues to execute. So Ans is B.

    ReplyDelete