proc print data=investment; 6
format Capital dollar12.2; 7
Begin the DATA step and create a SAS data set called Investment.
Calculate a value based on a $2,000 capital investment and 7% interest each year
from 1990 to 2009. Calculate variable values for one observation per iteration of the
Write each observation to data set Investment.
Write a note to the SAS log proving that the DATA step iterates only once.
Execute the DATA step.
To see your output, print the Investment data set with the PRINT procedure.
Use the FORMAT statement to write numeric values with dollar signs, commas, and
Execute the PRINT procedure.
Writing a Report with a DATA Step
Example 1: Creating a Report without Creating a Data Set
You can use a DATA step to generate a report without creating a data set by using
_NULL_ in the DATA statement. This approach saves system resources because SAS
does not create a data set. The report can contain both TITLE statements and
FOOTNOTE statements. If you use a FOOTNOTE statement, be sure to include
FOOTNOTE as an option in the FILE statement in the DATA step.
title1 'Budget Report'; 1
title2 'Mid-Year Totals by Department';
footnote 'compiled by Manager,
Documentation Development Department'; 2
data _null_; 3
set budget; 4
file print footnote; 5
if _n_=1 then 7
put @5 'Department' @30 'Mid-Year Total';
put @7 Department @35 MidYearTotal; 8
Define the footnote.
Begin the DATA step. _NULL_ specifies that no data set is created.
Read one observation per iteration from data set Budget.
Writing a Report with a DATA Step 419