SPSS Data Formats

In addition to the inherent type of data, SPSS stores both a print format and a write format. Both of these are forms of output formats.

Within the context of data reading and data exporting, additional input formats and output formats are allowed.


The print format is used for SPSS procedures and the PRINT command. Note that w is the field width and d is the number of visible decimal places.

Format

Specification

Example

String

Aw

A as A1 prints A

Hexadecimal codepoints

AHEXw

A as AHEX2 prints 41

Numeric

Fw.d

1.234 as F5.2 prints 1.23

Restricted numeric

Nw

123 as N5 prints 00123

Scientific notation

Ew.d

1234 as E10.2 prints 1234E+03

Numeric with dollar sign

DOLLARw.d

1234.56 as DOLLAR9.2 prints $1,234.56

Numeric with commas

COMMAw.d

1234.56 as COMMA9.2 prints 1,234.56

Numeric with dots

DOTw.d

1234.56 as DOT9.2 prints 1.234,56

Numeric with percent sign

PCTw.d

1234.56 as PCT9.2 prints 1234.56%

Date and time formats will print very differently depending on the field width. There are also limited valid widths for these fields.

Date or Time Format

Specification

Prototype

Date and time

DATETIME20

dd-MMM-yyyy hh:mm:ss

Date and time

DATETIME17

dd-MMM-yyyy hh:mm

Date

DATE11

dd-MMM-yyyy

Date

DATE9

dd-MMM-yy

Time

TIME8

hh:mm:ss

Time

TIME5

hh:mm

American date

ADATE10

mm/dd/yyyy

European date

EDATE10

dd.mm.yyyy

Sorted date

SDATE10

yyyy/mm/dd

Note that MMM prints as JAN, not 001.

Summary Formats

The following formats are only allowed on certain summary tables.

Format

Specification

Example

Parenthesize negative values

NEGPARENw.d

-1234.567 as NEGPAREN9.2 prints (1234.57)

Prefix with N=

NEQUALw.d

1234.567 as NEQUAL9.2 prints N=1234.57

Parenthesize values

PARENw.d

1234.567 as PAREN8.2 prints (1234.57)

Parenthesize percentage

PCTPARENw.d

1234.567 as PCTPAREN10.2 prints (1234.57%)


Write Format

The write format exactly mirrors the print format, but it is instead used by the WRITE command.


Input and Output Formats

SPSS can read and export data according to columnar or Fortran specifications. Generally speaking, these formats look like (FORMAT,d) and (FORMATw.d) respectively. Note that w is the field width and d is the implied number of decimal places.

Note however that, for free-field data input, the width and implied decimal specifications are ignored.

Columnar and Fortran Formats

Many common input formats can be expressed in columnar or Fortran styles. This is a crosswalk of the equivalent styles.

Format

Columnar Specification

Fortran Specification

Numeric

d or F,d

Fw.d

Restricted numeric

N,d

Nw.d

Scientific notation

E,d

Ew.d

Numeric with commas

COMMA,d

COMMAw.d

Numeric with dots

DOT,d

DOTw.d

Numeric with dollar sign

DOLLAR,d

DOLLARw.d

Numeric with percent sign

PCT,d

PCTw.d

Zoned decimal

Z,d

Zw.d

String

A

Aw

For columnar specifications, the numeric format is the default and needs no specification.

When the restricted numeric format is used for fixed-width input, if the input field has any other width, the value is read as system missing. For either fixed-width or free-field input, if the input field has a sign (-) or a decimal point (.), the value is read as system missing.

Fortran Formats

The Fortran style offers additional instructions and formats.

Instruction

Fortran Specification

Move to nth column

Tn

Repeat the following specification n times

nSPEC

Date or Time Prototype

Fortran Specification

dd-mmm-yyyy

DATEw

mm/dd/yyyy

ADATEw

dd/mm/yy

EDATEw

yyddd

JDATEw

yy/mm/dd

SDATEw

qQyyyy

QYRw

mm/yyyy

MOYRw

wkWKyyyy

WKYRw

dd-mmm-yyyy hh:mm:ss.ss

DATETIMEw.d

hh:mm:ss.ss

TIMEw.d

ddd hh:mm:ss.ss

DTIMEw.d

WKDAYw

MONTHw

Note that SPSS is capable of reading date and time data in columnar specifications. Simply use the standard date and time formats, as seen above under print formats.

Binary Formats

The following formats are used for reading data from COBOL, Fortran, or other low-level programs.

Format

Specification

Example

Fixed point integer binary

IBw.d

11111111 as IB8.0 reads -1

Positive fixed point integer binary

PIBw.d

11111111 as IB8.0 reads 255

Positive fixed point integer hexadecimal

PIBHEXw

FFFF as PIBHEX4 reads 65535

Zoned decimal

Zw.d

1234A as Z5.2 reads 123.41

Packed decimal

Pw.d

Unsigned packed decimal

PKw.d

Real binary

RBw

Real hexadecimal

RBHEXw

The fixed point integer binary format is modeled after the data used by COBOL in COMPUTATIONAL data items, or by FORTRAN in INTEGER*2 or INTEGER*4, or by Assembler in fullword and halfword items.

The zoned decimal format is modeled after the data used by COBOL in DISPLAY data items, or by PL/I in PICTURE data items, or by Assembler in zoned decimal data items.

The packed decimal format is modeled after the data used by COBOL in COMPUTATIONAL–3 data items, or by Assembler in packed decimal data items.

The real binary format is modeled after the data used by COBOL in COMPUTATIONAL–1 or COMPUTATIONAL–2 data items, or by PL/I in FLOATING DECIMAL data items, or by FORTRAN in REAL or REAL*8 data items, or by Assembler in floating-point data items.

After Reading Data

Once data is read into SPSS, the stored output formats are determined from the input format.

Implied decimal spaces are converted into actual decimal places, and 1 is added to the format width. For example, 1234 with an input format of F5.2 is read as 12.34 with an output format of F6.2.

Decorations and indicators are added to the format width. For example, data read with an input format DOLLAR7.2 receives an output format of DOLLAR10.2 to fit the dollar sign ($), comma (,), and decimmal (.).

Binary formats all become the standard numeric format.


CategoryRicottone

SPSS/DataFormats (last edited 2023-06-13 05:03:36 by DominicRicottone)