PUT Statement: Column

Writes variable values in the specified columns in the output line.

Valid in: DATA step
Categories: CAS
File-Handling
Type: Executable

Syntax

Arguments

variable

specifies the variable whose value is written.

start-column

specifies the first column of the field where the value is written in the output line.

-end-column

specifies the last column of the field for the value.

Tip If the value occupies only one column in the output line, omit end-column.
Example Because end-column is omitted, the values for the character variable GENDER occupy only column 16:
put name 1-10 gender 16;

.decimal-places

specifies the number of digits to the right of the decimal point in a numeric value.

Range positive integer
Tip If you specify 0 for d or omit d, the value is written without a decimal point.
Using Column Output in the PUT Statement

@ | @@

holds an output line for the execution of the next PUT statement even across iterations of the DATA step. These line-hold specifiers are called trailing @ and double trailing @.

Requirement The trailing @ or double trailing @ must be the last item in the PUT statement.
See Using Line-Hold Specifiers

Details

With column output, the column numbers indicate the position that each variable value occupies in the output line. If a value requires fewer columns than specified, a character variable is left-aligned in the specified columns, and a numeric variable is right-aligned in the specified columns.

There is no limit to the number of column specifications that you can make in a single PUT statement. You can write anywhere in the output line, even if a value overwrites columns that were written earlier in the same statement. You can combine column output with any of the other output styles in a single PUT statement. For more information, see Using Multiple Output Styles in a Single PUT Statement.

Example: Using Column Output in the PUT Statement

Use column output in the PUT statement as shown here.

  • This PUT statement uses column output.
    data _null_;
       input name $ 1-18 score1 score2 score3;
       put name 1-20 score1 23-25 score2 28-30
           score3 33-35;
       datalines;
    Joseph                  11   32   76
    Mitchel                 13   29   82
    Sue Ellen               14   27   74
    ;

    The program writes these lines to the SAS log.

    ----+----1----+----2----+----3----+----4
    Joseph                 11   32   76
    Mitchel                13   29   82
    Sue Ellen              14   27   74
    Note: The ruled line is for illustrative purposes only; the PUT statement does not generate it.

    The values for the character variable NAME begin in column 1, the left boundary of the specified field (columns 1 through 20). The values for the numeric variables SCORE1 through SCORE3 appear flush with the right boundary of their field.

  • This statement produces the same output lines, but writes the SCORE1 value first and the NAME value last.
    put score1 23-25 score2 28-30
        score3 33-35 name $ 1-20;
  • This DATA step specifies decimal points with column output.
    data _null_;
        x=11;
        y=15;
        put x 10-18 .1 y 20-28 .1;
    run;

    The program writes this line to the SAS log.

    ----+----1----+----2----+----3----+----4
                  11.0      15.0

See Also

Last updated: June 17, 2025