Although
output is usually generated by a procedure, you can also generate
output by using a DATA step application. Using the DATA step, you
can do the following:
-
-
write to an external file
-
To generate output,
you can use the FILE and PUT statements together within the DATA step.
Use the FILE statement to identify your current output file. Then
use the PUT statement to write lines that contain variable values
or text strings to the output file. You can write the values in column,
list, or formatted style.
You can use the FILE
and PUT statements to target a subset of data. If you have a large
data set that includes unnecessary information, this type of DATA
step processing can save time and computer resources. Write your code
so that the FILE statement executes before a PUT statement in the
current execution of a DATA step. Otherwise, your data is written
to the SAS log.
If you have a SAS data
set, you can use the FILE and PUT statements to create an external
file that another computer language can process. For example, you
can create a SAS data set that lists the test scores for high school
students. You can then use this file as input to a Fortran program
that analyzes test scores. The following table lists the variables
and the column positions that an existing Fortran program expects
to find in the input SAS data set:
Table 33.1 Variables and Column Positions
|
|
|
|
|
|
|
|
|
|
You can use the FILE
and PUT statements in the DATA step to create the data set that the
Fortran program reads:
data _null_;
set out.sats1;
file 'your-output-file';
put @10 year @15 test
@30 gender @35 score;
run;