Formats (WRITE command)

By default, WRITE uses the dictionary write formats. You can specify formats for some or all variables specified on WRITE. For a string variable, the specified format must have the same width as that of the dictionary format.

  • Format specifications can be either column-style or FORTRAN-like (see DATA LIST). The column location specified with column-style formats or implied with FORTRAN-like formats refers to the column in which the variable will be written.
  • A format specification following a list of variables applies to all the variables in the list. Use an asterisk to prevent the specified format from applying to variables preceding the asterisk. The specification of column locations implies a default print format, and that format will apply to all previous variables if no asterisk is used.
  • All available formats can be specified on WRITE. Note that hex and binary formats use different widths. For example, the AHEX format must have a width twice that of the corresponding A format. For more information on specifying formats and on the formats available, see DATA LIST and Variable Formats.
  • Format specifications are in effect only for the WRITE command. They do not change the dictionary write formats.
  • To specify a blank between variables in the output, use a string (see Strings) , specify blank columns in the format, or use an X or T format element in the WRITE specifications (see DATA LIST for information on X and T).

Example

WRITE OUTFILE='/data/personnel.txt' / TENURE (F2.0) ' ' MOHIRED YRHIRED DEPT *
        SALARY85 TO SALARY88 (4(DOLLAR8,1X)) NAME.
EXECUTE.
  • Format F2.0 is specified for TENURE. A blank between quotes is specified as a string after TENURE to separate values of TENURE from those of MOHIRED.
  • MOHIRED, YRHIRED, and DEPT are written with default formats because the asterisk prevents them from receiving the DOLLAR8 format specified for SALARY85 to SALARY88. The 1X format element is specified with DOLLAR8 to add one blank after each value of SALARY85 to SALARY88.
  • NAME uses the default dictionary format.