Chapter Contents |
Previous |
Next |
PUT, Column |
Valid: | in a DATA step |
Category: | File-handling |
Type: | Executable |
Syntax | |
Arguments | |
Details | |
Examples | |
See Also |
Syntax |
PUT variable start-column <--
end-column>
<.decimal-places> <@ | @@>; |
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; |
Range: | positive integer |
Tip: | If you specify 0 for d or omit d, the value is written without a decimal point. |
Featured in: | Examples |
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 will occupy 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 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.
Examples |
Use column output in the PUT statement as shown here.
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 the following lines to the SAS log:(footnote 1)
----+----1----+----2----+----3----+----4 Joseph 11 32 76 Mitchel 13 29 82 Sue Ellen 14 27 74The 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.
put score1 23-25 score2 28-30 score3 33-35 name $ 1-20;
data _null_; x=11; y=15; put x 10-18 .1 y 20-28 .1; run;
This program writes the following line to the SAS log:
----+----1----+----2----+----3----+----4 11.0 15.0
See Also |
Statement:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.