O'Reilly logo

Step-by-Step Programming with Base SAS 9.4 by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Simple Text

Writing a Character String

In its simplest form, the PUT statement writes the character string that you specify to the SAS log, to a procedure output file, or to an external file. If you omit the destination (as in this example), then SAS writes the string to the log. In the following example, SAS executes the PUT statement once during each iteration of the DATA step. If SAS encounters missing values for the variables Year and Result, then the PUT statement writes a message to the log.
data _null_;
   length medalist $ 19;
   input year 1-4  medalist $ 6-24  medal $ 26-31 country $ 33-35 result 37-41; 
   if year=. then put '*** Missing Year';
      else
   if result=. then put '*** Missing Results'; datalines; 1984 Lingjuan Li SILVER CHN 2559 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required