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 a DOLLAR11 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. If DOLLAR6.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 an F8.2 format (or the default format that is specified on SET).
  • PRINT FORMATS changes the print format for V3 to F3.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 type CCA.
  • PRINT FORMATS assigns the print format CCA to variable COST. With the format defined for CCA on SET, the value 37419 is displayed as Dfl’37.419,00. See the SET command for more information about custom currency formats.