Was this helpful?
.Width Statement--Set Output Width of a Column
The .width statement sets a default output width associated with a column.
This statement has the following format:
.width | .wid columnname{, columnname} (width)
     {, columnname}{, columnname} (width)}
The parameters for the .width statement are as follows:
columnname
The name of a column in the report. You can specify the column name as a delimited identifier by enclosing it in double quotes ("), if you have previously specified the .delimid statement.
width
The width, which is the total number of characters in the column to be used when calculating the positioning for the .center and .right statements. If not specified, Report-Writer determines this numeric by looking at the default format for the column.
The columnname and width can be expressed as variables. The comma (,) and parentheses ( ) must be explicitly stated and cannot be part of the columnname or width variable.
$columnvariable
Variable whose value is the name for a column in the report. Precede the variable with a dollar sign ($).
$widthvariable
Variable whose value is the default width, which is the total number of characters in the column to be used when calculating the positioning for .center and .right statements. If not specified or evaluated, Report-Writer determines this value is determined by looking at the default format for this column.
Description
The .width sets the default width, which is the total number of characters in a column when calculating positions in the .center and .right statements. Alternatively, you can specify the default width for a column as a parameter to the .position statement. If you specify variables for columnname and width, Report-Writer evaluates the variables during the loading of the report specification, before retrieving any report data.
Normally, you do not need the .width statement because Report-Writer determines default widths by analyzing the report formatting statements, as described in Automatic Determination of Default Settings.
If the determined default width for a column is not convenient, or you would like a different width associated with a columnname, you can override the default with the .width statement. Subsequently, you can use the .right or .center statements with a columnname to use this width, in conjunction with the default position for this column, in calculating the placement of text.
If no width is specified for a column, Report-Writer determines the default width by looking at the default format for the column.
Example
To print the following columns of salaries, set up desired position, formats and widths:
 New Salary    Old Salary
 | $50,000.00 | $45,000.00 |
 | $32,000.00 | $28,800.00 |
 | $35,000.00 | $31,500.00 |
 |    $100.00 |     $90.00 |
 | $35,000.00 | $31,500.00 |
 | $25,000.00 | $22,500.00 |
 |  $5,000.00 |  $4,500.00 |

.declare salary_fmt = c14 with value '''$$$,$$$.nn''' 
.declare salary_wid = integer with value '12'
.header report
    .position sal1(0), sal2(13)
    .format   sal1, sal2  ($salary_fmt)
    .width   sal1, sal2  ($salary_wid),
    .underline
    .center   sal1  .print  'New Salary'
    .center   sal2  .print  'Old Salary'
    .newline
    .nounderline
.detail
    .left   sal1  .print  '|'
    .right   sal1  .print  sal1
    .print ' |'
    .right   sal2  .print  sal2
    .print ' |'
    .newline
Last modified date: 11/09/2022