Overview (PRINT FORMATS command)
PRINT FORMATS
changes variable print formats.
Print formats are output formats and control the form in which values
are displayed by a procedure or by the PRINT
command.
PRINT FORMATS
changes only print formats. To
change write formats, use the WRITE FORMATS
command.
To change both the print and write formats with a single specification,
use the FORMATS
command. For information about assigning
input formats during data definition, see DATA LIST
.
See the topic Variable Types and Formats for more information.
Basic Specification
The basic specification is a variable list followed by the new format specification in parentheses. All specified variables receive the new format.
Syntax Rules
- You can specify more than one variable or variable list, followed by a format in parentheses. Only one format can be specified after each variable list. For clarity, each set of specifications can be separated by a slash.
- You can use keyword
TO
to refer to consecutive variables in the active dataset. - The specified width of a format must include enough positions
to accommodate any punctuation characters, such as decimal points,
commas, dollar signs, or date and time delimiters. (This situation
differs from assigning an input format on
DATA LIST
, where the program automatically expands the input format to accommodate punctuation characters in output.) - Custom currency formats (
CCw
,CCw.d
) must first be defined on theSET
command before they can be used onPRINT FORMATS
. - For string variables, you can only use
PRINT FORMATS
to switch betweenA
andAHEX
formats.PRINT FORMATS
cannot be used to change the length of string variables. To change the defined length of a string variable, use theALTER TYPE
command.
Operations
- Unlike most transformations,
PRINT FORMATS
takes effect as soon as it is encountered in the command sequence. Special attention should be paid to the position ofPRINT FORMATS
among commands. - Variables that are not specified on
PRINT FORMATS
retain their current print formats in the active dataset. To see the current formats, use theDISPLAY
command. - The new print formats are changed only in the active dataset and
are in effect for the duration of the session or until changed again
with a
PRINT FORMATS
orFORMATS
command. Print formats in the original data file (if this file exists) are not changed, unless the file is resaved with theSAVE
orXSAVE
command. - New numeric variables that are created with transformation commands
are assigned default print formats of
F8.2
(or the format that is specified on theFORMAT
subcommand ofSET
). TheFORMATS
command can be used to change the new variable’s print formats. - New string variables that are created with transformation commands
are assigned the format that is specified on the
STRING
command that declares the variable.PRINT FORMATS
cannot be used to change the format of a new string variable. - If a numeric data value exceeds its width specification, the program still attempts to display some value. First, the program rounds decimal values, then removes punctuation characters, and then tries scientific notation. Finally, if there is still not enough space, the program produces asterisks indicating that a value is present but cannot be displayed in the assigned width.