« Test Dataset: Class | Main | How can I create an autocall macro library on a PC? »

Using the ERROR Statement to Identify a Data Error

I haven’t tried this yet, but it looks wicked.  You can write custom error messages to help you debug your programs.

Let’s say during your datastep, you have an If Statement:

 

 if daysout lt 0 then do;

        error ‘Days checked out less than zero: ‘ itemid=

            checkout= daysout=;

        end;

 

The SAS Log will look like:

    17     if daysout lt 0 then do;
    18      error ‘Days checked out less than zero: ‘ itemid=
    19         checkout= daysout=;
    20     end;
    21 run;

    Days checked out less than zero: itemid=LIB0397
    checkout=05/14/2001 daysout=-31
    itemid=LIB0397 checkout=05/14/2001 duedate=06/14/2001
    empno=001005 canrenew=Y nrenew=0

    NOTE: There were 446 observations read from the dataset CORPLIB.CIRCUL.
    NOTE: The data set WORK.USAGE has 446 observations and 9 variables.
    NOTE: DATA statement used: real time 0.22 seconds

Posted on Monday, March 31, 2008 by Registered CommenterJared in | CommentsPost a Comment

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>