Next: , Previous: Sets of Variables, Up: Variables



4.6.4 Input and Output Formats

Data that PSPP inputs and outputs must have one of a number of formats. These formats are described, in general, by a format specification of the form NAMEw.d, where name is the format name and w is a field width. d is the optional desired number of decimal places, if appropriate. If d is not included then it is assumed to be 0. Some formats do not allow d to be specified.

When DATA LIST or another command specifies an input format, that format is converted to an output format for the purposes of PRINT and other data output commands. For most purposes, input and output formats are the same; the salient differences are described below.

Below are listed the input and output formats supported by PSPP. If an input format is mapped to a different output format by default, then that mapping is indicated with =>. Each format has the listed bounds on input width (iw) and output width (ow).

The standard numeric input and output formats are given in the following table:

Fw.d: 1 <= iw,ow <= 40
Standard decimal format with d decimal places. If the number is too large to fit within the field width, it is expressed in scientific notation (1.2+34) if w >= 6, with always at least two digits in the exponent. When used as an input format, scientific notation is allowed but an E or an F must be used to introduce the exponent.

The default output format is the same as the input format, except if d > 1. In that case the output w is always made to be at least 2 + d.

Ew.d: 1 <= iw <= 40; 6 <= ow <= 40
For input this is equivalent to F format except that no E or F is require to introduce the exponent. For output, produces scientific notation in the form 1.2+34. There are always at least two digits given in the exponent.

The default output w is the largest of the input w, the input d + 7, and 10. The default output d is the input d, but at least 3.

COMMAw.d: 1 <= iw,ow <= 40
Equivalent to F format, except that groups of three digits are comma-separated on output. If the number is too large to express in the field width, then first commas are eliminated, then if there is still not enough space the number is expressed in scientific notation given that w >= 6. Commas are allowed and ignored when this is used as an input format.
DOTw.d: 1 <= iw,ow <= 40
Equivalent to COMMA format except that the roles of comma and decimal point are interchanged. However: If SET /DECIMAL=DOT is in effect, then COMMA uses , for a decimal point and DOT uses . for a decimal point.
DOLLARw.d: 1 <= iw <= 40; 2 <= ow <= 40
Equivalent to COMMA format, except that the number is prefixed by a dollar sign ($) if there is room. On input the value is allowed to be prefixed by a dollar sign, which is ignored.

The default output w is the input w, but at least 2.

PCTw.d: 2 <= iw,ow <= 40
Equivalent to F format, except that the number is suffixed by a percent sign (%) if there is room. On input the value is allowed to be suffixed by a percent sign, which is ignored.

The default output w is the input w, but at least 2.

Nw.d: 1 <= iw,ow <= 40
Only digits are allowed within the field width. The decimal point is assumed to be d digits from the right margin.

The default output format is F with the same w and d, except if d > 1. In that case the output w is always made to be at least 2 + d.

Zw.d => F: 1 <= iw,ow <= 40
Zoned decimal input. If you need to use this then you know how.
IBw.d => F: 1 <= iw,ow <= 8
Integer binary format. The field is interpreted as a fixed-point positive or negative binary number in two's-complement notation. The location of the decimal point is implied. Endianness is the same as the host machine.

The default output format is F8.2 if d is 0. Otherwise it is F, with output w as 9 + input d and output d as input d.

PIB => F: 1 <= iw,ow <= 8
Positive integer binary format. The field is interpreted as a fixed-point positive binary number. The location of the decimal point is implied. Endianness is the same as the host machine.

The default output format follows the rules for IB format.

Pw.d => F: 1 <= iw,ow <= 16
Binary coded decimal format. Each byte from left to right, except the rightmost, represents two digits. The upper nibble of each byte is more significant. The upper nibble of the final byte is the least significant digit. The lower nibble of the final byte is the sign; a value of D represents a negative sign and all other values are considered positive. The decimal point is implied.

The default output format follows the rules for IB format.

PKw.d => F: 1 <= iw,ow <= 16
Positive binary code decimal format. Same as P but the last byte is the same as the others.

The default output format follows the rules for IB format.

RBw => F: 2 <= iw,ow <= 8
Binary C architecture-dependent “double” format. For a standard IEEE754 implementation w should be 8.

The default output format follows the rules for IB format.

PIBHEXw.d => F: 2 <= iw,ow <= 16
PIB format encoded as textual hex digit pairs. w must be even.

The input width is mapped to a default output width as follows: 2=>4, 4=>6, 6=>9, 8=>11, 10=>14, 12=>16, 14=>18, 16=>21. No allowances are made for decimal places.

RBHEXw => F: 4 <= iw,ow <= 16
RB format encoded as textual hex digits pairs. w must be even.

The default output format is F8.2.

CCAw.d: 1 <= ow <= 40
CCBw.d: 1 <= ow <= 40
CCCw.d: 1 <= ow <= 40
CCDw.d: 1 <= ow <= 40
CCEw.d: 1 <= ow <= 40
User-defined custom currency formats. May not be used as an input format. See SET, for more details.

The date and time numeric input and output formats accept a number of possible formats. Before describing the formats themselves, some definitions of the elements that make up their formats will be helpful:

leader
All formats accept an optional white space leader.
day
An integer between 1 and 31 representing the day of month.
day-count
An integer representing a number of days.
date-delimiter
One or more characters of white space or the following characters: - / . ,
month
A month name in one of the following forms:
year
An integer year number between 1582 and 19999, or between 1 and 199. Years between 1 and 199 will have 1900 added.
julian
A single number with a year number in the first 2, 3, or 4 digits (as above) and the day number within the year in the last 3 digits.
quarter
An integer between 1 and 4 representing a quarter.
q-delimiter
The letter Q or q.
week
An integer between 1 and 53 representing a week within a year.
wk-delimiter
The letters wk in any case.
time-delimiter
At least one characters of white space or : or ..
hour
An integer greater than 0 representing an hour.
minute
An integer between 0 and 59 representing a minute within an hour.
opt-second
Optionally, a time-delimiter followed by a real number representing a number of seconds.
hour24
An integer between 0 and 23 representing an hour within a day.
weekday
At least the first two characters of an English day word.
spaces
Any amount or no amount of white space.
sign
An optional positive or negative sign.
trailer
All formats accept an optional white space trailer.

The date input formats are strung together from the above pieces. On output, the date formats are always printed in a single canonical manner, based on field width. The date input and output formats are described below:

DATEw: 9 <= iw,ow <= 40
Date format. Input format: leader + day + date-delimiter + month + date-delimiter + year + trailer. Output format: DD-MMM-YY for w < 11, DD-MMM-YYYY otherwise.
EDATEw: 8 <= iw,ow <= 40
European date format. Input format same as DATE. Output format: DD.MM.YY for w < 10, DD.MM.YYYY otherwise.
SDATEw: 8 <= iw,ow <= 40
Standard date format. Input format: leader + year + date-delimiter + month + date-delimiter + day + trailer. Output format: YY/MM/DD for w < 10, YYYY/MM/DD otherwise.
ADATEw: 8 <= iw,ow <= 40
American date format. Input format: leader + month + date-delimiter + day + date-delimiter + year + trailer. Output format: MM/DD/YY for w < 10, MM/DD/YYYY otherwise.
JDATEw: 5 <= iw,ow <= 40
Julian date format. Input format: leader + julian + trailer. Output format: YYDDD for w < 7, YYYYDDD otherwise.
QYRw: 4 <= iw <= 40, 6 <= ow <= 40
Quarter/year format. Input format: leader + quarter + q-delimiter + year + trailer. Output format: Q Q YY, where the first Q is one of the digits 1, 2, 3, 4, if w < 8, Q Q YYYY otherwise.
MOYRw: 6 <= iw,ow <= 40
Month/year format. Input format: leader + month + date-delimiter + year + trailer. Output format: MMM YY for w < 8, MMM YYYY otherwise.
WKYRw: 6 <= iw <= 40, 8 <= ow <= 40
Week/year format. Input format: leader + week + wk-delimiter + year + trailer. Output format: WW WK YY for w < 10, WW WK YYYY otherwise.
DATETIMEw.d: 17 <= iw,ow <= 40
Date and time format. Input format: leader + day + date-delimiter + month + date-delimiter + year + time-delimiter + hour24 + time-delimiter + minute + opt-second. Output format: DD-MMM-YYYY HH:MM. If w > 19 then seconds :SS is added. If w > 22 and d > 0 then fractional seconds .SS are added.
TIMEw.d: 5 <= iw,ow <= 40
Time format. Input format: leader + sign + spaces + hour + time-delimiter + minute + opt-second. Output format: HH:MM. Seconds and fractional seconds are available with w of at least 8 and 10, respectively.
DTIMEw.d: 1 <= iw <= 40, 8 <= ow <= 40
Time format with day count. Input format: leader + sign + spaces + day-count + time-delimiter + hour + time-delimiter + minute + opt-second. Output format: DD HH:MM. Seconds and fractional seconds are available with w of at least 8 and 10, respectively.
WKDAYw: 2 <= iw,ow <= 40
A weekday as a number between 1 and 7, where 1 is Sunday. Input format: leader + weekday + trailer. Output format: as many characters, in all capital letters, of the English name of the weekday as will fit in the field width.
MONTHw: 3 <= iw,ow <= 40
A month as a number between 1 and 12, where 1 is January. Input format: leader + month + trailer. Output format: as many character, in all capital letters, of the English name of the month as will fit in the field width.

There are only two formats that may be used with string variables:

Aw: 1 <= iw <= 255, 1 <= ow <= 254
The entire field is treated as a string value.
AHEXw => A: 2 <= iw <= 254; 2 <= ow <= 510
The field is composed of characters in a string encoded as textual hex digit pairs.

The default output w is half the input w.