Previous Page | Next Page

Writing Lines to the SAS Log or to an Output File

Writing Output without Creating a Data Set

In many cases, when you use a DATA step to write a report, you do not need to create an additional data set. When you use the DATA _NULL_ statement, SAS processes the DATA step without writing observations to a data set. Using the DATA _NULL_ statement can increase program efficiency considerably.

The following is an example of a DATA _NULL_ statement:

data _null_;
   

The following program uses a PUT statement to write newspaper circulation values to the SAS log. Because the program uses a DATA _NULL_ statement, SAS does not create a data set.

data _null_;
   length state $ 15;
   input state $ morning_copies evening_copies year;
   put state morning_copies evening_copies year;
   datalines;
Massachusetts 798.4 984.7 1999
Massachusetts 834.2 793.6 1998
Massachusetts 750.3 .     1997
Alabama       .     698.4 1999
Alabama       463.8 522.0 1998
Alabama       583.2 234.9 1997
Alabama       .     339.6 1996
;

The following output shows the results:

Writing to the SAS Log

184  data _null_;
185     length state $ 15;
186     input state $ morning_copies evening_copies year;
187     put state morning_copies evening_copies year;
188     datalines;
Massachusetts 798.4 984.7 1999
Massachusetts 834.2 793.6 1998
Massachusetts 750.3 . 1997
Alabama . 698.4 1999
Alabama 463.8 522 1998
Alabama 583.2 234.9 1997
Alabama . 339.6 1996
      
196  ;

SAS indicates missing numeric values with a period. Note that the log contains three missing values.

Previous Page | Next Page | Top of Page