Implied Decimal Positions (DATA LIST command)

  • For fixed-format data, decimal positions can be coded in the data or implied by the format. If decimal positions are implied but are not entered in the data, the program interprets the rightmost digits in each value as the decimal digits. A coded decimal point in a value overrides the number of implied decimal places. For example, (DOLLAR,2) specifies two decimal positions. The value 123 is interpreted as 1.23; however, the value 12.3 is interpreted as 12.3 because the coded decimal position overrides the number of implied decimal positions.
  • For freefield data, decimal positions cannot be implied but must be coded in the data. If decimal positions are specified in the format but a data value does not include a decimal point, the program fills the decimal places with zeros. For example, with F3.1 format (three columns with one decimal place), the value 22 is displayed as 22.0. If a value in the data has more decimal digits than are specified in the format, the additional decimals are truncated in displayed output (but not in calculations). For example, with F3.1 format, the value 2.22 is displayed as 2.2 even though in calculations it remains 2.22.

The table below compares how values are interpreted for fixed and freefield formats. Values in the table are for a four-column numeric variable.

Table 1. Interpretation of values in fixed and freefield format
Values Fixed, default Fixed, two defined decimal places Freefield, default Freefield, two defined decimal places
2001 2001 20.01 2001.00 2001.00
201 201 2.01 201.00 201.00
–201 –201 –2.01 –201.00 –201.00
2 2 .02 2.00 2.00
20 20 .20 20.00 20.00
2.2 2.2 2.2 2.20 2.20
.201 .201 .201 .201 .201
2 01 Undefined Undefined Two values Two values

Example

DATA LIST
  /MODEL 1 RATE 2-6(PCT,2) COST 7-11(DOLLAR) READY 12-21(ADATE).
BEGIN DATA
1935  7878811-07-1988
2 16754654606-08-1989
3 17684783612-09-1989
END DATA.
  • Data are inline and in fixed format (the default).
  • Each variable is followed by its column location. After the column location, a column-style format is specified in parentheses.
  • MODEL begins in column 1, is one column wide, and receives the default numeric F format.
  • RATE begins in column 2 and ends in column 6. The PCT format is specified with two decimal places. A comma is used to separate the format type from the number of decimal places. Decimal points are not coded in the data. Thus, the program reads the rightmost digits of each value as decimal digits. The value 935 for the first case in the data is interpreted as 9.35. Note that it does not matter where numbers are entered within the column width.
  • COST begins in column 7 and ends in column 11. DOLLAR format is specified.
  • READY begins in column 12 and ends in column 21. ADATE format is specified.

Example

DATA LIST FILE="/data/data1.txt"
  /MODEL (F1) RATE (PCT5.2) COST (DOLLAR5) READY (ADATE10).
  • In this example, the FILE subcommand is used because the data are in an external file.
  • The variable definition is the same as in the preceding example except that FORTRAN-like format specifications are used rather than column-style. Column locations are not specified. Instead, the format specifications include a width for each format type.
  • The width (w) portion of each format must specify the total number of bytes in the widest value. DOLLAR5 format for COST accepts the five-digit value 78788, which displays as $78,788. Thus, the specified input format DOLLAR5 generates an output format DOLLAR7. The program automatically expands the width of the output format to accommodate the dollar sign and comma in displayed output.