SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Debugging and Testing DATA Steps
Testing Your Programs


PUT Statement

When the source of program errors may not be apparent, you can use the PUT statement to examine variable values and generate your own message in the log.

     data test;
        if code='1' then Type='Variable';
        else if code='2' then Type='Fixed';
        else put 'MY NOTE: invalid value: '
             code=;
     run;

In this example, if Code does not have the expected values of 1 or 2, the PUT statement above writes a message to the log:


The SAS Log window displays PUT message.


General form, simple PUT statement:
PUT specification(s);

where specification specifies what is written, how it is written, and where it is written. This can include

  • a character string
  • one or more data set variables
  • the automatic variables _N_ and _ERROR_
  • the automatic variable _ALL_

and much more. The following pages show examples of PUT specifications.



back||next


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

Terms of Use & Legal Information | Privacy Statement