SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Debugging and Testing DATA Steps
Testing Your Programs


Automatic Variables

You can use a PUT statement to specify the values of the automatic variables _N_ and _ERROR_. In some cases, specifying the value of _N_ can help you locate an observation in the data set:

        put 'MY NOTE: invalid value: '
             code= _n_= _error_=;

The SAS Log window displays automatic variable values.

You can also use a PUT statement to specify that all variable names and variable values, including automatic variables, be written to the log by using the _ALL_ specification:
        put 'MY NOTE: invalid value: ' _all_ ;



The SAS Log window displays all variable values.


Conditional Processing

You can use a PUT statement with conditional processing to flag program errors or data that is out of range. In the example below, the PUT statement is used to flag any missing or zero values for the variable Rate.

     data finance.newcalc;
        set finance.loans;
        if rate>0 then
           Interest=amount*(rate/12);
        else put 'DATA ERROR ' rate= _n_=;
     run;

NOTE: The PUT statement can accomplish a wide variety of tasks. This lesson shows a few ways to use the PUT statement to help you debug a program or examine variable values. For a thorough description of the PUT statement, refer to SAS Language Reference: Dictionary.



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement