PUT Statement |
The PUT statement writes data to an external file.
The arguments to the PUT statement are as follows:
specifies the value you want to output to the current position in the record. The operand can be either a variable name, a literal value, or an expression in parentheses. The operand can be followed immediately by an output format specification.
start new records. There are three types:
is used at the end of a PUT statement to hold the current record so that you can continue to write more data to the record with later PUT statements. Otherwise, the next record is used for the next PUT statement.
writes out the current record and begins forming a new record.
specifies that the next record written start at the indicated byte position in the file (for RECFM=N files only). The operand is a literal number, a variable name, or an expression in parentheses. For example:
put >3 x 3.2;
specify the column on the record to which the PUT statement should go. There are two types of positionals:
specifies to go to the indicated column, where operand is a literal number, a variable name, or an expression in parentheses. For example, @30 means to go to column 30.
specifies that the indicated number of columns are to be skipped, where operand is a literal number, a variable name, or an expression in parentheses.
specifies a valid SAS or user-defined output format. These are of the form or $. for standard numeric and character formats, respectively, where is the width of the field and is the decimal parameter, if any. They can also be a named format of the form NAME, where NAME is the name of the format. If the width is unspecified, then a default width is used; this is 9 for numeric variables.
The PUT statement writes to the file specified in the previously executed FILE statement, putting the values from matrices. The statement is described in detail in Chapter 8.
The PUT statement is a sequence of positionals and record directives, variables, and formats. An example that uses the PUT statement follows:
/* output variable A in column 1 using a 6.4 format */ /* Skip 3 columns and output X using an 8.4 format */ put @1 a 6.4 +3 x 8.4;