Formats (PRINT command)

By default, PRINT uses the dictionary print formats. You can specify formats for some or all variables that are specified on PRINT. For a string variable, the specified format must have a width at least as large as the width of the dictionary format. String values are truncated if the specified width is smaller than the width of the dictionary format.

  • Format specifications can be either column-style or FORTRAN-like (see DATA LIST). The column location that is specified with column-style formats or that is implied with FORTRAN-like formats refers to the column in which the variable will be displayed.
  • A format specification following a list of variables applies to all variables in the list. Use an asterisk to prevent the specified format from applying to variables that precede the asterisk. The specification of column locations implies a default print format, and that format applies to all previous variables if no asterisk is used.
  • Printable numeric formats are F, COMMA, DOLLAR, CC, DOT, N, E, PCT, PIBHEX, RBHEX, Z, and the date and time formats. Printable string formats are A and AHEX. Note that hex and binary formats use different widths. For example, the AHEX format must have a width that is twice the width of the corresponding A format. For more information about specifying formats and more information about the available formats, see DATA LIST and Variable Formats .
  • Format specifications are in effect only for the PRINT command. The specifications do not change the dictionary print formats.
  • When a format is specified for a variable, the automatic blank following the variable in the output is suppressed. To preserve the blank between variables, use a string (see Strings), specify blank columns in the format, or use an X or T format element (see DATA LIST for information about X and T).

Example

PRINT / TENURE (F2.0) ' ' MOHIRED YRHIRED DEPT *
        SALARY85 TO SALARY88 (4(DOLLAR8,1X)) NAME.
EXECUTE.
  • Format F2.0 is specified for TENURE. A blank string is specified after TENURE because the automatic blank following the variable is suppressed by the format specification.
  • MOHIRED, YRHIRED, and DEPT are displayed with default formats because the asterisk prevents them from receiving the DOLLAR8 format that is specified for SALARY85 to SALARY88. The automatic blank is preserved for MOHIRED, YRHIRED, and DEPT, but the blank is suppressed for SALARY85 to SALARY88 by the format specification. The 1X format element is therefore specified with DOLLAR8 to add one blank after each value of SALARY85 to SALARY88.
  • NAME uses the default dictionary format.