Examples (PRINT FORMATS command)
Basic Example
PRINT FORMATS SALARY (DOLLAR8) / HOURLY (DOLLAR7.2)
/ RAISE BONUS (PCT2).
- The print format for SALARY is changed to
DOLLAR
with eight positions, including the dollar sign and comma when appropriate. The value 11550 is displayed as $11,550. An eight-digit number requires aDOLLAR11
format specification: eight characters for digits, two characters for commas, and one character for the dollar sign. - The print format for HOURLY is changed to
DOLLAR
with seven positions, including the dollar sign, decimal point, and two decimal places. The number 115 is displayed as $115.00. IfDOLLAR6.2
had been specified, the value 115 would be displayed as $115.0. The program would truncate the last 0 because a width of 6 is not enough to display the full value. - The print format for both RAISE and BONUS is
changed to
PCT
with two positions: one position for the percentage and one position for the percent sign. The value 9 is displayed as 9%. Because the width allows for only two positions, the value 10 is displayed as 10.
Changing Default Formats
COMPUTE V3=V1 + V2.
PRINT FORMATS V3 (F3.1).
-
COMPUTE
creates the new numeric variable V3. By default, V3 is assigned anF8.2
format (or the default format that is specified onSET
). -
PRINT FORMATS
changes the print format for V3 toF3.1
.
Working With Custom Currency Formats
SET CCA='-/-.Dfl ..-'.
PRINT FORMATS COST (CCA14.2).
-
SET
defines a European currency format for the custom currency format typeCCA
. -
PRINT FORMATS
assigns the print formatCCA
to variable COST. With the format defined forCCA
onSET
, the value 37419 is displayed as Dfl’37.419,00. See theSET
command for more information about custom currency formats.