Examples (FORMATS command)
Changing Formats for Multiple Variables
FORMATS SALARY (DOLLAR8) /HOURLY (DOLLAR7.2)
/RAISE BONUS (PCT2).
- The print and write formats for SALARY are changed to
DOLLARformat with eight positions, including the dollar sign and comma when appropriate. The value 11550 is displayed as $11,550. An eight-digit number would require aDOLLAR11format: eight characters for the digits, two characters for commas, and one character for the dollar sign. - The print and write formats for HOURLY are changed to
DOLLARformat with seven positions, including the dollar sign, decimal point, and two decimal places. The value 115 is displayed as $115.00. IfDOLLAR6.2had 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 and write formats for both RAISE and BONUS are changed to
PCTwith 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, since the percent sign is truncated.
Changing Default Variable Formats
COMPUTE V3=V1 + V2.
FORMATS V3 (F3.1).
-
COMPUTEcreates the new numeric variable V3. By default, V3 is assigned anF8.2format (or the default format specified onSET). -
FORMATSchanges both the print and write formats for V3 toF3.1.
Working With Custom Currency Formats
SET CCA='-/-.Dfl ..-'.
FORMATS COST (CCA14.2).
-
SETdefines a European currency format for the custom currency format typeCCA. -
FORMATSassigns formatCCAto variable COST. With the format defined forCCAonSET, the value 37419 is displayed as Dfl 37.419,00. See theSETcommand for more information on custom currency formats.