This manual is for GNU PSPP version 0.6.2, software for statistical analysis.
Copyright © 1997, 1998, 2004, 2005 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.”(a) The FSF's Back-Cover Text is: “You have the freedom to copy and modify this GNU manual.”
PSPP is a tool for statistical analysis of sampled data. It reads a syntax file and a data file, analyzes the data, and writes the results to a listing file or to standard output.
The language accepted by PSPP is similar to those accepted by SPSS statistical products. The details of PSPP's language are given later in this manual.
PSPP produces output in two forms: tables and charts. Both of these can be written in several formats; currently, ASCII, PostScript, and HTML are supported. In the future, more drivers, such as PCL and X Window System drivers, may be developed. For now, Ghostscript, available from the Free Software Foundation, may be used to convert PostScript chart output to other formats.
The current version of PSPP, 0.6.2, is woefully incomplete in terms of its statistical procedure support. PSPP is a work in progress. The author hopes to fully support all features in the products that PSPP replaces, eventually. The author welcomes questions, comments, donations, and code submissions. See Submitting Bug Reports, for instructions on contacting the author.
PSPP is not in the public domain. It is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of this program that they might get from you.
Specifically, we want to make sure that you have the right to give away copies of PSPP, that you receive source code or else can get it if you want it, that you can change these programs or use pieces of them in new free programs, and that you know you can do these things.
To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of PSPP, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone finds out that there is no warranty for PSPP. If these programs are modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise conditions of the license for PSPP are found in the GNU General Public License. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. This manual specifically is covered by the GNU Free Documentation License (see GNU Free Documentation License).
pspp [ -B dir | --config-dir=dir ] [ -o device | --device=device ]
[ -d var[=value] | --define=var[=value] ] [-u var | --undef=var ]
[ -f file | --out-file=file ] [ -p | --pipe ] [ -I- | --no-include ]
[ -I dir | --include=dir ] [ -i | --interactive ]
[ -n | --edit | --dry-run | --just-print | --recon ]
[ -r | --no-statrc ] [ -h | --help ] [ -l | --list ]
[ -c command | --command command ] [ -s | --safer ]
[ --testing-mode ] [ -V | --version ] [ -v | --verbose ]
[ key=value ] file...
Syntax files and output device substitutions can be specified on PSPP's command line:
-i or
--interactive option is given (see Language control options).
=valueThere is one other way to specify a syntax file, if your operating system supports it. If you have a syntax file foobar.stat, put the notation
#! /usr/local/bin/pspp
at the top, and mark the file as executable with chmod +x
foobar.stat. (If PSPP is not installed in /usr/local/bin,
then insert its actual installation directory into the syntax file
instead.) Now you should be able to invoke the syntax file just by
typing its name. You can include any options on the command line as
usual. PSPP entirely ignores any lines beginning with ‘#!’.
Configuration options are used to change PSPP's configuration for the current run. The configuration options are:
-a {compatible|enhanced}--algorithm={compatible|enhanced}compatible, then PSPP will use the same algorithms
as used by some proprietary statistical analysis packages.
This is not recommended, as these algorithms are inferior and in some cases
compeletely broken.
The default setting is enhanced.
Certain commands have subcommands which allow you to override this setting on
a per command basis.
-B dir--config-dir=dir-o device--device=deviceInput and output options affect how PSPP reads input and writes output. These are the input and output options:
-f file--out-file=file-p--pipe-f file and --file=file options.
-I---no-include-I dir--include=dir-c command--command=command--testing-modemake
check and similar scripts.
Language control options control how PSPP syntax files are parsed and interpreted. The available language control options are:
-i--interactiveIn addition, this forces syntax files to be interpreted in interactive
mode, rather than the default batch mode. See Tokenizing lines, for
information on the differences between batch mode and interactive mode
command interpretation.
-n--edit--dry-run--just-print--recon-r--no-statrc-s--saferInformational options cause information about PSPP to be written to the terminal. Here are the available options:
-h--help-l--list-x {compatible|enhanced}--syntax={compatible|enhanced}compatible, then PSPP will only accept command syntax that
is compatible with the proprietary program SPSS.
If you choose enhanced then additional syntax will be available.
The default is enhanced.
-V--version-v--verboseThis option can be given multiple times to set the verbosity level to that value. The default verbosity level is 0, in which no informational messages will be displayed.
Higher verbosity levels cause messages to be displayed when the corresponding events take place.
Each verbosity level also includes messages from lower verbosity levels.
Please note: PSPP is not even close to completion. Only a few statistical procedures are implemented. PSPP is a work in progress.
This chapter discusses elements common to many PSPP commands. Later chapters will describe individual commands in detail.
PSPP divides most syntax file lines into series of short chunks called tokens. Tokens are then grouped to form commands, each of which tells PSPP to take some action—read in data, write out data, perform a statistical procedure, etc. Each type of token is described below.
. _ $ # @
Identifiers may be any length, but only the first 64 bytes are
significant. Identifiers are not case-sensitive: foobar,
Foobar, FooBar, FOOBAR, and FoObaR are
different representations of the same identifier.
Some identifiers are reserved. Reserved identifiers may not be used in any context besides those explicitly described in this manual. The reserved identifiers are:
ALL AND BY EQ GE GT LE LT NE NOT OR TO WITH
Reserved identifiers are always used as keywords. Other identifiers
may be used both as keywords and as user-defined identifiers, such as
variable names.
-5 3.14159265359 1e100 -.707 8945.
Negative numbers are expressed with a ‘-’ prefix. However, in situations where a literal ‘-’ token is expected, what appears to be a negative number is treated as ‘-’ followed by a positive number.
No white space is allowed within a number token, except for horizontal white space between ‘-’ and the rest of the number.
The last example above, ‘8945.’ will be interpreted as two
tokens, ‘8945’ and ‘.’, if it is the last token on a line.
See Forming commands of tokens.
Strings can be concatenated using ‘+’, so that ‘"a" + 'b' + 'c'’ is equivalent to ‘'abc'’. Concatenation is useful for splitting a single string across multiple source lines. The maximum length of a string, after concatenation, is 255 characters.
Strings may also be expressed as hexadecimal, octal, or binary character values by prefixing the initial quote character by ‘X’, ‘O’, or ‘B’ or their lowercase equivalents. Each pair, triplet, or octet of characters, according to the radix, is transformed into a single character with the given value. If there is an incomplete group of characters, the missing final digits are assumed to be ‘0’. These forms of strings are nonportable because numeric values are associated with different characters by different operating systems. Therefore, their use should be confined to syntax files that will not be widely distributed.
The character with value 00 is reserved for
internal use by PSPP. Its use in strings causes an error and
replacement by a space character.
, / = ( ) + - * / ** < <= <> > >= ~= & | .
Most of these appear within the syntax of commands, but the period (‘.’) punctuator is used only at the end of a command. It is a punctuator only as the last character on a line (except white space). When it is the last non-space character on a line, a period is not treated as part of another token, even if it would otherwise be part of, e.g., an identifier or a floating-point number.
Actually, the character that ends a command can be changed with SET's ENDCMD subcommand (see SET), but we do not recommend doing so. Throughout the remainder of this manual we will assume that the default setting is in effect.
Most PSPP commands share a common structure. A command begins with a command name, such as FREQUENCIES, DATA LIST, or N OF CASES. The command name may be abbreviated to its first word, and each word in the command name may be abbreviated to its first three or more characters, where these abbreviations are unambiguous.
The command name may be followed by one or more subcommands. Each subcommand begins with a subcommand name, which may be abbreviated to its first three letters. Some subcommands accept a series of one or more specifications, which follow the subcommand name, optionally separated from it by an equals sign (‘=’). Specifications may be separated from each other by commas or spaces. Each subcommand must be separated from the next (if any) by a forward slash (‘/’).
There are multiple ways to mark the end of a command. The most common way is to end the last line of the command with a period (‘.’) as described in the previous section (see Tokens). A blank line, or one that consists only of white space or comments, also ends a command by default, although you can use the NULLINE subcommand of SET to disable this feature (see SET).
There are two variants of command syntax, viz: batch mode and interactive mode. Batch mode is the default when reading commands from a file. Interactive mode is the default when commands are typed at a prompt by a user. Certain commands, such as INSERT (see INSERT), may explicitly change the syntax mode.
In batch mode, any line that contains a non-space character in the leftmost column begins a new command. Thus, each command consists of a flush-left line followed by any number of lines indented from the left margin. In this mode, a plus or minus sign (‘+’, ‘−’) as the first character in a line is ignored and causes that line to begin a new command, which allows for visual indentation of a command without that command being considered part of the previous command. The period terminating the end of a command is optional but recommended.
In interactive mode, each command must either be terminated with a period, or an empty line must follow the command. The use of (‘+’ and ‘−’ as continuation characters is not permitted.
Commands in PSPP are divided roughly into six categories:
PSPP does not place many restrictions on ordering of commands. The main restriction is that variables must be defined before they are otherwise referenced. This section describes the details of command ordering, but most users will have no need to refer to them.
PSPP possesses five internal states, called initial, INPUT PROGRAM, FILE TYPE, transformation, and procedure states. (Please note the distinction between the INPUT PROGRAM and FILE TYPE commands and the INPUT PROGRAM and FILE TYPE states.)
PSPP starts in the initial state. Each successful completion of a command may cause a state transition. Each type of command has its own rules for state transitions:
PSPP includes special support for unknown numeric data values. Missing observations are assigned a special value, called the system-missing value. This “value” actually indicates the absence of a value; it means that the actual value is unknown. Procedures automatically exclude from analyses those observations or cases that have missing values. Details of missing value exclusion depend on the procedure and can often be controlled by the user; refer to descriptions of individual procedures for details.
The system-missing value exists only for numeric variables. String variables always have a defined value, even if it is only a string of spaces.
Variables, whether numeric or string, can have designated user-missing values. Every user-missing value is an actual value for that variable. However, most of the time user-missing values are treated in the same way as the system-missing value. String variables that are wider than a certain width, usually 8 characters (depending on computer architecture), cannot have user-missing values.
For more information on missing values, see the following sections: Variables, MISSING VALUES, Expressions. See also the documentation on individual procedures for information on how they handle missing values.
Variables are the basic unit of data storage in PSPP. All the variables in a file taken together, apart from any associated data, are said to form a dictionary. Some details of variables are described in the sections below.
Each variable has a number of attributes, including:
Some system variable names begin with ‘$’, but user-defined variables' names may not begin with ‘$’.
The final character in a variable name should not be ‘.’, because
such an identifier will be misinterpreted when it is the final token
on a line: FOO. will be divided into two separate tokens,
‘FOO’ and ‘.’, indicating end-of-command. See Tokens.
The final character in a variable name should not be ‘_’, because some such identifiers are used for special purposes by PSPP procedures.
As with all PSPP identifiers, variable names are not case-sensitive. PSPP capitalizes variable names on output the same way they were capitalized at their point of definition in the input.
Certain systems may consider strings longer than 8
characters to be short strings. Eight characters represents a minimum
figure for the maximum length of a short string.
There are seven system variables. These are not like ordinary variables because system variables are not always stored. They can be used only in expressions. These system variables, whose values and output formats cannot be modified, are described below.
$CASENUM$DATEDD MMM YY.
$JDATE$LENGTH$SYSMIS$TIME$WIDTH
To refer to a set of variables, list their names one after another.
Optionally, their names may be separated by commas. To include a
range of variables from the dictionary in the list, write the name of
the first and last variable in the range, separated by TO. For
instance, if the dictionary contains six variables with the names
ID, X1, X2, GOAL, MET, and
NEXTGOAL, in that order, then X2 TO MET would include
variables X2, GOAL, and MET.
Commands that define variables, such as DATA LIST, give
TO an alternate meaning. With these commands, TO define
sequences of variables whose names end in consecutive integers. The
syntax is two identifiers that begin with the same root and end with
numbers, separated by TO. The syntax X1 TO X5 defines 5
variables, named X1, X2, X3, X4, and
X5. The syntax ITEM0008 TO ITEM0013 defines 6
variables, named ITEM0008, ITEM0009, ITEM0010,
ITEM0011, ITEM0012, and ITEM00013. The syntaxes
QUES001 TO QUES9 and QUES6 TO QUES3 are invalid.
After a set of variables has been defined with DATA LIST or another command with this method, the same set can be referenced on later commands using the same syntax.
An input format describes how to interpret the contents of an input field as a number or a string. It might specify that the field contains an ordinary decimal number, a time or date, a number in binary or hexadecimal notation, or one of several other notations. Input formats are used by commands such as DATA LIST that read data or syntax files into the PSPP active file.
Every input format corresponds to a default output format that specifies the formatting used when the value is output later. It is always possible to explicitly specify an output format that resembles the input format. Usually, this is the default, but in cases where the input format is unfriendly to human readability, such as binary or hexadecimal formats, the default output format is an easier-to-read decimal format.
Every variable has two output formats, called its print format and write format. Print formats are used in most output contexts; write formats are used only by WRITE (see WRITE). Newly created variables have identical print and write formats, and FORMATS, the most commonly used command for changing formats (see FORMATS), sets both of them to the same value as well. Thus, most of the time, the distinction between print and write formats is unimportant.
Input and output formats are specified to PSPP with a format
specification of the form TYPEw or TYPEw.d, where
TYPE is one of the format types described later, w is a
field width measured in columns, and d is an optional number of
decimal places. If d is omitted, a value of 0 is assumed. Some
formats do not allow a nonzero d to be specified.
The following sections describe the input and output formats supported by PSPP.
The basic numeric formats are used for input and output of real numbers in standard or scientific notation. The following table shows an example of how each format displays positive and negative numbers with the default decimal point setting:
| Format | 3141.59 | -3141.59
|
|---|---|---|
| F8.2 | 3141.59 | -3141.59
|
| COMMA9.2 | 3,141.59 | -3,141.59
|
| DOT9.2 | 3.141,59 | -3.141,59
|
| DOLLAR10.2 | $3,141.59 | -$3,141.59
|
| PCT9.2 | 3141.59% | -3141.59%
|
| E8.1 | 3.1E+003 | -3.1E+003
|
On output, numbers in F format are expressed in standard decimal notation with the requested number of decimal places. The other formats output some variation on this style:
On input, the basic numeric formats accept positive and numbers in standard decimal notation or scientific notation. Leading and trailing spaces are allowed. An empty or all-spaces field, or one that contains only a single period, is treated as the system missing value.
In scientific notation, the exponent may be introduced by a sign (‘+’ or ‘-’), or by one of the letters ‘e’ or ‘d’ (in uppercase or lowercase), or by a letter followed by a sign. A single space may follow the letter or the sign or both.
On fixed-format DATA LIST (see DATA LIST FIXED) and in a few
other contexts, decimals are implied when the field does not contain a
decimal point. In F6.5 format, for example, the field 314159 is
taken as the value 3.14159 with implied decimals. Decimals are never
implied if an explicit decimal point is present or if scientific
notation is used.
E and F formats accept the basic syntax already described. The other formats allow some additional variations:
All of the basic number formats have a maximum field width of 40 and accept no more than 16 decimal places, on both input and output. Some additional restrictions apply:
More details of basic numeric output formatting are given below:
3 in F1.0 format, and -1.125 as -1.13 in F5.1
format.
In scientific notation, the number always includes a decimal point, even if it is not followed by a digit.
-$9.99.
+Infinity or -Infinity for infinities, from
NaN for “not a number,” or from Unknown for other values
(if any are supported by the system). In fields under 3 columns wide,
special values are output as asterisks.
The custom currency formats are closely related to the basic numeric formats, but they allow users to customize the output format. The SET command configures custom currency formats, using the syntax
SET CCx="string".
where x is A, B, C, D, or E, and string is no more than 16 characters long.
string must contain exactly three commas or exactly three periods (but not both), except that a single quote character may be used to “escape” a following comma, period, or single quote. If three commas are used, commas will be used for grouping in output, and a period will be used as the decimal point. Uses of periods reverses these roles.
The commas or periods divide string into four fields, called the negative prefix, prefix, suffix, and negative suffix, respectively. The prefix and suffix are added to output whenever space is available. The negative prefix and negative suffix are always added to a negative number when the output includes a nonzero digit.
The following syntax shows how custom currency formats could be used to reproduce basic numeric formats:
SET CCA="-,,,". /* Same as COMMA.
SET CCB="-...". /* Same as DOT.
SET CCC="-,$,,". /* Same as DOLLAR.
SET CCD="-,,%,". /* Like PCT, but groups with commas.
Here are some more examples of custom currency formats. The final example shows how to use a single quote to escape a delimiter:
SET CCA=",EUR,,-". /* Euro.
SET CCB="(,USD ,,)". /* US dollar.
SET CCC="-.R$..". /* Brazilian real.
SET CCD="-,, NIS,". /* Israel shekel.
SET CCE="-.Rp'. ..". /* Indonesia Rupiah.
These formats would yield the following output:
| Format | 3145.59 | -3145.59
|
|---|---|---|
| CCA12.2 | EUR3,145.59 | EUR3,145.59-
|
| CCB14.2 | USD 3,145.59 | (USD 3,145.59)
|
| CCC11.2 | R$3.145,59 | -R$3.145,59
|
| CCD13.2 | 3,145.59 NIS | -3,145.59 NIS
|
| CCE10.0 | Rp. 3.146 | -Rp. 3.146
|
The default for all the custom currency formats is ‘-,,,’, equivalent to COMMA format.
The N and Z numeric formats provide compatibility with legacy file formats. They have much in common:
The N format supports input and output of fields that contain only digits. On input, leading or trailing spaces, a decimal point, or any other non-digit character causes the field to be read as the system-missing value. As a special exception, an N format used on DATA LIST FREE or DATA LIST LIST is treated as the equivalent F format.
On output, N pads the field on the left with zeros. Negative numbers are output like the system-missing value.
The Z format is a “zoned decimal” format used on IBM mainframes. Z format encodes the sign as part of the final digit, which must be one of the following:
0123456789
{ABCDEFGHI
}JKLMNOPQR
where the characters in each row represent digits 0 through 9 in order. Characters in the first two rows indicate a positive sign; those in the third indicate a negative sign.
On output, Z fields are padded on the left with spaces. On input, leading and trailing spaces are ignored. Any character in an input field other than spaces, the digit characters above, and ‘.’ causes the field to be read as system-missing.
The decimal point character for input and output is always ‘.’, even if the decimal point character is a comma (see SET DECIMAL).
Nonzero, negative values output in Z format are marked as negative even when no nonzero digits are output. For example, -0.2 is output in Z1.0 format as ‘J’. The “negative zero” value supported by most machines is output as positive.
The binary and hexadecimal formats are primarily designed for compatibility with existing machine formats, not for human readability. All of them therefore have a F format as default output format. Some of these formats are only portable between machines with compatible byte ordering (endianness) or floating-point format.
Binary formats use byte values that in text files are interpreted as special control functions, such as carriage return and line feed. Thus, data in binary formats should not be included in syntax files or read from data files with variable-length records, such as ordinary text files. They may be read from or written to data files with fixed-length records. See FILE HANDLE, for information on working with fixed-length records.
These are binary-coded decimal formats, in which every byte (except the last, in P format) represents two decimal digits. The most-significant 4 bits of the first byte is the most-significant decimal digit, the least-significant 4 bits of the first byte is the next decimal digit, and so on.
In P format, the most-significant 4 bits of the last byte are the least-significant decimal digit. The least-significant 4 bits represent the sign: decimal 15 indicates a negative value, decimal 13 indicates a positive value.
Numbers are rounded downward on output. The system-missing value and numbers outside representable range are output as zero.
The maximum field width is 16. Decimal places may range from 0 up to the number of decimal digits represented by the field.
The default output format is an F format with twice the input field width, plus one column for a decimal point (if decimal places were requested).
These are integer binary formats. IB reads and writes 2's complement binary integers, and PIB reads and writes unsigned binary integers. The byte ordering is by default the host machine's, but SET RIB may be used to select a specific byte ordering for reading (see SET RIB) and SET WIB, similarly, for writing (see SET WIB).
The maximum field width is 8. Decimal places may range from 0 up to the number of decimal digits in the largest value representable in the field width.
The default output format is an F format whose width is the number of decimal digits in the largest value representable in the field width, plus 1 if the format has decimal places.
This is a binary format for real numbers. By default it reads and writes the host machine's floating-point format, but SET RRB may be used to select an alternate floating-point format for reading (see SET RRB) and SET WRB, similarly, for writing (see SET WRB).
The recommended field width depends on the floating-point format. NATIVE (the default format), IDL, IDB, VD, VG, and ZL formats should use a field width of 8. ISL, ISB, VF, and ZS formats should use a field width of 4. Other field widths will not produce useful results. The maximum field width is 8. No decimal places may be specified.
The default output format is F8.2.
These are hexadecimal formats, for reading and writing binary formats where each byte has been recoded as a pair of hexadecimal digits.
A hexadecimal field consists solely of hexadecimal digits ‘0’...‘9’ and ‘A’...‘F’. Uppercase and lowercase are accepted on input; output is in uppercase.
Other than the hexadecimal representation, these formats are equivalent to PIB and RB formats, respectively. However, bytes in PIBHEX format are always ordered with the most-significant byte first (big-endian order), regardless of the host machine's native byte order or PSPP settings.
Field widths must be even and between 2 and 16. RBHEX format allows no decimal places; PIBHEX allows as many decimal places as a PIB format with half the given width.
In PSPP, a time is an interval. The time formats translate between human-friendly descriptions of time intervals and PSPP's internal representation of time intervals, which is simply the number of seconds in the interval. PSPP has two time formats:
| Time Format | Template | Example
|
|---|---|---|
| TIME | hh:MM:SS.ss | 04:31:17.01
|
| DTIME | DD HH:MM:SS.ss | 00 04:31:17.01
|
A date is a moment in the past or the future. Internally, PSPP represents a date as the number of seconds since the epoch, midnight, Oct. 14, 1582. The date formats translate between human-readable dates and PSPP's numeric representation of dates and times. PSPP has several date formats:
| Date Format | Template | Example
|
|---|---|---|
| DATE | dd-mmm-yyyy | 01-OCT-1978
|
| ADATE | mm/dd/yyyy | 10/01/1978
|
| EDATE | dd.mm.yyyy | 01.10.1978
|
| JDATE | yyyyjjj | 1978274
|
| SDATE | yyyy/mm/dd | 1978/10/01
|
| QYR | q Q yyyy | 3 Q 1978
|
| MOYR | mmm yyyy | OCT 1978
|
| WKYR | ww WK yyyy | 40 WK 1978
|
| DATETIME | dd-mmm-yyyy HH:MM:SS.ss | 01-OCT-1978 04:31:17.01
|
The templates in the preceding tables describe how the time and date formats are input and output:
ddmmmmmmm is output as two digits, mmm as the
first three letters of an English month name (January, February,
...). In input, both of these formats, plus Roman numerals, are
accepted.
yyyyjjjqwwDDhhHHMMSS.ssFor output, the date and time formats use the delimiters indicated in the table. For input, date components may be separated by spaces or by one of the characters ‘-’, ‘/’, ‘.’, or ‘,’, and time components may be separated by spaces, ‘:’, or ‘.’. On input, the ‘Q’ separating quarter from year and the ‘WK’ separating week from year may be uppercase or lowercase, and the spaces around them are optional.
On input, all time and date formats accept any amount of leading and trailing white space.
The maximum width for time and date formats is 40 columns. Minimum input and output width for each of the time and date formats is shown below:
| Format | Min. Input Width | Min. Output Width | Option
|
|---|---|---|---|
| DATE | 8 | 9 | 4-digit year
|
| ADATE | 8 | 8 | 4-digit year
|
| EDATE | 8 | 8 | 4-digit year
|
| JDATE | 5 | 5 | 4-digit year
|
| SDATE | 8 | 8 | 4-digit year
|
| QYR | 4 | 6 | 4-digit year
|
| MOYR | 6 | 6 | 4-digit year
|
| WKYR | 6 | 8 | 4-digit year
|
| DATETIME | 17 | 17 | seconds
|
| TIME | 5 | 5 | seconds
|
| DTIME | 8 | 8 | seconds
|
For the time and date formats, the default output format is the same as the input format, except that PSPP increases the field width, if necessary, to the minimum allowed for output.
Time or dates narrower than the field width are right-justified within the field.
When a time or date exceeds the field width, characters are trimmed from the end until it fits. This can occur in an unusual situation, e.g. with a year greater than 9999 (which adds an extra digit), or for a negative value on TIME or DTIME (which adds a leading minus sign).
The system-missing value is output as a period at the right end of the field.
The WKDAY and MONTH formats provide input and output for the names of weekdays and months, respectively.
On output, these formats convert a number between 1 and 7, for WKDAY, or between 1 and 12, for MONTH, into the English name of a day or month, respectively. If the name is longer than the field, it is trimmed to fit. If the name is shorter than the field, it is padded on the right with spaces. Values outside the valid range, and the system-missing value, are output as all spaces.
On input, English weekday or month names (in uppercase or lowercase) are converted back to their corresponding numbers. Weekday and month names may be abbreviated to their first 2 or 3 letters, respectively.
The field width may range from 2 to 40, for WKDAY, or from 3 to 40, for MONTH. No decimal places are allowed.
The default output format is the same as the input format.
The A and AHEX formats are the only ones that may be assigned to string variables. Neither format allows any decimal places.
In A format, the entire field is treated as a string value. The field width may range from 1 to 32,767, the maximum string width. The default output format is the same as the input format.
In AHEX format, the field is composed of characters in a string encoded as hex digit pairs. On output, hex digits are output in uppercase; on input, uppercase and lowercase are both accepted. The default output format is A format with half the input width.
Most of the time, variables don't retain their values between cases. Instead, either they're being read from a data file or the active file, in which case they assume the value read, or, if created with COMPUTE or another transformation, they're initialized to the system-missing value or to blanks, depending on type.
However, sometimes it's useful to have a variable that keeps its value between cases. You can do this with LEAVE (see LEAVE), or you can use a scratch variable. Scratch variables are variables whose names begin with an octothorpe (‘#’).
Scratch variables have the same properties as variables left with LEAVE: they retain their values between cases, and for the first case they are initialized to 0 or blanks. They have the additional property that they are deleted before the execution of any procedure. For this reason, scratch variables can't be used for analysis. To use a scratch variable in an analysis, use COMPUTE (see COMPUTE) to copy its value into an ordinary variable, then use that ordinary variable in the analysis.
PSPP makes use of many files each time it runs. Some of these it reads, some it writes, some it creates. Here is a table listing the most important of these files:
A file handle is a reference to a data file, system file, portable file, or scratch file. Most often, a file handle is specified as the name of a file as a string, that is, enclosed within ‘'’ or ‘"’.
A file name string that begins or ends with ‘|’ is treated as the
name of a command to pipe data to or from. You can use this feature
to read data over the network using a program such as ‘curl’
(e.g. GET '|curl -s -S http://example.com/mydata.sav'), to
read compressed data from a file using a program such as ‘zcat’
(e.g. GET '|zcat mydata.sav.gz'), and for many other
purposes.
PSPP also supports declaring named file handles with the FILE HANDLE command. This command associates an identifier of your choice (the file handle's name) with a file. Later, the file handle name can be substituted for the name of the file. When PSPP syntax accesses a file multiple times, declaring a named file handle simplifies updating the syntax later to use a different file. Use of FILE HANDLE is also required to read data files in binary formats. See FILE HANDLE, for more information.
PSPP assumes that a file handle name that begins with ‘#’ refers to a scratch file, unless the name has already been declared on FILE HANDLE to refer to another kind of file. A scratch file is similar to a system file, except that it persists only for the duration of a given PSPP session. Most commands that read or write a system or portable file, such as GET and SAVE, also accept scratch file handles. Scratch file handles may also be declared explicitly with FILE HANDLE. Scratch files are a PSPP extension.
In some circumstances, PSPP must distinguish whether a file handle refers to a system file or a portable file. When this is necessary to read a file, e.g. as an input file for GET or MATCH FILES, PSPP uses the file's contents to decide. In the context of writing a file, e.g. as an output file for SAVE or AGGREGATE, PSPP decides based on the file's name: if it ends in ‘.por’ (with any capitalization), then PSPP writes a portable file; otherwise, PSPP writes a system file.
INLINE is reserved as a file handle name. It refers to the “data file” embedded into the syntax file between BEGIN DATA and END DATA. See BEGIN DATA, for more information.
The file to which a file handle refers may be reassigned on a later FILE HANDLE command if it is first closed using CLOSE FILE HANDLE. The CLOSE FILE HANDLE command is also useful to free the storage associated with a scratch file. See CLOSE FILE HANDLE, for more information.
The syntax of some parts of the PSPP language is presented in this manual using the formalism known as Backus-Naur Form, or BNF. The following table describes BNF:
numberintegerstringvar-name=, /, +, -, etc..var-listALL.
expressionExpressions share a common syntax each place they appear in PSPP commands. Expressions are made up of operands, which can be numbers, strings, or variable names, separated by operators. There are five types of operators: grouping, arithmetic, logical, relational, and functions.
Every operator takes one or more operands as input and yields exactly one result as output. Depending on the operator, operands accept strings or numbers as operands. With few exceptions, operands may be full-fledged expressions in themselves.
Some PSPP operators and expressions work with Boolean values, which represent true/false conditions. Booleans have only three possible values: 0 (false), 1 (true), and system-missing (unknown). System-missing is neither true nor false and indicates that the true value is unknown.
Boolean-typed operands or function arguments must take on one of these three values. Other values are considered false, but provoke a warning when the expression is evaluated.
Strings and Booleans are not compatible, and neither may be used in place of the other.
Most numeric operators yield system-missing when given any system-missing operand. A string operator given any system-missing operand typically results in the empty string. Exceptions are listed under particular operator descriptions.
String user-missing values are not treated specially in expressions.
User-missing values for numeric variables are always transformed into
the system-missing value, except inside the arguments to the
VALUE and SYSMIS functions.
The missing-value functions can be used to precisely control how missing values are treated in expressions. See Missing Value Functions, for more details.
Parentheses (‘()’) are the grouping operators. Surround an expression with parentheses to force early evaluation.
Parentheses also surround the arguments to functions, but in that situation they act as punctuators, not as operators.
The arithmetic operators take numeric operands and produce numeric results.
+ b - b * b / b ** b0**0 is system-missing as well.
- aThe logical operators take logical operands and produce logical results, meaning “true or false.” Logical operators are not true Boolean operators because they may also result in a system-missing value. See Boolean Values, for more information.
AND b & b OR b | bNOT a~ aThe relational operators take numeric or string operands and produce Boolean results.
Strings cannot be compared to numbers. When strings of different lengths are compared, the shorter string is right-padded with spaces to match the length of the longer string.
The results of string comparisons, other than tests for equality or inequality, depend on the character set in use. String comparisons are case-sensitive.
EQ b = b LE b <= b LT b < b GE b >= b GT b > b NE b ~= b <> bPSPP functions provide mathematical abilities above and beyond those possible using simple operators. Functions have a common syntax: each is composed of a function name followed by a left parenthesis, one or more arguments, and a right parenthesis.
Function names are not reserved. Their names are specially treated
only when followed by a left parenthesis, so that EXP(10)
refers to the constant value e raised to the 10th power, but
EXP by itself refers to the value of variable EXP.
The sections below describe each function in detail.
Advanced mathematical functions take numeric arguments and produce numeric results.
Takes the base-10 logarithm of number. If number is not positive, the result is system-missing.
Takes the base-e logarithm of number. If number is not positive, the result is system-missing.
Yields the base-e logarithm of the complete gamma of number. If number is a negative integer, the result is system-missing.
Takes the square root of number. If number is negative, the result is system-missing.
Miscellaneous mathematical functions take numeric arguments and produce numeric results.
Returns the remainder (modulus) of numerator divided by denominator. If numerator is 0, then the result is 0, even if denominator is missing. If denominator is 0, the result is system-missing.
Returns the remainder when number is divided by 10. If number is negative, MOD10(number) is negative or zero.
Takes the absolute value of number and rounds it to an integer. Then, if number was negative originally, negates the result.
Discards the fractional part of number; that is, rounds number towards zero.
Trigonometric functions take numeric arguments and produce numeric results.
Takes the arccosine, in radians, of number. Results in system-missing if number is not between -1 and 1 inclusive. This function is a PSPP extension.
Takes the arcsine, in radians, of number. Results in system-missing if number is not between -1 and 1 inclusive.
Takes the tangent of angle which should be in radians. Results in system-missing at values of angle that are too close to odd multiples of pi/2. Portability: none.
Missing-value functions take various numeric arguments and yield various types of results. Except where otherwise stated below, the normal rules of evaluation apply within expression arguments to these functions. In particular, user-missing values for numeric variables are converted to system-missing values.
Each argument must be a numeric expression. Returns the number of system-missing values in the list, which may include variable ranges using the var1
TOvar2 syntax.
Each argument must be a numeric expression. Returns the number of values in the list that are not system-missing. The list may include variable ranges using the var1
TOvar2 syntax.
When expr is simply the name of a numeric variable, returns 1 if the variable has the system-missing value, 0 if it is user-missing or not missing. If given expr takes another form, results in 1 if the value is system-missing, 0 otherwise.
Prevents the user-missing values of variable from being transformed into system-missing values, and always results in the actual value of variable, whether it is valid, user-missing, or system-missing.
Set membership functions determine whether a value is a member of a set. They take a set of numeric arguments or a set of string arguments, and produce Boolean results.
String comparisons are performed according to the rules given in Relational Operators.
Results in true if value is equal to any of the set values. Otherwise, results in false. If value is system-missing, returns system-missing. System-missing values in set do not cause ANY to return system-missing.
Results in true if value is in any of the intervals bounded by low and high inclusive. Otherwise, results in false. Each low must be less than or equal to its corresponding high value. low and high must be given in pairs. If value is system-missing, returns system-missing. System-missing values in set do not cause RANGE to return system-missing.
Statistical functions compute descriptive statistics on a list of values. Some statistics can be computed on numeric or string values; other can only be computed on numeric values. Their results have the same type as their arguments. The current case's weighting factor (see WEIGHT) has no effect on statistical functions.
These functions' argument lists may include entire ranges of variables
using the var1 TO var2 syntax.
Unlike most functions, statistical functions can return non-missing
values even when some of their arguments are missing. Most
statistical functions, by default, require only 1 non-missing value to
have a non-missing return, but CFVAR, SD, and VARIANCE require 2.
These defaults can be increased (but not decreased) by appending a dot
and the minimum number of valid arguments to the function name. For
example, MEAN.3(X, Y, Z) would only return non-missing if all
of ‘X’, ‘Y’, and ‘Z’ were valid.
Results in the coefficient of variation of the values of number. (The coefficient of variation is the standard deviation divided by the mean.)
Results in the value of the greatest value. The values may be numeric or string.
Results in the value of the least value. The values may be numeric or string.
String functions take various arguments and return various results.
Returns a string consisting of each string in sequence.
CONCAT("abc", "def", "ghi")has a value of"abcdefghi". The resultant string is truncated to a maximum of 255 characters.
Returns a positive integer indicating the position of the first occurrence of needle in haystack. Returns 0 if haystack does not contain needle. Returns system-missing if needle is an empty string.
Divides needles into one or more needles, each with length needle_len. Searches haystack for the first occurrence of each needle, and returns the smallest value. Returns 0 if haystack does not contain any part in needle. It is an error if needle_len does not evenly divide the length of needles. Returns system-missing if needles is an empty string.
Returns a string identical to string except that all uppercase letters are changed to lowercase letters. The definitions of “uppercase” and “lowercase” are system-dependent.
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with spaces on the left side to length length. Returns an empty string if length is system-missing, negative, or greater than 255.
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with padding on the left side to length length. Returns an empty string if length is system-missing, negative, or greater than 255, or if padding does not contain exactly one character.
Returns string, after removing leading spaces. Other white space, such as tabs, carriage returns, line feeds, and vertical tabs, is not removed.
Returns string, after removing leading padding characters. If padding does not contain exactly one character, returns an empty string.
Returns the number produced when string is interpreted according to format specifier format. If the format width w is less than the length of string, then only the first w characters in string are used, e.g.
NUMBER("123", F3.0)andNUMBER("1234", F3.0)both have value 123. If w is greater than string's length, then it is treated as if it were right-padded with spaces. If string is not in the correct format for format, system-missing is returned.
Returns a positive integer indicating the position of the last occurrence of needle in haystack. Returns 0 if haystack does not contain needle. Returns system-missing if needle is an empty string.
Divides needle into parts, each with length needle_len. Searches haystack for the last occurrence of each part, and returns the largest value. Returns 0 if haystack does not contain any part in needle. It is an error if needle_len does not evenly divide the length of needle. Returns system-missing if needle is an empty string.
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with spaces on the right to length length. Returns an empty string if length is system-missing, negative, or greater than 255.
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with padding on the right to length length. Returns an empty string if length is system-missing, negative, or greater than 255, or if padding does not contain exactly one character.
Returns string, after removing trailing spaces. Other types of white space are not removed.
Returns string, after removing trailing padding characters. If padding does not contain exactly one character, returns an empty string.
Returns a string corresponding to number in the format given by format specifier format. For example,
STRING(123.56, F5.1)has the value"123.6".
Returns a string consisting of the value of string from position start onward. Returns an empty string if start is system-missing, less than 1, or greater than the length of string.
Returns a string consisting of the first count characters from string beginning at position start. Returns an empty string if start or count is system-missing, if start is less than 1 or greater than the number of characters in string, or if count is less than 1. Returns a string shorter than count characters if start + count - 1 is greater than the number of characters in string. Examples:
SUBSTR("abcdefg", 3, 2)has value"cd";SUBSTR("nonsense", 4, 10)has the value"sense".
For compatibility, PSPP considers dates before 15 Oct 1582 invalid. Most time and date functions will not accept earlier dates.
Times and dates are handled by PSPP as single numbers. A time is an interval. PSPP measures times in seconds. Thus, the following intervals correspond with the numeric values given:
10 minutes 600
1 hour 3,600
1 day, 3 hours, 10 seconds 97,210
40 days 3,456,000
A date, on the other hand, is a particular instant in the past or the future. PSPP represents a date as a number of seconds since midnight preceding 14 Oct 1582. Because midnight preceding the dates given below correspond with the numeric PSPP dates given:
15 Oct 1582 86,400
4 Jul 1776 6,113,318,400
1 Jan 1900 10,010,390,400
1 Oct 1978 12,495,427,200
24 Aug 1995 13,028,601,600
These functions take numeric arguments and return numeric values that represent times.
Returns a time corresponding to nhours hours, nmins minutes, and nsecs seconds. The arguments may not have mixed signs: if any of them are positive, then none may be negative, and vice versa.
These functions take numeric arguments in PSPP time format and give numeric results.
Results in the number of seconds and fractional seconds in time. (
CTIME.SECONDSdoes nothing;CTIME.SECONDS(x)is equivalent to x.)
These functions take numeric arguments and give numeric results that represent dates. Arguments taken by these functions are:
If these functions' arguments are out-of-range, they are correctly normalized before conversion to date format. Non-integers are rounded toward zero.
Results in a date value corresponding to the midnight before day day of month month of year year.
Results in a date value corresponding to the midnight before the first day of month month of year year.
Results in a date value corresponding to the midnight before the first day of quarter quarter of year year.
Results in a date value corresponding to the midnight before the first day of week week of year year.
Results in a date value corresponding to the day yday of year year.
These functions take numeric arguments in PSPP date or time format and give numeric results. These names are used for arguments:
For a time, results in the time corresponding to the number of whole days date-or-time includes. For a date, results in the date corresponding to the latest midnight at or before date-or-time; that is, gives the date that date-or-time is in.
For a time, results in the number of whole hours beyond the number of whole days represented by date-or-time. For a date, results in the hour (as an integer between 0 and 23) corresponding to date-or-time.
Results in the day of the year (as an integer between 1 and 366) corresponding to date.
Results in the day of the month (as an integer between 1 and 31) corresponding to date.
Results in the number of minutes (as an integer between 0 and 59) after the last hour in time-or-date.
Results in the month of the year (as an integer between 1 and 12) corresponding to date.
Results in the quarter of the year (as an integer between 1 and 4) corresponding to date.
Results in the number of whole seconds after the last whole minute (as an integer between 0 and 59) in time-or-date.
Results in the time of day at the instant corresponding to date, as a time value. This is the number of seconds since midnight on the day corresponding to date.
Results in the week of the year (as an integer between 1 and 53) corresponding to date.
Results in the day of week (as an integer between 1 and 7) corresponding to date, where 1 represents Sunday.
Returns the year (as an integer 1582 or greater) corresponding to date.
Ordinary arithmetic operations on dates and times often produce sensible results. Adding a time to, or subtracting one from, a date produces a new date that much earlier or later. The difference of two dates yields the time between those dates. Adding two times produces the combined time. Multiplying a time by a scalar produces a time that many times longer. Since times and dates are just numbers, the ordinary addition and subtraction operators are employed for these purposes.
Adding two dates does not produce a useful result.
Dates and times may have very large values. Thus, it is not a good idea to take powers of these values; also, the accuracy of some procedures may be affected. If necessary, convert times or dates in seconds to some other unit, like days or years, before performing analysis.
PSPP supplies a few functions for date arithmetic:
Returns the span of time from date1 to date2 in terms of unit, which must be a quoted string, one of ‘years’, ‘quarters’, ‘months’, ‘weeks’, ‘days’, ‘hours’, ‘minutes’, and ‘seconds’. The result is an integer, truncated toward zero.
One year is considered to span from a given date to the same month, day, and time of day the next year. Thus, from Jan. 1 of one year to Jan. 1 the next year is considered to be a full year, but Feb. 29 of a leap year to the following Feb. 28 is not. Similarly, one month spans from a given day of the month to the same day of the following month. Thus, there is never a full month from Jan. 31 of a given year to any day in the following February.
Returns date advanced by the given quantity of the specified unit, which must be one of the strings ‘years’, ‘quarters’, ‘months’, ‘weeks’, ‘days’, ‘hours’, ‘minutes’, and ‘seconds’.
When unit is ‘years’, ‘quarters’, or ‘months’, only the integer part of quantity is considered. Adding one of these units can cause the day of the month to exceed the number of days in the month. In this case, the method comes into play: if it is omitted or specified as ‘closest’ (as a quoted string), then the resulting day is the last day of the month; otherwise, if it is specified as ‘rollover’, then the extra days roll over into the following month.
When unit is ‘weeks’, ‘days’, ‘hours’, ‘minutes’, or ‘seconds’, the quantity is not rounded to an integer and method, if specified, is ignored.
variable must be a numeric or string variable name.
LAGyields the value of that variable for the case n before the current one. Results in system-missing (for numeric variables) or blanks (for string variables) for the first n cases.
LAGobtains values from the cases that become the new active file after a procedure executes. Thus,LAGwill not return values from cases dropped by transformations such as SELECT IF, and transformations like COMPUTE that modify data will change the values returned byLAG. These are both the case whether these transformations precede or follow the use ofLAG.If
LAGis used before TEMPORARY, then the values it returns are those in cases just before TEMPORARY.LAGmay not be used after TEMPORARY.If omitted, ncases defaults to 1. Otherwise, ncases must be a small positive constant integer. There is no explicit limit, but use of a large value will increase memory consumption.
year is a year, either between 0 and 99 or at least 1582. Unlike other PSPP date functions, years between 0 and 99 always correspond to 1900 through 1999. month is a month between 1 and 13. day is a day between 0 and 31. A day of 0 refers to the last day of the previous month, and a month of 13 refers to the first month of the next year. year must be in range. year, month, and day must all be integers.
YRMODAresults in the number of days between 15 Oct 1582 and the date specified, plus one. The date passed toYRMODAmust be on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
Returns a string matching the label associated with the current value of variable. If the current value of variable has no associated label, then this function returns the empty string. variable may be a numeric or string variable.
PSPP can calculate several functions of standard statistical distributions. These functions are named systematically based on the function and the distribution. The table below describes the statistical distribution functions in general:
The individual distributions are described individually below.
The following continuous distributions are available:
Beta distribution with shape parameters a and b. The noncentral distribution takes an additional parameter lambda. Constraints: a > 0, b > 0, lambda >= 0, 0 <= x <= 1, 0 <= p <= 1.
Bivariate normal distribution of two standard normal variables with correlation coefficient rho. Two variates x0 and x1 must be provided. Constraints: 0 <= rho <= 1, 0 <= p <= 1.
Cauchy distribution with location parameter a and scale parameter b. Constraints: b > 0, 0 < p < 1.
Chi-squared distribution with df degrees of freedom. The noncentral distribution takes an additional parameter lambda. Constraints: df > 0, lambda > 0, x >= 0, 0 <= p < 1.
Exponential distribution with scale parameter a. The inverse of a represents the rate of decay. Constraints: a > 0, x >= 0, 0 <= p < 1.
Exponential power distribution with positive scale parameter a and nonnegative power parameter b. Constraints: a > 0, b >= 0, x >= 0, 0 <= p <= 1. This distribution is a PSPP extension.
F-distribution of two chi-squared deviates with df1 and df2 degrees of freedom. The noncentral distribution takes an additional parameter lambda. Constraints: df1 > 0, df2 > 0, lambda >= 0, x >= 0, 0 <= p < 1.
Gamma distribution with shape parameter a and scale parameter b. Constraints: a > 0, b > 0, x >= 0, 0 <= p < 1.
Half-normal distribution with location parameter a and shape parameter b. Constraints: b > 0, 0 < p < 1.
Inverse Gaussian distribution with parameters a and b. Constraints: a > 0, b > 0, x > 0, 0 <= p < 1.
Laplace distribution with location parameter a and scale parameter b. Constraints: b > 0, 0 < p < 1.
Levy symmetric alpha-stable distribution with scale c and exponent alpha. Constraints: 0 < alpha <= 2.
Levy skew alpha-stable distribution with scale c, exponent alpha, and skewness parameter beta. Constraints: 0 < alpha <= 2, -1 <= beta <= 1.
Logistic distribution with location parameter a and scale parameter b. Constraints: b > 0, 0 < p < 1.
Lognormal distribution with parameters a and b. Constraints: a > 0, b > 0, x >= 0, 0 <= p < 1.
Normal distribution with mean mu and standard deviation sigma. Constraints: b > 0, 0 < p < 1. Three additional functions are available as shorthand:
Normal tail distribution with lower limit a and standard deviation sigma. This distribution is a PSPP extension. Constraints: a > 0, x > a, 0 < p < 1.
Pareto distribution with threshold parameter a and shape parameter b. Constraints: a > 0, b > 0, x >= a, 0 <= p < 1.
Rayleigh distribution with scale parameter sigma. This distribution is a PSPP extension. Constraints: sigma > 0, x > 0.
Rayleigh tail distribution with lower limit a and scale parameter sigma. This distribution is a PSPP extension. Constraints: a > 0, sigma > 0, x > a.
Studentized maximum modulus distribution with parameters a and b. Constraints: a > 0, b > 0, x > 0, 0 <= p < 1.
Studentized range distribution with parameters a and b. Constraints: a >= 1, b >= 1, x > 0, 0 <= p < 1.
T-distribution with df degrees of freedom. The noncentral distribution takes an additional parameter lambda. Constraints: df > 0, 0 < p < 1.
Type-1 Gumbel distribution with parameters a and b. This distribution is a PSPP extension. Constraints: 0 < p < 1.
Type-2 Gumbel distribution with parameters a and b. This distribution is a PSPP extension. Constraints: x > 0, 0 < p < 1.
Uniform distribution with parameters a and b. Constraints: a <= x <= b, 0 <= p <= 1. An additional function is available as shorthand:
Weibull distribution with parameters a and b. Constraints: a > 0, b > 0, x >= 0, 0 <= p < 1.
The following discrete distributions are available:
Bernoulli distribution with probability of success p. Constraints: x = 0 or 1, 0 <= p <= 1.
Binomial distribution with n trials and probability of success p. Constraints: integer n > 0, 0 <= p <= 1, integer x <= n.
Geometric distribution with probability of success p. Constraints: 0 <= p <= 1, integer x > 0.
Hypergeometric distribution when b objects out of a are drawn and c of the available objects are distinctive. Constraints: integer a > 0, integer b <= a, integer c <= a, integer x >= 0.
Logarithmic distribution with probability parameter p. Constraints: 0 <= p < 1, x >= 1.
Negative binomial distribution with number of successes paramter n and probability of success parameter p. Constraints: integer n >= 0, 0 < p <= 1, integer x >= 1.
Poisson distribution with mean mu. Constraints: mu > 0, integer x >= 0.
The following table describes operator precedence. Smaller-numbered levels in the table have higher precedence. Within a level, operations are always performed from left to right. The first occurrence of ‘-’ represents unary negation, the second binary subtraction.
( )
**
-
* /
+ -
EQ GE GT LE LT NE
AND NOT OR
Data are the focus of the PSPP language. Each datum belongs to a case (also called an observation). Each case represents an individual or “experimental unit”. For example, in the results of a survey, the names of the respondents, their sex, age, etc. and their responses are all data and the data pertaining to single respondent is a case. This chapter examines the PSPP commands for defining variables and reading and writing data. There are alternative commands to read data from predefined sources such as system files or databases (See GET DATA.)
Note: These commands tell PSPP how to read data, but the data will not actually be read until a procedure is executed.
BEGIN DATA.
...
END DATA.
BEGIN DATA and END DATA can be used to embed raw ASCII
data in a PSPP syntax file. DATA LIST or another input
procedure must be used before BEGIN DATA (see DATA LIST).
BEGIN DATA and END DATA must be used together. END
DATA must appear by itself on a single line, with no leading
white space and exactly one space between the words END and
DATA, like this:
END DATA.
CLOSE FILE HANDLE handle_name.
CLOSE FILE HANDLE disassociates the name of a file handle with a given file. The only specification is the name of the handle to close. Afterward FILE HANDLE.
If the file handle name refers to a scratch file, then the storage associated with the scratch file in memory or on disk will be freed. If the scratch file is in use, e.g. it has been specified on a GET command whose execution has not completed, then freeing is delayed until it is no longer in use.
The file named INLINE, which represents data entered between BEGIN DATA and END DATA, cannot be closed. Attempts to close it with CLOSE FILE HANDLE have no effect.
CLOSE FILE HANDLE is a PSPP extension.
Used to read text or binary data, DATA LIST is the most fundamental data-reading command. Even the more sophisticated input methods use DATA LIST commands as a building block. Understanding DATA LIST is important to understanding how to use PSPP to read your data files.
There are two major variants of DATA LIST, which are fixed format and free format. In addition, free format has a minor variant, list format, which is discussed in terms of its differences from vanilla free format.
Each form of DATA LIST is described in detail below.
See GET DATA, for a command that offers a few enhancements over DATA LIST and that may be substituted for DATA LIST in many situations.
DATA LIST [FIXED]
{TABLE,NOTABLE}
[FILE='file-name']
[RECORDS=record_count]
[END=end_var]
[SKIP=record_count]
/[line_no] var_spec...
where each var_spec takes one of the forms
var_list start-end [type_spec]
var_list (fortran_spec)
DATA LIST FIXED is used to read data files that have values at fixed positions on each line of single-line or multiline records. The keyword FIXED is optional.
The FILE subcommand must be used if input is to be taken from an external file. It may be used to specify a file name as a string or a file handle (see File Handles). If the FILE subcommand is not used, then input is assumed to be specified within the command file using BEGIN DATA...END DATA (see BEGIN DATA).
The optional RECORDS subcommand, which takes a single integer as an argument, is used to specify the number of lines per record. If RECORDS is not specified, then the number of lines per record is calculated from the list of variable specifications later in DATA LIST.
The END subcommand is only useful in conjunction with INPUT PROGRAM. See INPUT PROGRAM, for details.
The optional SKIP subcommand specifies a number of records to skip at the beginning of an input file. It can be used to skip over a row that contains variable names, for example.
DATA LIST can optionally output a table describing how the data file will be read. The TABLE subcommand enables this output, and NOTABLE disables it. The default is to output the table.
The list of variables to be read from the data list must come last. Each line in the data record is introduced by a slash (‘/’). Optionally, a line number may follow the slash. Following, any number of variable specifications may be present.
Each variable specification consists of a list of variable names
followed by a description of their location on the input line. Sets of
variables may be specified using the DATA LIST TO convention
(see Sets of Variables). There are two ways to specify the location of the variable
on the line: columnar style and FORTRAN style.
In columnar style, the starting column and ending column for the field are specified after the variable name, separated by a dash (‘-’). For instance, the third through fifth columns on a line would be specified ‘3-5’. By default, variables are considered to be in ‘F’ format (see Input and Output Formats). (This default can be changed; see SET for more information.)
In columnar style, to use a variable format other than the default, specify the format type in parentheses after the column numbers. For instance, for alphanumeric ‘A’ format, use ‘(A)’.
In addition, implied decimal places can be specified in parentheses after the column numbers. As an example, suppose that a data file has a field in which the characters ‘1234’ should be interpreted as having the value 12.34. Then this field has two implied decimal places, and the corresponding specification would be ‘(2)’. If a field that has implied decimal places contains a decimal point, then the implied decimal places are not applied.
Changing the variable format and adding implied decimal places can be done together; for instance, ‘(N,5)’.
When using columnar style, the input and output width of each variable is computed from the field width. The field width must be evenly divisible into the number of variables specified.
FORTRAN style is an altogether different approach to specifying field locations. With this approach, a list of variable input format specifications, separated by commas, are placed after the variable names inside parentheses. Each format specifier advances as many characters into the input line as it uses.
Implied decimal places also exist in FORTRAN style. A format specification with d decimal places also has d implied decimal places.
In addition to the standard format specifiers (see Input and Output Formats), FORTRAN style defines some extensions:
XTxNEWRECxFORTRAN and columnar styles may be freely intermixed. Columnar style
leaves the active column immediately after the ending column
specified. Record motion using NEWREC in FORTRAN style also
applies to later FORTRAN and columnar specifiers.
DATA LIST TABLE /NAME 1-10 (A) INFO1 TO INFO3 12-17 (1).
BEGIN DATA.
John Smith 102311
Bob Arnold 122015
Bill Yates 918 6
END DATA.
Defines the following variables:
NAME, a 10-character-wide long string variable, in columns 1
through 10.
INFO1, a numeric variable, in columns 12 through 13.
INFO2, a numeric variable, in columns 14 through 15.
INFO3, a numeric variable, in columns 16 through 17.
The BEGIN DATA/END DATA commands cause three cases to be
defined:
Case NAME INFO1 INFO2 INFO3
1 John Smith 10 23 11
2 Bob Arnold 12 20 15
3 Bill Yates 9 18 6
The TABLE keyword causes PSPP to print out a table
describing the four variables defined.
DAT LIS FIL="survey.dat"
/ID 1-5 NAME 7-36 (A) SURNAME 38-67 (A) MINITIAL 69 (A)
/Q01 TO Q50 7-56
/.
Defines the following variables:
ID, a numeric variable, in columns 1-5 of the first record.
NAME, a 30-character long string variable, in columns 7-36 of the
first record.
SURNAME, a 30-character long string variable, in columns 38-67 of
the first record.
MINITIAL, a 1-character short string variable, in column 69 of
the first record.
Q01, Q02, Q03, ..., Q49,
Q50, all numeric, Q01 in column 7, Q02 in column 8,
..., Q49 in column 55, Q50 in column 56, all in the second
record.
Cases are separated by a blank record.
Data is read from file survey.dat in the current directory.
This example shows keywords abbreviated to their first 3 letters.
DATA LIST FREE
[({TAB,'c'}, ...)]
[{NOTABLE,TABLE}]
[FILE='file-name']
[SKIP=record_cnt]
/var_spec...
where each var_spec takes one of the forms
var_list [(type_spec)]
var_list *
In free format, the input data is, by default, structured as a series of fields separated by spaces, tabs, commas, or line breaks. Each field's content may be unquoted, or it may be quoted with a pairs of apostrophes (‘'’) or double quotes (‘"’). Unquoted white space separates fields but is not part of any field. Any mix of spaces, tabs, and line breaks is equivalent to a single space for the purpose of separating fields, but consecutive commas will skip a field.
Alternatively, delimiters can be specified explicitly, as a parenthesized, comma-separated list of single-character strings immediately following FREE. The word TAB may also be used to specify a tab character as a delimiter. When delimiters are specified explicitly, only the given characters, plus line breaks, separate fields. Furthermore, leading spaces at the beginnings of fields are not trimmed, consecutive delimiters define empty fields, and no form of quoting is allowed.
The NOTABLE and TABLE subcommands are as in DATA LIST FIXED above. NOTABLE is the default.
The FILE and SKIP subcommands are as in DATA LIST FIXED above.
The variables to be parsed are given as a single list of variable names. This list must be introduced by a single slash (‘/’). The set of variable names may contain format specifications in parentheses (see Input and Output Formats). Format specifications apply to all variables back to the previous parenthesized format specification.
In addition, an asterisk may be used to indicate that all variables preceding it are to have input/output format ‘F8.0’.
Specified field widths are ignored on input, although all normal limits on field width apply, but they are honored on output.
DATA LIST LIST
[({TAB,'c'}, ...)]
[{NOTABLE,TABLE}]
[FILE='file-name']
[SKIP=record_count]
/var_spec...
where each var_spec takes one of the forms
var_list [(type_spec)]
var_list *
With one exception, DATA LIST LIST is syntactically and semantically equivalent to DATA LIST FREE. The exception is that each input line is expected to correspond to exactly one input record. If more or fewer fields are found on an input line than expected, an appropriate diagnostic is issued.
END CASE.
END CASE is used only within INPUT PROGRAM to output the current case. See INPUT PROGRAM, for details.
END FILE.
END FILE is used only within INPUT PROGRAM to terminate the current input program. See INPUT PROGRAM.
For text files:
FILE HANDLE handle_name
/NAME='file-name'
[/MODE=CHARACTER]
/TABWIDTH=tab_width
For binary files in native encoding with fixed-length records:
FILE HANDLE handle_name
/NAME='file-name'
/MODE=IMAGE
[/LRECL=rec_len]
For binary files in native encoding with variable-length records:
FILE HANDLE handle_name
/NAME='file-name'
/MODE=BINARY
[/LRECL=rec_len]
For binary files encoded in EBCDIC:
FILE HANDLE handle_name
/NAME='file-name'
/MODE=360
/RECFORM={FIXED,VARIABLE,SPANNED}
[/LRECL=rec_len]
To explicitly declare a scratch handle:
FILE HANDLE handle_name
/MODE=SCRATCH
Use FILE HANDLE to associate a file handle name with a file and its attributes, so that later commands can refer to the file by its handle name. Names of text files can be specified directly on commands that access files, so that FILE HANDLE is only needed when a file is not an ordinary file containing lines of text. However, FILE HANDLE may be used even for text files, and it may be easier to specify a file's name once and later refer to it by an abstract handle.
Specify the file handle name as the identifier immediately following the FILE HANDLE command name. The identifier INLINE is reserved for representing data embedded in the syntax file (see BEGIN DATA) The file handle name must not already have been used in a previous invocation of FILE HANDLE, unless it has been closed by an intervening command (see CLOSE FILE HANDLE).
The effect and syntax of FILE HANDLE depends on the selected MODE:
In CHARACTER mode only, tabs are expanded to spaces by input programs, except by DATA LIST FREE with explicitly specified delimiters. Each tab is 4 characters wide by default, but TABWIDTH (a PSPP extension) may be used to specify an alternate width. Use a TABWIDTH of 0 to suppress tab expansion.
Alphanumeric data in mode 360 files are encoded in EBCDIC. PSPP translates EBCDIC to or from the host's native format as necessary on input or output, using an ASCII/EBCDIC translation that is one-to-one, so that a “round trip” from ASCII to EBCDIC back to ASCII, or vice versa, always yields exactly the original data.
The RECFORM subcommand is required in mode 360. The precise file format depends on its setting:
IBM documentation calls this *F (fixed-length, deblocked)
format.
Following the BDW, the remainder of each block is a sequence of one or more variable-length records, each of which in turn begins with a 4-byte record descriptor word (RDW) that has the same format as the BDW. Following the RDW, the remainder of each record is the record data.
The maximum length of a record in VARIABLE mode is 65,527 bytes: 65,535 bytes (the maximum value of a 16-bit unsigned integer), minus 4 bytes for the BDW, minus 4 bytes for the RDW.
In mode VARIABLE, LRECL specifies a maximum, not a fixed, record length, in bytes. The default is 8,192.
IBM documentation calls this *VB (variable-length, blocked,
unspanned) format.
The maximum length of a logical record in VARIABLE mode is limited only by memory available to PSPP. Segments are limited to 65,527 bytes, as in VARIABLE mode.
This format is similar to what IBM documentation call *VS
(variable-length, deblocked, spanned) format.
In mode 360, fields of type A that extend beyond the end of a record
read from disk are padded with spaces in the host's native character
set, which are then translated from EBCDIC to the native character
set. Thus, when the host's native character set is based on ASCII,
these fields are effectively padded with character X'80'. This
wart is implemented for compatibility.
The NAME subcommand specifies the name of the file associated with the handle. It is required in all modes but SCRATCH mode, in which its use is forbidden.
INPUT PROGRAM.
... input commands ...
END INPUT PROGRAM.
INPUT PROGRAM...END INPUT PROGRAM specifies a complex input program. By placing data input commands within INPUT PROGRAM, PSPP programs can take advantage of more complex file structures than available with only DATA LIST.
The first sort of extended input program is to simply put multiple DATA LIST commands within the INPUT PROGRAM. This will cause all of the data files to be read in parallel. Input will stop when end of file is reached on any of the data files.
Transformations, such as conditional and looping constructs, can also be included within INPUT PROGRAM. These can be used to combine input from several data files in more complex ways. However, input will still stop when end of file is reached on any of the data files.
To prevent INPUT PROGRAM from terminating at the first end of file, use the END subcommand on DATA LIST. This subcommand takes a variable name, which should be a numeric scratch variable (see Scratch Variables). (It need not be a scratch variable but otherwise the results can be surprising.) The value of this variable is set to 0 when reading the data file, or 1 when end of file is encountered.
Two additional commands are useful in conjunction with INPUT PROGRAM. END CASE is the first. Normally each loop through the INPUT PROGRAM structure produces one case. END CASE controls exactly when cases are output. When END CASE is used, looping from the end of INPUT PROGRAM to the beginning does not cause a case to be output.
END FILE is the second. When the END subcommand is used on DATA LIST, there is no way for the INPUT PROGRAM construct to stop looping, so an infinite loop results. END FILE, when executed, stops the flow of input data and passes out of the INPUT PROGRAM structure.
All this is very confusing. A few examples should help to clarify.
INPUT PROGRAM.
DATA LIST NOTABLE FILE='a.data'/X 1-10.
DATA LIST NOTABLE FILE='b.data'/Y 1-10.
END INPUT PROGRAM.
LIST.
The example above reads variable X from file a.data and variable Y from file b.data. If one file is shorter than the other then the extra data in the longer file is ignored.
INPUT PROGRAM.
NUMERIC #A #B.
DO IF NOT #A.
DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
END IF.
DO IF NOT #B.
DATA LIST NOTABLE END=#B FILE='b.data'/Y 1-10.
END IF.
DO IF #A AND #B.
END FILE.
END IF.
END CASE.
END INPUT PROGRAM.
LIST.
The above example reads variable X from a.data and variable Y from b.data. If one file is shorter than the other then the missing field is set to the system-missing value alongside the present value for the remaining length of the longer file.
INPUT PROGRAM.
NUMERIC #A #B.
DO IF #A.
DATA LIST NOTABLE END=#B FILE='b.data'/X 1-10.
DO IF #B.
END FILE.
ELSE.
END CASE.
END IF.
ELSE.
DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
DO IF NOT #A.
END CASE.
END IF.
END IF.
END INPUT PROGRAM.
LIST.
The above example reads data from file a.data, then from b.data, and concatenates them into a single active file.
INPUT PROGRAM.
NUMERIC #EOF.
LOOP IF NOT #EOF.
DATA LIST NOTABLE END=#EOF FILE='a.data'/X 1-10.
DO IF NOT #EOF.
END CASE.
END IF.
END LOOP.
COMPUTE #EOF = 0.
LOOP IF NOT #EOF.
DATA LIST NOTABLE END=#EOF FILE='b.data'/X 1-10.
DO IF NOT #EOF.
END CASE.
END IF.
END LOOP.
END FILE.
END INPUT PROGRAM.
LIST.
The above example does the same thing as the previous example, in a different way.
INPUT PROGRAM.
LOOP #I=1 TO 50.
COMPUTE X=UNIFORM(10).
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
LIST/FORMAT=NUMBERED.
The above example causes an active file to be created consisting of 50 random variates between 0 and 10.
LIST
/VARIABLES=var_list
/CASES=FROM start_index TO end_index BY incr_index
/FORMAT={UNNUMBERED,NUMBERED} {WRAP,SINGLE}
{NOWEIGHT,WEIGHT}
The LIST procedure prints the values of specified variables to the listing file.
The VARIABLES subcommand specifies the variables whose values are to be printed. Keyword VARIABLES is optional. If VARIABLES subcommand is not specified then all variables in the active file are printed.
The CASES subcommand can be used to specify a subset of cases to be printed. Specify FROM and the case number of the first case to print, TO and the case number of the last case to print, and BY and the number of cases to advance between printing cases, or any subset of those settings. If CASES is not specified then all cases are printed.
The FORMAT subcommand can be used to change the output format. NUMBERED will print case numbers along with each case; UNNUMBERED, the default, causes the case numbers to be omitted. The WRAP and SINGLE settings are currently not used. WEIGHT will cause case weights to be printed along with variable values; NOWEIGHT, the default, causes case weights to be omitted from the output.
Case numbers start from 1. They are counted after all transformations have been considered.
LIST attempts to fit all the values on a single line. If needed to make them fit, variable names are displayed vertically. If values cannot fit on a single line, then a multi-line format will be used.
LIST is a procedure. It causes the data to be read.
NEW FILE.
NEW FILE command clears the current active file.
PRINT
OUTFILE='file-name'
RECORDS=n_lines
{NOTABLE,TABLE}
[/[line_no] arg...]
arg takes one of the following forms:
'string' [start-end]
var_list start-end [type_spec]
var_list (fortran_spec)
var_list *
The PRINT transformation writes variable data to the listing file or an output file. PRINT is executed when a procedure causes the data to be read. Follow PRINT by EXECUTE to print variable data without invoking a procedure (see EXECUTE).
All PRINT subcommands are optional. If no strings or variables are specified, PRINT outputs a single blank line.
The OUTFILE subcommand specifies the file to receive the output. The file may be a file name as a string or a file handle (see File Handles). If OUTFILE is not present then output will be sent to PSPP's output listing file. When OUTFILE is present, a space is inserted at beginning of each output line, even lines that otherwise would be blank.
The RECORDS subcommand specifies the number of lines to be output. The number of lines may optionally be surrounded by parentheses.
TABLE will cause the PRINT command to output a table to the listing file that describes what it will print to the output file. NOTABLE, the default, suppresses this output table.
Introduce the strings and variables to be printed with a slash (‘/’). Optionally, the slash may be followed by a number indicating which output line will be specified. In the absence of this line number, the next line number will be specified. Multiple lines may be specified using multiple slashes with the intended output for a line following its respective slash.
Literal strings may be printed. Specify the string itself. Optionally the string may be followed by a column number or range of column numbers, specifying the location on the line for the string to be printed. Otherwise, the string will be printed at the current position on the line.
Variables to be printed can be specified in the same ways as available for DATA LIST FIXED (see DATA LIST FIXED). In addition, a variable list may be followed by an asterisk (‘*’), which indicates that the variables should be printed in their dictionary print formats, separated by spaces. A variable list followed by a slash or the end of command will be interpreted the same way.
If a FORTRAN type specification is used to move backwards on the current line, then text is written at that point on the line, the line will be truncated to that length, although additional text being added will again extend the line to that length.
PRINT EJECT
OUTFILE='file-name'
RECORDS=n_lines
{NOTABLE,TABLE}
/[line_no] arg...
arg takes one of the following forms:
'string' [start-end]
var_list start-end [type_spec]
var_list (fortran_spec)
var_list *
PRINT EJECT advances to the beginning of a new output page in the listing file or output file. It can also output data in the same way as PRINT.
All PRINT EJECT subcommands are optional.
Without OUTFILE, PRINT EJECT ejects the current page in the listing file, then it produces other output, if any is specified.
With OUTFILE, PRINT EJECT writes its output to the specified file. The first line of output is written with ‘1’ inserted in the first column. Commonly, this is the only line of output. If additional lines of output are specified, these additional lines are written with a space inserted in the first column, as with PRINT.
See PRINT, for more information on syntax and usage.
PRINT SPACE OUTFILE='file-name' n_lines.
PRINT SPACE prints one or more blank lines to an output file.
The OUTFILE subcommand is optional. It may be used to direct output to a file specified by file name as a string or file handle (see File Handles). If OUTFILE is not specified then output will be directed to the listing file.
n_lines is also optional. If present, it is an expression (see Expressions) specifying the number of blank lines to be printed. The expression must evaluate to a nonnegative value.
REREAD FILE=handle COLUMN=column.
The REREAD transformation allows the previous input line in a data file already processed by DATA LIST or another input command to be re-read for further processing.
The FILE subcommand, which is optional, is used to specify the file to have its line re-read. The file must be specified as the name of a file handle (see File Handles). If FILE is not specified then the last file specified on DATA LIST will be assumed (last file specified lexically, not in terms of flow-of-control).
By default, the line re-read is re-read in its entirety. With the COLUMN subcommand, a prefix of the line can be exempted from re-reading. Specify an expression (see Expressions) evaluating to the first column that should be included in the re-read line. Columns are numbered from 1 at the left margin.
Issuing REREAD multiple times will not back up in the data
file. Instead, it will re-read the same line multiple times.
REPEATING DATA
/STARTS=start-end
/OCCURS=n_occurs
/FILE='file-name'
/LENGTH=length
/CONTINUED[=cont_start-cont_end]
/ID=id_start-id_end=id_var
/{TABLE,NOTABLE}
/DATA=var_spec...
where each var_spec takes one of the forms
var_list start-end [type_spec]
var_list (fortran_spec)
REPEATING DATA parses groups of data repeating in a uniform format, possibly with several groups on a single line. Each group of data corresponds with one case. REPEATING DATA may only be used within an INPUT PROGRAM structure (see INPUT PROGRAM). When used with DATA LIST, it can be used to parse groups of cases that share a subset of variables but differ in their other data.
The STARTS subcommand is required. Specify a range of columns, using literal numbers or numeric variable names. This range specifies the columns on the first line that are used to contain groups of data. The ending column is optional. If it is not specified, then the record width of the input file is used. For the inline file (see BEGIN DATA) this is 80 columns; for a file with fixed record widths it is the record width; for other files it is 1024 characters by default.
The OCCURS subcommand is required. It must be a number or the name of a numeric variable. Its value is the number of groups present in the current record.
The DATA subcommand is required. It must be the last subcommand specified. It is used to specify the data present within each repeating group. Column numbers are specified relative to the beginning of a group at column 1. Data is specified in the same way as with DATA LIST FIXED (see DATA LIST FIXED).
All other subcommands are optional.
FILE specifies the file to read, either a file name as a string or a file handle (see File Handles). If FILE is not present then the default is the last file handle used on DATA LIST (lexically, not in terms of flow of control).
By default REPEATING DATA will output a table describing how it will parse the input data. Specifying NOTABLE will disable this behavior; specifying TABLE will explicitly enable it.
The LENGTH subcommand specifies the length in characters of each group. If it is not present then length is inferred from the DATA subcommand. LENGTH can be a number or a variable name.
Normally all the data groups are expected to be present on a single line. Use the CONTINUED command to indicate that data can be continued onto additional lines. If data on continuation lines starts at the left margin and continues through the entire field width, no column specifications are necessary on CONTINUED. Otherwise, specify the possible range of columns in the same way as on STARTS.
When data groups are continued from line to line, it is easy for cases to get out of sync through careless hand editing. The ID subcommand allows a case identifier to be present on each line of repeating data groups. REPEATING DATA will check for the same identifier on each line and report mismatches. Specify the range of columns that the identifier will occupy, followed by an equals sign (‘=’) and the identifier variable name. The variable must already have been declared with NUMERIC or another command.
REPEATING DATA should be the last command given within an INPUT PROGRAM. It should not be enclosed within a LOOP structure (see LOOP). Use DATA LIST before, not after, REPEATING DATA.
WRITE
OUTFILE='file-name'
RECORDS=n_lines
{NOTABLE,TABLE}
/[line_no] arg...
arg takes one of the following forms:
'string' [start-end]
var_list start-end [type_spec]
var_list (fortran_spec)
var_list *
WRITE writes text or binary data to an output file.
See PRINT, for more information on syntax and usage. PRINT and WRITE differ in only a few ways:
The commands in this chapter read, write, and examine system files and portable files.
APPLY DICTIONARY FROM={'file-name',file_handle}.
APPLY DICTIONARY applies the variable labels, value labels, and missing values taken from a file to corresponding variables in the active file. In some cases it also updates the weighting variable.
Specify a system file, portable file, or scratch file with a file name string or as a file handle (see File Handles). The dictionary in the file will be read, but it will not replace the active file dictionary. The file's data will not be read.
Only variables with names that exist in both the active file and the system file are considered. Variables with the same name but different types (numeric, string) will cause an error message. Otherwise, the system file variables' attributes will replace those in their matching active file variables, as described below.
If a system file variable has a variable label, then it will replace the active file variable's variable label. If the system file variable does not have a variable label, then the active file variable's variable label, if any, will be retained.
If the active file variable is numeric or short string, then value labels and missing values, if any, will be copied to the active file variable. If the system file variable does not have value labels or missing values, then those in the active file variable, if any, will not be disturbed.
Finally, weighting of the active file is updated (see WEIGHT). If the active file has a weighting variable, and the system file does not, or if the weighting variable in the system file does not exist in the active file, then the active file weighting variable, if any, is retained. Otherwise, the weighting variable in the system file becomes the active file weighting variable.
APPLY DICTIONARY takes effect immediately. It does not read the active file. The system file is not modified.
EXPORT
/OUTFILE='file-name'
/UNSELECTED={RETAIN,DELETE}
/DIGITS=n
/DROP=var_list
/KEEP=var_list
/RENAME=(src_names=target_names)...
/TYPE={COMM,TAPE}
/MAP
The EXPORT procedure writes the active file dictionary and data to a specified portable file or scratch file.
By default, cases excluded with FILTER are written to the file. These can be excluded by specifying DELETE on the UNSELECTED subcommand. Specifying RETAIN makes the default explicit.
Portable files express real numbers in base 30. Integers are always expressed to the maximum precision needed to make them exact. Non-integers are, by default, expressed to the machine's maximum natural precision (approximately 15 decimal digits on many machines). If many numbers require this many digits, the portable file may significantly increase in size. As an alternative, the DIGITS subcommand may be used to specify the number of decimal digits of precision to write. DIGITS applies only to non-integers.
The OUTFILE subcommand, which is the only required subcommand, specifies the portable file or scratch file to be written as a file name string or a file handle (see File Handles).
DROP, KEEP, and RENAME follow the same format as the SAVE procedure (see SAVE).
The TYPE subcommand specifies the character set for use in the portable file. Its value is currently not used.
The MAP subcommand is currently ignored.
EXPORT is a procedure. It causes the active file to be read.
GET
/FILE={'file-name',file_handle}
/DROP=var_list
/KEEP=var_list
/RENAME=(src_names=target_names)...
GET clears the current dictionary and active file and replaces them with the dictionary and data from a specified file.
The FILE subcommand is the only required subcommand. Specify the system file, portable file, or scratch file to be read as a string file name or a file handle (see File Handles).
By default, all the variables in a file are read. The DROP subcommand can be used to specify a list of variables that are not to be read. By contrast, the KEEP subcommand can be used to specify variable that are to be read, with all other variables not read.
Normally variables in a file retain the names that they were saved under. Use the RENAME subcommand to change these names. Specify, within parentheses, a list of variable names followed by an equals sign (‘=’) and the names that they should be renamed to. Multiple parenthesized groups of variable names can be included on a single RENAME subcommand. Variables' names may be swapped using a RENAME subcommand of the form ‘/RENAME=(A B=B A)’.
Alternate syntax for the RENAME subcommand allows the parentheses to be eliminated. When this is done, only a single variable may be renamed at once. For instance, ‘/RENAME=A=B’. This alternate syntax is deprecated.
DROP, KEEP, and RENAME are executed in left-to-right order. Each may be present any number of times. GET never modifies a file on disk. Only the active file read from the file is affected by these subcommands.
GET does not cause the data to be read, only the dictionary. The data is read later, when a procedure is executed.
Use of GET to read a portable file or scratch file is a PSPP extension.
GET DATA
/TYPE={GNM,PSQL,TXT}
...additional subcommands depending on TYPE...
The GET DATA command is used to read files and other data sources created by other applications. When this command is executed, the current dictionary and active file are replaced with variables and data read from the specified source.
The TYPE subcommand is mandatory and must be the first subcommand specified. It determines the type of the file or source to read. PSPP currently supports the following file types:
Each supported file type has additional subcommands, explained in separate sections below.
GET DATA /TYPE=GNM
/FILE={'file-name'}
/SHEET={NAME 'sheet-name', INDEX n}
/CELLRANGE={RANGE 'range', FULL}
/READNAMES={ON, OFF}
/ASSUMEDVARWIDTH=n.
To use GET DATA to read a spreadsheet file created by Gnumeric (http://gnumeric.org), specify TYPE=GNM to indicate the file's format and use FILE to indicate the Gnumeric file to be read. All other subcommands are optional.
The format of each variable is determined by the format of the spreadsheet cell containing the first datum for the variable. If this cell is of string (text) format, then the width of the variable is determined from the length of the string it contains, unless the ASSUMEDVARWIDTH subcommand is given.
The FILE subcommand is mandatory. Specify the name of the file to be read.
The SHEET subcommand specifies the sheet within the spreadsheet file to read. There are two forms of the SHEET subcommand. In the first form, ‘/SHEET=name sheet-name’, the string sheet-name is the name of the sheet to read. In the second form, ‘/SHEET=index idx’, idx is a integer which is the index of the sheet to read. The first sheet has the index 1. If the SHEET subcommand is omitted, then the command will read the first sheet in the file.
The CELLRANGE subcommand specifies the range of cells within the sheet to read. If the subcommand is given as ‘/CELLRANGE=FULL’, then the entire sheet is read. To read only part of a sheet, use the form ‘/CELLRANGE=range 'top-left-cell:bottom-right-cell'’. For example, the subcommand ‘/CELLRANGE=range 'C3:P19'’ reads columns C–P, and rows 3–19 inclusive. If no CELLRANGE subcommand is given, then the entire sheet is read.
If ‘/READNAMES=ON’ is specified, then the contents of cells of the first row are used as the names of the variables in which to store the data from subsequent rows. If the READNAMES command is omitted, or if ‘/READNAMES=OFF’ is used, then the variables receive automatically assigned names.
The ASSUMEDVARWIDTH subcommand specifies the maximum width of string variables read from the file. If omitted, the default value is determined from the length of the string in the first spreadsheet cell for each variable.
GET DATA /TYPE=PSQL
/CONNECT={connection info}
/SQL={query}
[/ASSUMEDVARWIDTH=n]
[/UNENCRYPTED]
[/BSIZE=n].
The PSQL type is used to import data from a postgres database server. The server may be located locally or remotely. Variables are automatically created based on the table column names or the names specified in the SQL query. Postgres data types of high precision, will loose precision when imported into PSPP. Not all the postgres data types are able to be represented in PSPP. If a datum cannot be represented a warning will be issued and that datum will be set to SYSMIS.
The CONNECT subcommand is mandatory. It is a string specifying the parameters of the database server from which the data should be fetched. The format of the string is given in the postgres manual http://www.postgresql.org/docs/8.0/static/libpq.html#LIBPQ-CONNECT.
The SQL subcommand is mandatory. It must be a valid SQL string to retrieve data from the database.
The ASSUMEDVARWIDTH subcommand specifies the maximum width of string variables read from the database. If omitted, the default value is determined from the length of the string in the first value read for each variable.
The UNENCRYPTED subcommand allows data to be retrieved over an insecure connection. If the connection is not encrypted, and the UNENCRYPTED subcommand is not given, then an error will occur. Whether or not the connection is encrypted depends upon the underlying psql library and the capabilities of the database server.
The BSIZE subcommand serves only to optimise the speed of data transfer. It specifies an upper limit on number of cases to fetch from the database at once. The default value is 4096. If your SQL statement fetches a large number of cases but only a small number of variables, then the data transfer may be faster if you increase this value. Conversely, if the number of variables is large, or if the machine on which PSPP is running has only a small amount of memory, then a smaller value will be better.
The following syntax is an example:
GET DATA /TYPE=PSQL
/CONNECT='host=example.com port=5432 dbname=product user=fred passwd=xxxx'
/SQL='select * from manufacturer'.
GET DATA /TYPE=TXT
/FILE={'file-name',file_handle}
[/ARRANGEMENT={DELIMITED,FIXED}]
[/FIRSTCASE={first_case}]
[/IMPORTCASE={ALL,FIRST max_cases,PERCENT percent}]
...additional subcommands depending on ARRANGEMENT...
When TYPE=TXT is specified, GET DATA reads data in a delimited or fixed columnar format, much like DATA LIST (see DATA LIST).
The FILE subcommand is mandatory. Specify the file to be read as a string file name or (for textual data only) a file handle (see File Handles).
The ARRANGEMENT subcommand determines the file's basic format. DELIMITED, the default setting, specifies that fields in the input data are separated by spaces, tabs, or other user-specified delimiters. FIXED specifies that fields in the input data appear at particular fixed column positions within records of a case.
By default, cases are read from the input file starting from the first line. To skip lines at the beginning of an input file, set FIRSTCASE to the number of the first line to read: 2 to skip the first line, 3 to skip the first two lines, and so on.
IMPORTCASE can be used to limit the number of cases read from the input file. With the default setting, ALL, all cases in the file are read. Specify FIRST max_cases to read at most max_cases cases from the file. Use PERCENT percent to read only percent percent, approximately, of the cases contained in the file. (The percentage is approximate, because there is no way to accurately count the number of cases in the file without reading the entire file. The number of cases in some kinds of unusual files cannot be estimated; PSPP will read all cases in such files.)
FIRSTCASE and IMPORTCASE may be used with delimited and fixed-format data. The remaining subcommands, which apply only to one of the two file arrangements, are described below.
GET DATA /TYPE=TXT
/FILE={'file-name',file_handle}
[/ARRANGEMENT={DELIMITED,FIXED}]
[/FIRSTCASE={first_case}]
[/IMPORTCASE={ALL,FIRST max_cases,PERCENT percent}]
/DELIMITERS="delimiters"
[/QUALIFIER="quotes" [/ESCAPE]]
[/DELCASE={LINE,VARIABLES n_variables}]
/VARIABLES=del_var [del_var]...
where each del_var takes the form:
variable format
The GET DATA command with TYPE=TXT and ARRANGEMENT=DELIMITED reads input data from text files in delimited format, where fields are separated by a set of user-specified delimiters. Its capabilities are similar to those of DATA LIST FREE (see DATA LIST FREE), with a few enhancements.
The required FILE subcommand and optional FIRSTCASE and IMPORTCASE subcommands are described above (see GET DATA /TYPE=TXT).
DELIMITERS, which is required, specifies the set of characters that may separate fields. Each character in the string specified on DELIMITERS separates one field from the next. The end of a line also separates fields, regardless of DELIMITERS. Two consecutive delimiters in the input yield an empty field, as does a delimiter at the end of a line. A space character as a delimiter is an exception: consecutive spaces do not yield an empty field and neither does any number of spaces at the end of a line.
To use a tab as a delimiter, specify ‘\t’ at the beginning of the DELIMITERS string. To use a backslash as a delimiter, specify ‘\\’ as the first delimiter or, if a tab should also be a delimiter, immediately following ‘\t’. To read a data file in which each field appears on a separate line, specify the empty string for DELIMITERS.
The optional QUALIFIER subcommand names one or more characters that can be used to quote values within fields in the input. A field that begins with one of the specified quote characters ends at the next matching quote. Intervening delimiters become part of the field, instead of terminating it. The ability to specify more than one quote character is a PSPP extension.
By default, a character specified on QUALIFIER cannot itself be
embedded within a field that it quotes, because the quote character
always terminates the quoted field. With ESCAPE, however, a doubled
quote character within a quoted field inserts a single instance of the
quote into the field. For example, if ‘'’ is specified on
QUALIFIER, then without ESCAPE 'a''b' specifies a pair of
fields that contain ‘a’ and ‘b’, but with ESCAPE it
specifies a single field that contains ‘a'b’. ESCAPE is a PSPP
extension.
The DELCASE subcommand controls how data may be broken across lines in the data file. With LINE, the default setting, each line must contain all the data for exactly one case. For additional flexibility, to allow a single case to be split among lines or multiple cases to be contained on a single line, specify VARIABLES n_variables, where n_variables is the number of variables per case.
The VARIABLES subcommand is required and must be the last subcommand. Specify the name of each variable and its input format (see Input and Output Formats) in the order they should be read from the input file.
On a Unix-like system, the ‘/etc/passwd’ file has a format similar to this:
root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash
blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash
john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash
jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh
The following syntax reads a file in the format used by ‘/etc/passwd’:
GET DATA /TYPE=TXT /FILE='/etc/passwd' /DELIMITERS=':'
/VARIABLES=username A20
password A40
uid F10
gid F10
gecos A40
home A40
shell A40.
Consider the following data on used cars:
model year mileage price type age
Civic 2002 29883 15900 Si 2
Civic 2003 13415 15900 EX 1
Civic 1992 107000 3800 n/a 12
Accord 2002 26613 17900 EX 1
The following syntax can be used to read the used car data:
GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2
/VARIABLES=model A8
year F4
mileage F6
price F5
type A4
age F2.
Consider the following information on animals in a pet store:
'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type"
, (Years), , , (Dollars), ,
"Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog"
"Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish"
"Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat"
"Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
The following syntax can be used to read the pet store data:
GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE
/FIRSTCASE=3
/VARIABLES=name A10
age F3.1
color A5
received EDATE10
price F5.2
height a5
type a10.
GET DATA /TYPE=TXT
/FILE={'file-name',file_handle}
[/ARRANGEMENT={DELIMITED,FIXED}]
[/FIRSTCASE={first_case}]
[/IMPORTCASE={ALL,FIRST max_cases,PERCENT percent}]
[/FIXCASE=n]
/VARIABLES fixed_var [fixed_var]...
[/rec# fixed_var [fixed_var]...]...
where each fixed_var takes the form:
variable start-end format
The GET DATA command with TYPE=TXT and ARRANGEMENT=FIXED reads input data from text files in fixed format, where each field is located in particular fixed column positions within records of a case. Its capabilities are similar to those of DATA LIST FIXED (see DATA LIST FIXED), with a few enhancements.
The required FILE subcommand and optional FIRSTCASE and IMPORTCASE subcommands are described above (see GET DATA /TYPE=TXT).
The optional FIXCASE subcommand may be used to specify the positive integer number of input lines that make up each case. The default value is 1.
The VARIABLES subcommand, which is required, specifies the positions at which each variable can be found. For each variable, specify its name, followed by its start and end column separated by ‘-’ (e.g. ‘0-9’), followed by the input format type (e.g. ‘F’). For this command, columns are numbered starting from 0 at the left column. Introduce the variables in the second and later lines of a case by a slash followed by the number of the line within the case, e.g. ‘/2’ for the second line.
Consider the following data on used cars:
model year mileage price type age
Civic 2002 29883 15900 Si 2
Civic 2003 13415 15900 EX 1
Civic 1992 107000 3800 n/a 12
Accord 2002 26613 17900 EX 1
The following syntax can be used to read the used car data:
GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2
/VARIABLES=model 0-7 A
year 8-15 F
mileage 16-23 F
price 24-31 F
type 32-40 A
age 40-47 F.
IMPORT
/FILE='file-name'
/TYPE={COMM,TAPE}
/DROP=var_list
/KEEP=var_list
/RENAME=(src_names=target_names)...
The IMPORT transformation clears the active file dictionary and data and replaces them with a dictionary and data from a system, portable file, or scratch file.
The FILE subcommand, which is the only required subcommand, specifies the portable file to be read as a file name string or a file handle (see File Handles).
The TYPE subcommand is currently not used.
DROP, KEEP, and RENAME follow the syntax used by GET (see GET).
IMPORT does not cause the data to be read, only the dictionary. The data is read later, when a procedure is executed.
Use of IMPORT to read a system file or scratch file is a PSPP extension.
MATCH FILES
/{FILE,TABLE}={*,'file-name'}
/RENAME=(src_names=target_names)...
/IN=var_name
/BY=var_list
/DROP=var_list
/KEEP=var_list
/FIRST=var_name
/LAST=var_name
/MAP
MATCH FILES merges one or more system, portable, or scratch files, optionally including the active file. Cases with the same values for BY variables are combined into a single case. Cases with different values are output in order. Thus, multiple sorted files are combined into a single sorted file based on the value of the BY variables. The results of the merge become the new active file.
Specify FILE with a system, portable, or scratch file as a file name string or file handle (see File Handles), or with an asterisk (‘*’) to indicate the current active file. The files specified on FILE are merged together based on the BY variables, or combined case-by-case if BY is not specified.
Specify TABLE with a file to use it as a table lookup file. Cases in table lookup files are not used up after they've been used once. This means that data in table lookup files can correspond to any number of cases in FILE files. Table lookup files correspond to lookup tables in traditional relational database systems. If a table lookup file contains more than one case with a given set of BY variables, only the first case is used.
Any number of FILE and TABLE subcommands may be specified. Ordinarily, at least two FILE subcommands, or one FILE and at least one TABLE, should be specified. Each instance of FILE or TABLE can be followed by any sequence of RENAME subcommands. These have the same form and meaning as the corresponding subcommands of GET (see GET), but apply only to variables in the given file.
Each FILE or TABLE may optionally be followed by an IN subcommand, which creates a numeric variable with the specified name and format F1.0. The IN variable takes value 1 in a case if the given file contributed a row to the merged file, 0 otherwise. The DROP, KEEP, and RENAME subcommands do not affect IN variables.
When more than one FILE or TABLE contains a variable with a given name, those variables must all have the same type (numeric or string) and, for string variables, the same width. This rules applies to variable names after renaming with RENAME; thus, RENAME can be used to resolve conflicts.
FILE and TABLE must be specified at the beginning of the command, with any RENAME or IN specifications immediately after the corresponding FILE or TABLE. These subcommands are followed by BY, DROP, KEEP, FIRST, LAST, and MAP.
The BY subcommand specifies a list of variables that are used to match cases from each of the files. When TABLE or IN is used, BY is required; otherwise, it is optional. When BY is specified, all the files named on FILE and TABLE subcommands must be sorted in ascending order of the BY variables. Variables belonging to files that are not present for the current case are set to the system-missing value for numeric variables or spaces for string variables.
The DROP and KEEP subcommands allow variables to be dropped from or reordered within the new active file. These subcommands have the same form and meaning as the corresponding subcommands of GET (see GET). They apply to the new active file as a whole, not to individual input files. The variable names specified on DROP and KEEP are those after any renaming with RENAME.
The optional FIRST and LAST subcommands name variables that MATCH FILES adds to the active file. The new variables are numeric with print and write format F1.0. The value of the FIRST variable is 1 in the first case with a given set of values for the BY variables, and 0 in other cases. Similarly, the LAST variable is 1 in the last case with a given of BY values, and 0 in other cases.
MATCH FILES may not be specified following TEMPORARY (see TEMPORARY) if the active file is used as an input source.
Use of portable or scratch files on MATCH FILES is a PSPP extension.
SAVE
/OUTFILE={'file-name',file_handle}
/UNSELECTED={RETAIN,DELETE}
/{COMPRESSED,UNCOMPRESSED}
/PERMISSIONS={WRITEABLE,READONLY}
/DROP=var_list
/KEEP=var_list
/VERSION=version
/RENAME=(src_names=target_names)...
/NAMES
/MAP
The SAVE procedure causes the dictionary and data in the active file to be written to a system file or scratch file.
OUTFILE is the only required subcommand. Specify the system file or scratch file to be written as a string file name or a file handle (see File Handles).
By default, cases excluded with FILTER are written to the system file. These can be excluded by specifying DELETE on the UNSELECTED subcommand. Specifying RETAIN makes the default explicit.
The COMPRESS and UNCOMPRESS subcommand determine whether the saved system file is compressed. By default, system files are compressed. This default can be changed with the SET command (see SET).
The PERMISSIONS subcommand specifies permissions for the new system file. WRITEABLE, the default, creates the file with read and write permission. READONLY creates the file for read-only access.
By default, all the variables in the active file dictionary are written to the system file. The DROP subcommand can be used to specify a list of variables not to be written. In contrast, KEEP specifies variables to be written, with all variables not specified not written.
Normally variables are saved to a system file under the same names they have in the active file. Use the RENAME subcommand to change these names. Specify, within parentheses, a list of variable names followed by an equals sign (‘=’) and the names that they should be renamed to. Multiple parenthesized groups of variable names can be included on a single RENAME subcommand. Variables' names may be swapped using a RENAME subcommand of the form ‘/RENAME=(A B=B A)’.
Alternate syntax for the RENAME subcommand allows the parentheses to be eliminated. When this is done, only a single variable may be renamed at once. For instance, ‘/RENAME=A=B’. This alternate syntax is deprecated.
DROP, KEEP, and RENAME are performed in left-to-right order. They each may be present any number of times. SAVE never modifies the active file. DROP, KEEP, and RENAME only affect the system file written to disk.
The VERSION subcommand specifies the version of the file format. Valid versions are 2 and 3. The default version is 3. In version 2 system files, variable names longer than 8 bytes will be truncated. The two versions are otherwise identical.
The NAMES and MAP subcommands are currently ignored.
SAVE causes the data to be read. It is a procedure.
SYSFILE INFO FILE='file-name'.
SYSFILE INFO reads the dictionary in a system file and displays the information in its dictionary.
Specify a file name or file handle. SYSFILE INFO reads that file as a system file and displays information on its dictionary.
SYSFILE INFO does not affect the current active file.
XEXPORT
/OUTFILE='file-name'
/DIGITS=n
/DROP=var_list
/KEEP=var_list
/RENAME=(src_names=target_names)...
/TYPE={COMM,TAPE}
/MAP
The EXPORT transformation writes the active file dictionary and data to a specified portable file.
This transformation is a PSPP extension.
It is similar to the EXPORT procedure, with two differences:
See EXPORT, for more information.
XSAVE
/OUTFILE='file-name'
/{COMPRESSED,UNCOMPRESSED}
/PERMISSIONS={WRITEABLE,READONLY}
/DROP=var_list
/KEEP=var_list
/VERSION=version
/RENAME=(src_names=target_names)...
/NAMES
/MAP
The XSAVE transformation writes the active file dictionary and data to a system file or scratch file. It is similar to the SAVE procedure, with two differences:
See SAVE, for more information.
The variables in the active file dictionary are important. There are several utility functions for examining and adjusting them.
ADD VALUE LABELS
/var_list value 'label' [value 'label']...
ADD VALUE LABELS has the same syntax and purpose as VALUE LABELS (see VALUE LABELS), but it does not clear value labels from the variables before adding the ones specified.
DELETE VARIABLES var_list.
DELETE VARIABLES deletes the specified variables from the dictionary. It may not be used to delete all variables from the dictionary; use NEW FILE to do that (see NEW FILE).
DELETE VARIABLES should not used after defining transformations and before executing a procedure. If it is used in such a context, it causes the data to be read. If it is used while TEMPORARY is in effect, it causes the temporary transformations to become permanent.
DISPLAY {NAMES,INDEX,LABELS,VARIABLES,DICTIONARY,SCRATCH}
[SORTED] [var_list]
DISPLAY displays requested information on variables. Variables can optionally be sorted alphabetically. The entire dictionary or just specified variables can be described.
One of the following keywords can be present:
If SORTED is specified, then the variables are displayed in ascending order based on their names; otherwise, they are displayed in the order that they occur in the active file dictionary.
DISPLAY VECTORS.
DISPLAY VECTORS lists all the currently declared vectors.
FORMATS var_list (fmt_spec).
FORMATS set both print and write formats for the specified numeric variables to the specified format specification. See Input and Output Formats.
Specify a list of variables followed by a format specification in parentheses. The print and write formats of the specified variables will be changed.
Additional lists of variables and formats may be included if they are delimited by a slash (‘/’).
FORMATS takes effect immediately. It is not affected by conditional and looping structures such as DO IF or LOOP.
LEAVE var_list.
LEAVE prevents the specified variables from being reinitialized whenever a new case is processed.
Normally, when a data file is processed, every variable in the active file is initialized to the system-missing value or spaces at the beginning of processing for each case. When a variable has been specified on LEAVE, this is not the case. Instead, that variable is initialized to 0 (not system-missing) or spaces for the first case. After that, it retains its value between cases.
This becomes useful for counters. For instance, in the example below the variable SUM maintains a running total of the values in the ITEM variable.
DATA LIST /ITEM 1-3.
COMPUTE SUM=SUM+ITEM.
PRINT /ITEM SUM.
LEAVE SUM
BEGIN DATA.
123
404
555
999
END DATA.
Partial output from this example:
123 123.00
404 527.00
555 1082.00
999 2081.00
It is best to use LEAVE command immediately before invoking a procedure command, because the left status of variables is reset by certain transformations—for instance, COMPUTE and IF. Left status is also reset by all procedure invocations.
MISSING VALUES var_list (missing_values).
missing_values takes one of the following forms:
num1
num1, num2
num1, num2, num3
num1 THRU num2
num1 THRU num2, num3
string1
string1, string2
string1, string2, string3
As part of a range, LO or LOWEST may take the place of num1;
HI or HIGHEST may take the place of num2.
MISSING VALUES sets user-missing values for numeric and short string variables. Long string variables may not have missing values.
Specify a list of variables, followed by a list of their user-missing values in parentheses. Up to three discrete values may be given, or, for numeric variables only, a range of values optionally accompanied by a single discrete value. Ranges may be open-ended on one end, indicated through the use of the keyword LO or LOWEST or HI or HIGHEST.
The MISSING VALUES command takes effect immediately. It is not affected by conditional and looping constructs such as DO IF or LOOP.
MODIFY VARS
/REORDER={FORWARD,BACKWARD} {POSITIONAL,ALPHA} (var_list)...
/RENAME=(old_names=new_names)...
/{DROP,KEEP}=var_list
/MAP
MODIFY VARS reorders, renames, and deletes variables in the active file.
At least one subcommand must be specified, and no subcommand may be specified more than once. DROP and KEEP may not both be specified.
The REORDER subcommand changes the order of variables in the active file. Specify one or more lists of variable names in parentheses. By default, each list of variables is rearranged into the specified order. To put the variables into the reverse of the specified order, put keyword BACKWARD before the parentheses. To put them into alphabetical order in the dictionary, specify keyword ALPHA before the parentheses. BACKWARD and ALPHA may also be combined.
To rename variables in the active file, specify RENAME, an equals sign (‘=’), and lists of the old variable names and new variable names separated by another equals sign within parentheses. There must be the same number of old and new variable names. Each old variable is renamed to the corresponding new variable name. Multiple parenthesized groups of variables may be specified.
The DROP subcommand deletes a specified list of variables from the active file.
The KEEP subcommand keeps the specified list of variables in the active file. Any unlisted variables are deleted from the active file.
MAP is currently ignored.
If either DROP or KEEP is specified, the data is read; otherwise it is not.
MODIFY VARS may not be specified following TEMPORARY (see TEMPORARY).
NUMERIC /var_list [(fmt_spec)].
NUMERIC explicitly declares new numeric variables, optionally setting their output formats.
Specify a slash (‘/’), followed by the names of the new numeric variables. If you wish to set their output formats, follow their names by an output format specification in parentheses (see Input and Output Formats); otherwise, the default is F8.2.
Variables created with NUMERIC are initialized to the system-missing value.
PRINT FORMATS var_list (fmt_spec).
PRINT FORMATS sets the print formats for the specified numeric variables to the specified format specification.
Its syntax is identical to that of FORMATS (see FORMATS), but PRINT FORMATS sets only print formats, not write formats.
RENAME VARIABLES (old_names=new_names)... .
RENAME VARIABLES changes the names of variables in the active file. Specify lists of the old variable names and new variable names, separated by an equals sign (‘=’), within parentheses. There must be the same number of old and new variable names. Each old variable is renamed to the corresponding new variable name. Multiple parenthesized groups of variables may be specified.
RENAME VARIABLES takes effect immediately. It does not cause the data to be read.
RENAME VARIABLES may not be specified following TEMPORARY (see TEMPORARY).
VALUE LABELS
/var_list value 'label' [value 'label']...
VALUE LABELS allows values of numeric and short string variables to be associated with labels. In this way, a short value can stand for a long value.
To set up value labels for a set of variables, specify the variable names after a slash (‘/’), followed by a list of values and their associated labels, separated by spaces. Long string variables may not be specified.
Before VALUE LABELS is executed, any existing value labels are cleared from the variables specified. Use ADD VALUE LABELS (see ADD VALUE LABELS) to add value labels without clearing those already present.
STRING /var_list (fmt_spec).
STRING creates new string variables for use in transformations.
Specify a slash (‘/’), followed by the names of the string variables to create and the desired output format specification in parentheses (see Input and Output Formats). Variable widths are implicitly derived from the specified output formats.
Created variables are initialized to spaces.
VARIABLE LABELS
var_list 'var_label'
[ /var_list 'var_label']
.
.
.
[ /var_list 'var_label']
VARIABLE LABELS associates explanatory names with variables. This name, called a variable label, is displayed by statistical procedures.
To assign a variable label to a group of variables, specify a list of variable names and the variable label as a string. To assign different labels to different variables in the same command, precede the subsequent variable list with a slash (‘/’).
VARIABLE ALIGNMENT
var_list ( LEFT | RIGHT | CENTER )
[ /var_list ( LEFT | RIGHT | CENTER ) ]
.
.
.
[ /var_list ( LEFT | RIGHT | CENTER ) ]
VARIABLE ALIGNMENT sets the alignment of variables for display editing purposes. This only has effect for third party software. It does not affect the display of variables in the PSPP output.
VARIABLE WIDTH
var_list (width)
[ /var_list (width) ]
.
.
.
[ /var_list (width) ]
VARIABLE WIDTH sets the column width of variables for display editing purposes. This only affects third party software. It does not affect the display of variables in the PSPP output.
VARIABLE LEVEL
var_list ( SCALE | NOMINAL | ORDINAL )
[ /var_list ( SCALE | NOMINAL | ORDINAL ) ]
.
.
.
[ /var_list ( SCALE | NOMINAL | ORDINAL ) ]
VARIABLE LEVEL sets the measurement level of variables. Currently, this has no effect except for certain third party software.
Two possible syntaxes:
VECTOR vec_name=var_list.
VECTOR vec_name_list(count [format]).
VECTOR allows a group of variables to be accessed as if they were consecutive members of an array with a vector(index) notation.
To make a vector out of a set of existing variables, specify a name for the vector followed by an equals sign (‘=’) and the variables to put in the vector. All the variables in the vector must be the same type. String variables in a vector must all have the same width.
To make a vector and create variables at the same time, specify one or
more vector names followed by a count in parentheses. This will cause
variables named vec1 through veccount
to be created as numeric variables. By default, the new variables
have print and write format F8.2, but an alternate format may be
specified inside the parentheses before or after the count and
separated from it by white space or a comma. Variable names including
numeric suffixes may not exceed 64 characters in length, and none of
the variables may exist prior to VECTOR.
Vectors created with VECTOR disappear after any procedure or procedure-like command is executed. The variables contained in the vectors remain, unless they are scratch variables (see Scratch Variables).
Variables within a vector may be referenced in expressions using
vector(index) syntax.
WRITE FORMATS var_list (fmt_spec).
WRITE FORMATS sets the write formats for the specified numeric variables to the specified format specification. Its syntax is identical to that of FORMATS (see FORMATS), but WRITE FORMATS sets only write formats, not print formats.
The PSPP procedures examined in this chapter manipulate data and prepare the active file for later analyses. They do not produce output, as a rule.
AGGREGATE
OUTFILE={*,'file-name',file_handle}
/PRESORTED
/DOCUMENT
/MISSING=COLUMNWISE
/BREAK=var_list
/dest_var['label']...=agr_func(src_vars, args...)...
AGGREGATE summarizes groups of cases into single cases. Cases are divided into groups that have the same values for one or more variables called break variables. Several functions are available for summarizing case contents.
The OUTFILE subcommand is required and must appear first. Specify a system file, portable file, or scratch file by file name or file handle (see File Handles). The aggregated cases are written to this file. If ‘*’ is specified, then the aggregated cases replace the active file. Use of OUTFILE to write a portable file or scratch file is a PSPP extension.
By default, the active file will be sorted based on the break variables before aggregation takes place. If the active file is already sorted or otherwise grouped in terms of the break variables, specify PRESORTED to save time.
Specify DOCUMENT to copy the documents from the active file into the aggregate file (see DOCUMENT). Otherwise, the aggregate file will not contain any documents, even if the aggregate file replaces the active file.
Normally, only a single case (for SD and SD., two cases) need be non-missing in each group for the aggregate variable to be non-missing. Specifying /MISSING=COLUMNWISE inverts this behavior, so that the aggregate variable becomes missing if any aggregated value is missing.
If PRESORTED, DOCUMENT, or MISSING are specified, they must appear between OUTFILE and BREAK.
At least one break variable must be specified on BREAK, a required subcommand. The values of these variables are used to divide the active file into groups to be summarized. In addition, at least one dest_var must be specified.
One or more sets of aggregation variables must be specified. Each set comprises a list of aggregation variables, an equals sign (‘=’), the name of an aggregation function (see the list below), and a list of source variables in parentheses. Some aggregation functions expect additional arguments following the source variable names.
Aggregation variables typically are created with no variable label, value labels, or missing values. Their default print and write formats depend on the aggregation function used, with details given in the table below. A variable label for an aggregation variable may be specified just after the variable's name in the aggregation variable list.
Each set must have exactly as many source variables as aggregation variables. Each aggregation variable receives the results of applying the specified aggregation function to the corresponding source variable. The MEAN, SD, and SUM aggregation functions may only be applied to numeric variables. All the rest may be applied to numeric and short and long string variables.
The available aggregation functions are as follows:
Aggregation functions compare string values in terms of internal character codes. On most modern computers, this is a form of ASCII.
The aggregation functions listed above exclude all user-missing values from calculations. To include user-missing values, insert a period (‘.’) at the end of the function name. (e.g. ‘SUM.’). (Be aware that specifying such a function as the last token on a line will cause the period to be interpreted as the end of the command.)
AGGREGATE both ignores and cancels the current SPLIT FILE settings (see SPLIT FILE).
AUTORECODE VARIABLES=src_vars INTO dest_vars
/DESCENDING
/PRINT
The AUTORECODE procedure considers the n values that a variable takes on and maps them onto values 1...n on a new numeric variable.
Subcommand VARIABLES is the only required subcommand and must come first. Specify VARIABLES, an equals sign (‘=’), a list of source variables, INTO, and a list of target variables. There must the same number of source and target variables. The target variables must not already exist.
By default, increasing values of a source variable (for a string, this is based on character code comparisons) are recoded to increasing values of its target variable. To cause increasing values of a source variable to be recoded to decreasing values of its target variable (n down to 1), specify DESCENDING.
PRINT is currently ignored.
AUTORECODE is a procedure. It causes the data to be read.
COMPUTE variable = expression.
or
COMPUTE vector(index) = expression.
COMPUTE assigns the value of an expression to a target variable. For each case, the expression is evaluated and its value assigned to the target variable. Numeric and short and long string variables may be assigned. When a string expression's width differs from the target variable's width, the string result of the expression is truncated or padded with spaces on the right as necessary. The expression and variable types must match.
For numeric variables only, the target variable need not already
exist. Numeric variables created by COMPUTE are assigned an
F8.2 output format. String variables must be declared before
they can be used as targets for COMPUTE.
The target variable may be specified as an element of a vector (see VECTOR). In this case, a vector index expression must be specified in parentheses following the vector name. The index expression must evaluate to a numeric value that, after rounding down to the nearest integer, is a valid index for the named vector.
Using COMPUTE to assign to a variable specified on LEAVE
(see LEAVE) resets the variable's left state. Therefore,
LEAVE should be specified following COMPUTE, not before.
COMPUTE is a transformation. It does not cause the active file to be read.
When COMPUTE is specified following TEMPORARY (see TEMPORARY), the LAG function may not be used (see LAG).
COUNT var_name = var... (value...).
Each value takes one of the following forms:
number
string
num1 THRU num2
MISSING
SYSMIS
In addition, num1 and num2 can be LO or LOWEST, or HI or HIGHEST,
respectively.
COUNT creates or replaces a numeric target variable that counts the occurrence of a criterion value or set of values over one or more test variables for each case.
The target variable values are always nonnegative integers. They are never missing. The target variable is assigned an F8.2 output format. See Input and Output Formats. Any variables, including long and short string variables, may be test variables.
User-missing values of test variables are treated just like any other values. They are not treated as system-missing values. User-missing values that are criterion values or inside ranges of criterion values are counted as any other values. However (for numeric variables), keyword MISSING may be used to refer to all system- and user-missing values.
COUNT target variables are assigned values in the order
specified. In the command COUNT A=A B(1) /B=A B(2)., the
following actions occur:
A and B is counted.
A is assigned this value.
B and the new
value of A is counted.
B is assigned this value.
Despite this ordering, all COUNT criterion variables must exist before the procedure is executed—they may not be created as target variables earlier in the command! Break such a command into two separate commands.
The examples below may help to clarify.
Q0, Q2, ..., Q9 are numeric variables,
the following commands:
QCOUNT.
COUNT QCOUNT=Q0 TO Q9(1).
DESCRIPTIVES QCOUNT /STATISTICS=SUM.
QVALID.
QVALID by 10 to obtain a percentage of
valid values, using COMPUTE. See COMPUTE, for details.
COUNT QVALID=Q0 TO Q9 (LO THRU HI).
COMPUTE QVALID=QVALID*10.
DESCRIPTIVES QVALID /STATISTICS=MEAN.
FLIP /VARIABLES=var_list /NEWNAMES=var_name.
FLIP transposes rows and columns in the active file. It causes cases to be swapped with variables, and vice versa.
All variables in the transposed active file are numeric. String variables take on the system-missing value in the transposed file.
No subcommands are required. If specified, the VARIABLES subcommand selects variables to be transformed into cases, and variables not specified are discarded. If the VARIABLES subcommand is omitted, all variables are selected for transposition.
The variables specified by NEWNAMES, which must be a string variable, is used to give names to the variables created by FLIP. Only the first 8 characters of the variable are used. If NEWNAMES is not specified then the default is a variable named CASE_LBL, if it exists. If it does not then the variables created by FLIP are named VAR000 through VAR999, then VAR1000, VAR1001, and so on.
When a NEWNAMES variable is available, the names must be canonicalized before becoming variable names. Invalid characters are replaced by letter ‘V’ in the first position, or by ‘_’ in subsequent positions. If the name thus generated is not unique, then numeric extensions are added, starting with 1, until a unique name is found or there are no remaining possibilities. If the latter occurs then the FLIP operation aborts.
The resultant dictionary contains a CASE_LBL variable, a string variable of width 8, which stores the names of the variables in the dictionary before the transposition. Variables names longer than 8 characters are truncated. If the active file is subsequently transposed using FLIP, this variable can be used to recreate the original variable names.
FLIP honors N OF CASES (see N OF CASES). It ignores TEMPORARY (see TEMPORARY), so that “temporary” transformations become permanent.
IF condition variable=expression.
or
IF condition vector(index)=expression.
The IF transformation conditionally assigns the value of a target expression to a target variable, based on the truth of a test expression.
Specify a boolean-valued expression (see Expressions) to be tested following the IF keyword. This expression is evaluated for each case. If the value is true, then the value of the expression is computed and assigned to the specified variable. If the value is false or missing, nothing is done. Numeric and short and long string variables may be assigned. When a string expression's width differs from the target variable's width, the string result of the expression is truncated or padded with spaces on the right as necessary. The expression and variable types must match.
The target variable may be specified as an element of a vector (see VECTOR). In this case, a vector index expression must be specified in parentheses following the vector name. The index expression must evaluate to a numeric value that, after rounding down to the nearest integer, is a valid index for the named vector.
Using IF to assign to a variable specified on LEAVE
(see LEAVE) resets the variable's left state. Therefore,
LEAVE should be specified following IF, not before.
When IF is specified following TEMPORARY (see TEMPORARY), the LAG function may not be used (see LAG).
RECODE var_list (src_value...=dest_value)... [INTO var_list].
src_value may take the following forms:
number
string
num1 THRU num2
MISSING
SYSMIS
ELSE
Open-ended ranges may be specified using LO or LOWEST for num1
or HI or HIGHEST for num2.
dest_value may take the following forms:
num
string
SYSMIS
COPY
RECODE translates data from one range of values to another, via flexible user-specified mappings. Data may be remapped in-place or copied to new variables. Numeric, short string, and long string data can be recoded.
Specify the list of source variables, followed by one or more mapping specifications each enclosed in parentheses. If the data is to be copied to new variables, specify INTO, then the list of target variables. String target variables must already have been declared using STRING or another transformation, but numeric target variables can be created on the fly. There must be exactly as many target variables as source variables. Each source variable is remapped into its corresponding target variable.
When INTO is not used, the input and output variables must be of the same type. Otherwise, string values can be recoded into numeric values, and vice versa. When this is done and there is no mapping for a particular value, either a value consisting of all spaces or the system-missing value is assigned, depending on variable type.
Mappings are considered from left to right. The first src_value that matches the value of the source variable causes the target variable to receive the value indicated by the dest_value. Literal number, string, and range src_value's should be self-explanatory. MISSING as a src_value matches any user- or system-missing value. SYSMIS matches the system missing value only. ELSE is a catch-all that matches anything. It should be the last src_value specified.
Numeric and string dest_value's should be self-explanatory. COPY causes the input values to be copied to the output. This is only valid if the source and target variables are of the same type. SYSMIS indicates the system-missing value.
If the source variables are strings and the target variables are numeric, then there is one additional mapping available: (CONVERT), which must be the last specified mapping. CONVERT causes a number specified as a string to be converted to a numeric value. If the string cannot be parsed as a number, then the system-missing value is assigned.
Multiple recodings can be specified on a single RECODE invocation. Introduce additional recodings with a slash (‘/’) to separate them from the previous recodings.
SORT CASES BY var_list[({D|A}] [ var_list[({D|A}] ] ...
SORT CASES sorts the active file by the values of one or more variables.
Specify BY and a list of variables to sort by. By default, variables are sorted in ascending order. To override sort order, specify (D) or (DOWN) after a list of variables to get descending order, or (A) or (UP) for ascending order. These apply to all the listed variables up until the preceding (A), (D), (UP) or (DOWN).
The sort algorithms used by SORT CASES are stable. That is, records that have equal values of the sort variables will have the same relative order before and after sorting. As a special case, re-sorting an already sorted file will not affect the ordering of cases.
SORT CASES is a procedure. It causes the data to be read.
SORT CASES attempts to sort the entire active file in main memory. If workspace is exhausted, it falls back to a merge sort algorithm that involves creates numerous temporary files.
SORT CASES may not be specified following TEMPORARY.
This chapter documents PSPP commands that temporarily or permanently select data records from the active file for analysis.
FILTER BY var_name.
FILTER OFF.
FILTER allows a boolean-valued variable to be used to select cases from the data stream for processing.
To set up filtering, specify BY and a variable name. Keyword BY is optional but recommended. Cases which have a zero or system- or user-missing value are excluded from analysis, but not deleted from the data stream. Cases with other values are analyzed. To filter based on a different condition, use transformations such as COMPUTE or RECODE to compute a filter variable of the required form, then specify that variable on FILTER.
FILTER OFF turns off case filtering.
Filtering takes place immediately before cases pass to a procedure for
analysis. Only one filter variable may be active at a time. Normally,
case filtering continues until it is explicitly turned off with FILTER
OFF. However, if FILTER is placed after TEMPORARY, it filters only
the next procedure or procedure-like command.
N [OF CASES] num_of_cases [ESTIMATED].
N OF CASES limits the number of cases processed by any
procedures that follow it in the command stream. N OF CASES
100, for example, tells PSPP to disregard all cases after the first
100.
When N OF CASES is specified after TEMPORARY, it affects only the next procedure (see TEMPORARY). Otherwise, cases beyond the limit specified are not processed by any later procedure.
If the limit specified on N OF CASES is greater than the number of cases in the active file, it has no effect.
When N OF CASES is used along with SAMPLE or SELECT
IF, the case limit is applied to the cases obtained after sampling or
case selection, regardless of how N OF CASES is placed relative
to SAMPLE or SELECT IF in the command file. Thus, the
commands N OF CASES 100 and SAMPLE .5 will both randomly
sample approximately half of the active file's cases, then select the
first 100 of those sampled, regardless of their order in the command
file.
N OF CASES with the ESTIMATED keyword gives an estimated
number of cases before DATA LIST or another command to read in
data. ESTIMATED never limits the number of cases processed by
procedures. PSPP currently does not make use of case count estimates.
SAMPLE num1 [FROM num2].
SAMPLE randomly samples a proportion of the cases in the active file. Unless it follows TEMPORARY, it operates as a transformation, permanently removing cases from the active file.
The proportion to sample can be expressed as a single number between 0
and 1. If k is the number specified, and N is the number
of currently-selected cases in the active file, then after
SAMPLE k., approximately k*N cases will be
selected.
The proportion to sample can also be specified in the style SAMPLE
m FROM N. With this style, cases are selected as follows:
SAMPLE and SELECT IF are performed in the order specified by the syntax file.
SAMPLE is always performed before N OF CASES, regardless
of ordering in the syntax file (see N OF CASES).
The same values for SAMPLE may result in different samples. To
obtain the same sample, use the SET command to set the random
number seed to the same value before each SAMPLE. Different
samples may still result when the file is processed on systems with
differing endianness or floating-point formats. By default, the
random number seed is based on the system time.
SELECT IF expression.
SELECT IF selects cases for analysis based on the value of a boolean expression. Cases not selected are permanently eliminated from the active file, unless TEMPORARY is in effect (see TEMPORARY).
Specify a boolean expression (see Expressions). If the value of the expression is true for a particular case, the case will be analyzed. If the expression has a false or missing value, then the case will be deleted from the data stream.
Place SELECT IF as early in the command file as possible. Cases that are deleted early can be processed more efficiently in time and space.
When SELECT IF is specified following TEMPORARY (see TEMPORARY), the LAG function may not be used (see LAG).
SPLIT FILE [{LAYERED, SEPARATE}] BY var_list.
SPLIT FILE OFF.
SPLIT FILE allows multiple sets of data present in one data file to be analyzed separately using single statistical procedure commands.
Specify a list of variable names to analyze multiple sets of data separately. Groups of adjacent cases having the same values for these variables are analyzed by statistical procedure commands as one group. An independent analysis is carried out for each group of cases, and the variable values for the group are printed along with the analysis.
When a list of variable names is specified, one of the keywords LAYERED or SEPARATE may also be specified. If provided, either keyword are ignored.
Groups are formed only by adjacent cases. To create a split using a variable where like values are not adjacent in the working file, you should first sort the data by that variable (see SORT CASES).
Specify OFF to disable SPLIT FILE and resume analysis of the entire active file as a single group of data.
When SPLIT FILE is specified after TEMPORARY, it affects only the next procedure (see TEMPORARY).
TEMPORARY.
TEMPORARY is used to make the effects of transformations following its execution temporary. These transformations will affect only the execution of the next procedure or procedure-like command. Their effects will not be saved to the active file.
The only specification on TEMPORARY is the command name.
TEMPORARY may not appear within a DO IF or LOOP construct. It may appear only once between procedures and procedure-like commands.
Scratch variables cannot be used following TEMPORARY.
An example may help to clarify:
DATA LIST /X 1-2.
BEGIN DATA.
2
4
10
15
20
24
END DATA.
COMPUTE X=X/2.
TEMPORARY.
COMPUTE X=X+3.
DESCRIPTIVES X.
DESCRIPTIVES X.
The data read by the first DESCRIPTIVES are 4, 5, 8, 10.5, 13, 15. The data read by the first DESCRIPTIVES are 1, 2, 5, 7.5, 10, 12.
WEIGHT BY var_name.
WEIGHT OFF.
WEIGHT assigns cases varying weights, changing the frequency distribution of the active file. Execution of WEIGHT is delayed until data have been read.
If a variable name is specified, WEIGHT causes the values of that variable to be used as weighting factors for subsequent statistical procedures. Use of keyword BY is optional but recommended. Weighting variables must be numeric. Scratch variables may not be used for weighting (see Scratch Variables).
When OFF is specified, subsequent statistical procedures will weight all cases equally.
A positive integer weighting factor w on a case will yield the same statistical output as would replicating the case w times. A weighting factor of 0 is treated for statistical purposes as if the case did not exist in the input. Weighting values need not be integers, but negative and system-missing values for the weighting variable are interpreted as weighting factors of 0. User-missing values are not treated specially.
When WEIGHT is specified after TEMPORARY, it affects only the next procedure (see TEMPORARY).
WEIGHT does not cause cases in the active file to be replicated in memory.
This chapter documents PSPP commands used for conditional execution, looping, and flow of control.
BREAK.
BREAK terminates execution of the innermost currently executing LOOP construct.
BREAK is allowed only inside LOOP...END LOOP. See LOOP, for more details.
DO IF condition.
...
[ELSE IF condition.
...
]...
[ELSE.
...]
END IF.
DO IF allows one of several sets of transformations to be executed, depending on user-specified conditions.
If the specified boolean expression evaluates as true, then the block of code following DO IF is executed. If it evaluates as missing, then none of the code blocks is executed. If it is false, then the boolean expression on the first ELSE IF, if present, is tested in turn, with the same rules applied. If all expressions evaluate to false, then the ELSE code block is executed, if it is present.
When DO IF or ELSE IF is specified following TEMPORARY (see TEMPORARY), the LAG function may not be used (see LAG).
DO REPEAT dummy_name=expansion....
...
END REPEAT [PRINT].
expansion takes one of the following forms:
var_list
num_or_range...
'string'...
num_or_range takes one of the following forms:
number
num1 TO num2
DO REPEAT repeats a block of code, textually substituting different variables, numbers, or strings into the block with each repetition.
Specify a dummy variable name followed by an equals sign (‘=’) and
the list of replacements. Replacements can be a list of variables
(which may be existing variables or new variables or some combination),
numbers, or strings. When new variable names are
specified, DO REPEAT creates them as numeric variables. When numbers
are specified, runs of increasing integers may be indicated as
num1 TO num2, so that
‘1 TO 5’ is short for ‘1 2 3 4 5’.
Multiple dummy variables can be specified. Each variable must have the same number of replacements.
The code within DO REPEAT is repeated as many times as there are replacements for each variable. The first time, the first value for each dummy variable is substituted; the second time, the second value for each dummy variable is substituted; and so on.
Dummy variable substitutions work like macros. They take place anywhere in a line that the dummy variable name occurs as a token, including command and subcommand names. For this reason, words commonly used in command and subcommand names should not be used as dummy variable identifiers.
If PRINT is specified on END REPEAT, the commands after substitutions are made are printed to the listing file, prefixed by a plus sign (‘+’).
LOOP [index_var=start TO end [BY incr]] [IF condition].
...
END LOOP [IF condition].
LOOP iterates a group of commands. A number of termination options are offered.
Specify index_var to make that variable count from one value to another by a particular increment. index_var must be a pre-existing numeric variable. start, end, and incr are numeric expressions (see Expressions.)
During the first iteration, index_var is set to the value of start. During each successive iteration, index_var is increased by the value of incr. If end > start, then the loop terminates when index_var > end; otherwise it terminates when index_var < end. If incr is not specified then it defaults to +1 or -1 as appropriate.
If end > start and incr < 0, or if end < start and incr > 0, then the loop is never executed. index_var is nevertheless set to the value of start.
Modifying index_var within the loop is allowed, but it has no effect on the value of index_var in the next iteration.
Specify a boolean expression for the condition on LOOP to cause the loop to be executed only if the condition is true. If the condition is false or missing before the loop contents are executed the first time, the loop contents are not executed at all.
If index and condition clauses are both present on LOOP, the index variable is always set before the condition is evaluated. Thus, a condition that makes use of the index variable will always see the index value to be used in the next execution of the body.
Specify a boolean expression for the condition on END LOOP to cause the loop to terminate if the condition is true after the enclosed code block is executed. The condition is evaluated at the end of the loop, not at the beginning, so that the body of a loop with only a condition on END LOOP will always execute at least once.
If neither the index clause nor either condition clause is present, then the loop is executed MXLOOPS (see SET) times.
BREAK also terminates LOOP execution (see BREAK).
Loop index variables are by default reset to system-missing from one case to another, not left, unless a scratch variable is used as index. When loops are nested, this is usually undesired behavior, which can be corrected with LEAVE (see LEAVE) or by using a scratch variable as the loop index.
When LOOP or END LOOP is specified following TEMPORARY (see TEMPORARY), the LAG function may not be used (see LAG).
This chapter documents the statistical procedures that PSPP supports so far.
DESCRIPTIVES
/VARIABLES=var_list
/MISSING={VARIABLE,LISTWISE} {INCLUDE,NOINCLUDE}
/FORMAT={LABELS,NOLABELS} {NOINDEX,INDEX} {LINE,SERIAL}
/SAVE
/STATISTICS={ALL,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,
SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,DEFAULT,
SESKEWNESS,SEKURTOSIS}
/SORT={NONE,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,SKEWNESS,
RANGE,MINIMUM,MAXIMUM,SUM,SESKEWNESS,SEKURTOSIS,NAME}
{A,D}
The DESCRIPTIVES procedure reads the active file and outputs descriptive statistics requested by the user. In addition, it can optionally compute Z-scores.
The VARIABLES subcommand, which is required, specifies the list of variables to be analyzed. Keyword VARIABLES is optional.
All other subcommands are optional:
The MISSING subcommand determines the handling of missing variables. If INCLUDE is set, then user-missing values are included in the calculations. If NOINCLUDE is set, which is the default, user-missing values are excluded. If VARIABLE is set, then missing values are excluded on a variable by variable basis; if LISTWISE is set, then the entire case is excluded whenever any value in that case has a system-missing or, if INCLUDE is set, user-missing value.
The FORMAT subcommand affects the output format. Currently the LABELS/NOLABELS and NOINDEX/INDEX settings are not used. When SERIAL is set, both valid and missing number of cases are listed in the output; when NOSERIAL is set, only valid cases are listed.
The SAVE subcommand causes DESCRIPTIVES to calculate Z scores for all the specified variables. The Z scores are saved to new variables. Variable names are generated by trying first the original variable name with Z prepended and truncated to a maximum of 8 characters, then the names ZSC000 through ZSC999, STDZ00 through STDZ09, ZZZZ00 through ZZZZ09, ZQZQ00 through ZQZQ09, in that sequence. In addition, Z score variable names can be specified explicitly on VARIABLES in the variable list by enclosing them in parentheses after each variable.
The STATISTICS subcommand specifies the statistics to be displayed:
ALLMEANSEMEANSTDDEVVARIANCEKURTOSISSKEWNESSRANGEMINIMUMMAXIMUMSUMDEFAULTSEKURTOSISSESKEWNESSThe SORT subcommand specifies how the statistics should be sorted. Most of the possible values should be self-explanatory. NAME causes the statistics to be sorted by name. By default, the statistics are listed in the order that they are specified on the VARIABLES subcommand. The A and D settings request an ascending or descending sort order, respectively.
FREQUENCIES
/VARIABLES=var_list
/FORMAT={TABLE,NOTABLE,LIMIT(limit)}
{STANDARD,CONDENSE,ONEPAGE[(onepage_limit)]}
{LABELS,NOLABELS}
{AVALUE,DVALUE,AFREQ,DFREQ}
{SINGLE,DOUBLE}
{OLDPAGE,NEWPAGE}
/MISSING={EXCLUDE,INCLUDE}
/STATISTICS={DEFAULT,MEAN,SEMEAN,MEDIAN,MODE,STDDEV,VARIANCE,
KURTOSIS,SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,
SESKEWNESS,SEKURTOSIS,ALL,NONE}
/NTILES=ntiles
/PERCENTILES=percent...
/HISTOGRAM=[MINIMUM(x_min)] [MAXIMUM(x_max)]
[{FREQ,PCNT}] [{NONORMAL,NORMAL}]
/PIECHART=[MINIMUM(x_min)] [MAXIMUM(x_max)] {NOMISSING,MISSING}
(These options are not currently implemented.)
/BARCHART=...
/HBAR=...
/GROUPED=...
The FREQUENCIES procedure outputs frequency tables for specified variables. FREQUENCIES can also calculate and display descriptive statistics (including median and mode) and percentiles.
FREQUENCIES also support graphical output in the form of histograms and pie charts. In the future, it will be able to produce bar charts and output percentiles for grouped data.
The VARIABLES subcommand is the only required subcommand. Specify the variables to be analyzed.
The FORMAT subcommand controls the output format. It has several possible settings:
The MISSING subcommand controls the handling of user-missing values. When EXCLUDE, the default, is set, user-missing values are not included in frequency tables or statistics. When INCLUDE is set, user-missing are included. System-missing values are never included in statistics, but are listed in frequency tables.
The available STATISTICS are the same as available in DESCRIPTIVES (see DESCRIPTIVES), with the addition of MEDIAN, the data's median value, and MODE, the mode. (If there are multiple modes, the smallest value is reported.) By default, the mean, standard deviation of the mean, minimum, and maximum are reported for each variable.
PERCENTILES causes the specified percentiles to be reported.
The percentiles should be presented at a list of numbers between 0
and 100 inclusive.
The NTILES subcommand causes the percentiles to be reported at the
boundaries of the data set divided into the specified number of ranges.
For instance, /NTILES=4 would cause quartiles to be reported.
The HISTOGRAM subcommand causes the output to include a histogram for each specified variable. The X axis by default ranges from the minimum to the maximum value observed in the data, but the MINIMUM and MAXIMUM keywords can set an explicit range. The Y axis by default is labeled in frequencies; use the PERCENT keyword to causes it to be labeled in percent of the total observed count. Specify NORMAL to superimpose a normal curve on the histogram.
The PIECHART adds a pie chart for each variable to the data. Each slice represents one value, with the size of the slice proportional to the value's frequency. By default, all non-missing values are given slices. The MINIMUM and MAXIMUM keywords can be used to limit the displayed slices to a given range of values. The MISSING keyword adds slices for missing values.
EXAMINE
VARIABLES=var_list [BY factor_list ]
/STATISTICS={DESCRIPTIVES, EXTREME[(n)], ALL, NONE}
/PLOT={BOXPLOT, NPPLOT, HISTOGRAM, ALL, NONE}
/CINTERVAL n
/COMPARE={GROUPS,VARIABLES}
/ID={case_number, var_name}
/{TOTAL,NOTOTAL}
/PERCENTILE=[value_list]={HAVERAGE, WAVERAGE, ROUND, AEMPIRICAL, EMPIRICAL }
/MISSING={LISTWISE, PAIRWISE} [{EXCLUDE, INCLUDE}]
[{NOREPORT,REPORT}]
The EXAMINE command is used to test how closely a distribution is to a normal distribution. It also shows you outliers and extreme values.
The VARIABLES subcommand specifies the dependent variables and the independent variable to use as factors for the analysis. Variables listed before the first BY keyword are the dependent variables. The dependent variables may optionally be followed by a list of factors which tell PSPP how to break down the analysis for each dependent variable. The format for each factor is
var [BY var].
The STATISTICS subcommand specifies the analysis to be done. DESCRIPTIVES will produce a table showing some parametric and non-parametrics statistics. EXTREME produces a table showing extreme values of the dependent variable. A number in parentheses determines how many upper and lower extremes to show. The default number is 5.
The PLOT subcommand specifies which plots are to be produced if any.
The COMPARE subcommand is only relevant if producing boxplots, and it is only useful there is more than one dependent variable and at least one factor. If /COMPARE=GROUPS is specified, then one plot per dependent variable is produced, containing boxplots for all the factors. If /COMPARE=VARIABLES is specified, then one plot per factor is produced, each each containing one boxplot per dependent variable. If the /COMPARE subcommand is ommitted, then PSPP uses the default value of /COMPARE=GROUPS.
The CINTERVAL subcommand specifies the confidence interval to use in calculation of the descriptives command. The default it 95%.
The PERCENTILES subcommand specifies which percentiles are to be calculated, and which algorithm to use for calculating them. The default is to calculate the 5, 10, 25, 50, 75, 90, 95 percentiles using the HAVERAGE algorithm.
The TOTAL and NOTOTAL subcommands are mutually exclusive. If NOTOTAL is given and factors have been specified in the VARIABLES subcommand, then then statistics for the unfactored dependent variables are produced in addition to the factored variables. If there are no factors specified then TOTAL and NOTOTAL have no effect.
Warning! If many dependent variable are given, or factors are given for which there are many distinct values, then EXAMINE will produce a very large quantity of output.
CROSSTABS
/TABLES=var_list BY var_list [BY var_list]...
/MISSING={TABLE,INCLUDE,REPORT}
/WRITE={NONE,CELLS,ALL}
/FORMAT={TABLES,NOTABLES}
{LABELS,NOLABELS,NOVALLABS}
{PIVOT,NOPIVOT}
{AVALUE,DVALUE}
{NOINDEX,INDEX}
{BOX,NOBOX}
/CELLS={COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
ASRESIDUAL,ALL,NONE}
/STATISTICS={CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
KAPPA,ETA,CORR,ALL,NONE}
(Integer mode.)
/VARIABLES=var_list (low,high)...
The CROSSTABS procedure displays crosstabulation tables requested by the user. It can calculate several statistics for each cell in the crosstabulation tables. In addition, a number of statistics can be calculated for each table itself.
The TABLES subcommand is used to specify the tables to be reported. Any number of dimensions is permitted, and any number of variables per dimension is allowed. The TABLES subcommand may be repeated as many times as needed. This is the only required subcommand in general mode.
Occasionally, one may want to invoke a special mode called integer mode. Normally, in general mode, PSPP automatically determines what values occur in the data. In integer mode, the user specifies the range of values that the data assumes. To invoke this mode, specify the VARIABLES subcommand, giving a range of data values in parentheses for each variable to be used on the TABLES subcommand. Data values inside the range are truncated to the nearest integer, then assigned to that value. If values occur outside this range, they are discarded. When it is present, the VARIABLES subcommand must precede the TABLES subcommand.
In general mode, numeric and string variables may be specified on TABLES. Although long string variables are allowed, only their initial short-string parts are used. In integer mode, only numeric variables are allowed.
The MISSING subcommand determines the handling of user-missing values. When set to TABLE, the default, missing values are dropped on a table by table basis. When set to INCLUDE, user-missing values are included in tables and statistics. When set to REPORT, which is allowed only in integer mode, user-missing values are included in tables but marked with an ‘M’ (for “missing”) and excluded from statistical calculations.
Currently the WRITE subcommand is ignored.
The FORMAT subcommand controls the characteristics of the crosstabulation tables to be displayed. It has a number of possible settings:
The CELLS subcommand controls the contents of each cell in the displayed crosstabulation table. The possible settings are:
‘/CELLS’ without any settings specified requests COUNT, ROW, COLUMN, and TOTAL. If CELLS is not specified at all then only COUNT will be selected.
The STATISTICS subcommand selects statistics for computation:
Selected statistics are only calculated when appropriate for the statistic. Certain statistics require tables of a particular size, and some statistics are calculated only in integer mode.
‘/STATISTICS’ without any settings selects CHISQ. If the STATISTICS subcommand is not given, no statistics are calculated.
Please note: Currently the implementation of CROSSTABS has the followings bugs:
Fixes for any of these deficiencies would be welcomed.
NPAR TESTS
nonparametric test subcommands
.
.
.
[ /STATISTICS={DESCRIPTIVES} ]
[ /MISSING={ANALYSIS, LISTWISE} {INCLUDE, EXCLUDE} ]
NPAR TESTS performs nonparametric tests. Non parametric tests make very few assumptions about the distribution of the data. One or more tests may be specified by using the corresponding subcommand. If the /STATISTICS subcommand is also specified, then summary statistics are produces for each variable that is the subject of any test.
[ /BINOMIAL[(p)]=var_list[(value1[, value2)] ] ]
The binomial test compares the observed distribution of a dichotomous variable with that of a binomial distribution. The variable p specifies the test proportion of the binomial distribution. The default value of 0.5 is assumed if p is omitted.
If a single value appears after the variable list, then that value is used as the threshold to partition the observed values. Values less than or equal to the threshold value form the first category. Values greater than the threshold form the second category.
If two values appear after the variable list, then they will be used as the values which a variable must take to be in the respective category. Cases for which a variable takes a value equal to neither of the specified values, take no part in the test for that variable.
If no values appear, then the variable must assume dichotomous values. If more than two distinct, non-missing values for a variable under test are encountered then an error occurs.
If the test proportion is equal to 0.5, then a two tailed test is reported. For any other test proportion, a one tailed test is reported. For one tailed tests, if the test proportion is less than or equal to the observed proportion, then the significance of observing the observed proportion or more is reported. If the test proportion is more than the observed proportion, then the significance of observing the observed proportion or less is reported. That is to say, the test is always performed in the observed direction.
PSPP uses a very precise approximation to the gamma function to compute the binomial significance. Thus, exact results are reported even for very large sample sizes.
[ /CHISQUARE=var_list[(lo,hi)] [/EXPECTED={EQUAL|f1, f2 ... fn}] ]
The chisquare test produces a chi-square statistic for the differences between the expected and observed frequencies of the categories of a variable. Optionally, a range of values may appear after the variable list. If a range is given, then non integer values are truncated, and values outside the specified range are excluded from the analysis.
The /EXPECTED subcommand specifies the expected values of each category. There must be exactly one non-zero expected value, for each observed category, or the EQUAL keywork must be specified. You may use the notation n*f to specify n consecutive expected categories all taking a frequency of f. The frequencies given are proportions, not absolute frequencies. The sum of the frequencies need not be 1. If no /EXPECTED subcommand is given, then then equal frequencies are expected.
T-TEST
/MISSING={ANALYSIS,LISTWISE} {EXCLUDE,INCLUDE}
/CRITERIA=CIN(confidence)
(One Sample mode.)
TESTVAL=test_value
/VARIABLES=var_list
(Independent Samples mode.)
GROUPS=var(value1 [, value2])
/VARIABLES=var_list
(Paired Samples mode.)
PAIRS=var_list [WITH var_list [(PAIRED)] ]
The T-TEST procedure outputs tables used in testing hypotheses about means. It operates in one of three modes:
Each of these modes are described in more detail below. There are two optional subcommands which are common to all modes.
The /CRITERIA subcommand tells PSPP the confidence interval used in the tests. The default value is 0.95.
The MISSING subcommand determines the handling of missing variables. If INCLUDE is set, then user-missing values are included in the calculations, but system-missing values are not. If EXCLUDE is set, which is the default, user-missing values are excluded as well as system-missing values. This is the default.
If LISTWISE is set, then the entire case is excluded from analysis whenever any variable specified in the /VARIABLES, /PAIRS or /GROUPS subcommands contains a missing value. If ANALYSIS is set, then missing values are excluded only in the analysis for which they would be needed. This is the default.
The TESTVAL subcommand invokes the One Sample mode. This mode is used to test a population mean against a hypothesised mean. The value given to the TESTVAL subcommand is the value against which you wish to test. In this mode, you must also use the /VARIABLES subcommand to tell PSPP which variables you wish to test.
The GROUPS subcommand invokes Independent Samples mode or `Groups' mode. This mode is used to test whether two groups of values have the same population mean. In this mode, you must also use the /VARIABLES subcommand to tell PSPP the dependent variables you wish to test.
The variable given in the GROUPS subcommand is the independent variable which determines to which group the samples belong. The values in parentheses are the specific values of the independent variable for each group. If the parentheses are omitted and no values are given, the default values of 1.0 and 2.0 are assumed.
If the independent variable is numeric, it is acceptable to specify only one value inside the parentheses. If you do this, cases where the independent variable is greater than or equal to this value belong to the first group, and cases less than this value belong to the second group. When using this form of the GROUPS subcommand, missing values in the independent variable are excluded on a listwise basis, regardless of whether /MISSING=LISTWISE was specified.
The PAIRS subcommand introduces Paired Samples mode.
Use this mode when repeated measures have been taken from the same
samples.
If the WITH keyword is omitted, then tables for all
combinations of variables given in the PAIRS subcommand are
generated.
If the WITH keyword is given, and the (PAIRED) keyword
is also given, then the number of variables preceding WITH
must be the same as the number following it.
In this case, tables for each respective pair of variables are
generated.
In the event that the WITH keyword is given, but the
(PAIRED) keyword is omitted, then tables for each combination
of variable preceding WITH against variable following
WITH are generated.
ONEWAY
[/VARIABLES = ] var_list BY var
/MISSING={ANALYSIS,LISTWISE} {EXCLUDE,INCLUDE}
/CONTRAST= value1 [, value2] ... [,valueN]
/STATISTICS={DESCRIPTIVES,HOMOGENEITY}
The ONEWAY procedure performs a one-way analysis of variance of variables factored by a single independent variable. It is used to compare the means of a population divided into more than two groups.
The variables to be analysed should be given in the VARIABLES
subcommand.
The list of variables must be followed by the BY keyword and
the name of the independent (or factor) variable.
You can use the STATISTICS subcommand to tell PSPP to display
ancilliary information. The options accepted are:
The CONTRAST subcommand is used when you anticipate certain
differences between the groups.
The subcommand must be followed by a list of numerals which are the
coefficients of the groups to be tested.
The number of coefficients must correspond to the number of distinct
groups (or values of the independent variable).
If the total sum of the coefficients are not zero, then PSPP will
display a warning, but will proceed with the analysis.
The CONTRAST subcommand may be given up to 10 times in order
to specify different contrast tests.
RANK
[VARIABLES=] var_list [{A,D}] [BY var_list]
/TIES={MEAN,LOW,HIGH,CONDENSE}
/FRACTION={BLOM,TUKEY,VW,RANKIT}
/PRINT[={YES,NO}
/MISSING={EXCLUDE,INCLUDE}
/RANK [INTO var_list]
/NTILES(k) [INTO var_list]
/NORMAL [INTO var_list]
/PERCENT [INTO var_list]
/RFRACTION [INTO var_list]
/PROPORTION [INTO var_list]
/N [INTO var_list]
/SAVAGE [INTO var_list]
The RANK command ranks variables and stores the results into new variables.
The VARIABLES subcommand, which is mandatory, specifies one or more variables whose values are to be ranked. After each variable, ‘A’ or ‘D’ may appear, indicating that the variable is to be ranked in ascending or descending order. Ascending is the default. If a BY keyword appears, it should be followed by a list of variables which are to serve as group variables. In this case, the cases are gathered into groups, and ranks calculated for each group.
The TIES subcommand specifies how tied values are to be treated. The default is to take the mean value of all the tied cases.
The FRACTION subcommand specifies how proportional ranks are to be calculated. This only has any effect if NORMAL or PROPORTIONAL rank functions are requested.
The PRINT subcommand may be used to specify that a summary of the rank variables created should appear in the output.
The function subcommands are RANK, NTILES, NORMAL, PERCENT, RFRACTION, PROPORTION and SAVAGE. Any number of function subcommands may appear. If none are given, then the default is RANK. The NTILES subcommand must take an integer specifying the number of partitions into which values should be ranked. Each subcommand may be followed by the INTO keyword and a list of variables which are the variables to be created and receive the rank scores. There may be as many variables specified as there are variables named on the VARIABLES subcommand. If fewer are specified, then the variable names are automatically created.
The MISSING subcommand determines how user missing values are to be treated. A setting of EXCLUDE means that variables whose values are user-missing are to be excluded from the rank scores. A setting of INCLUDE means they are to be included. The default is EXCLUDE.
The REGRESSION procedure fits linear models to data via least-squares estimation. The procedure is appropriate for data which satisfy those assumptions typical in linear regression:
The REGRESSION procedure estimates the coefficients b_0,...,b_k and produces output relevant to inferences for the linear model.
REGRESSION
/VARIABLES=var_list
/DEPENDENT=var_list
/STATISTICS={ALL, DEFAULTS, R, COEFF, ANOVA, BCOV}
/SAVE={PRED, RESID}
The REGRESSION procedure reads the active file and outputs statistics relevant to the linear model specified by the user.
The VARIABLES subcommand, which is required, specifies the list of variables to be analyzed. Keyword VARIABLES is required. The DEPENDENT subcommand specifies the dependent variable of the linear model. The DEPENDENT subcommand is required. All variables listed in the VARIABLES subcommand, but not listed in the DEPENDENT subcommand, are treated as explanatory variables in the linear model.
All other subcommands are optional:
The STATISTICS subcommand specifies the statistics to be displayed:
ALLRCOEFFANOVABCOVThe SAVE subcommand causes PSPP to save the residuals or predicted values from the fitted model to the active file. PSPP will store the residuals in a variable called RES1 if no such variable exists, RES2 if RES1 already exists, RES3 if RES1 and RES2 already exist, etc. It will choose the name of the variable for the predicted values similarly, but with PRED as a prefix.
The following PSPP syntax will generate the default output and save the predicted values and residuals to the active file.
title 'Demonstrate REGRESSION procedure'.
data list / v0 1-2 (A) v1 v2 3-22 (10).
begin data.
b 7.735648 -23.97588
b 6.142625 -19.63854
a 7.651430 -25.26557
c 6.125125 -16.57090
a 8.245789 -25.80001
c 6.031540 -17.56743
a 9.832291 -28.35977
c 5.343832 -16.79548
a 8.838262 -29.25689
b 6.200189 -18.58219
end data.
list.
regression /variables=v0 v1 v2 /statistics defaults /dependent=v2
/save pred resid /method=enter.
Commands that don't fit any other category are placed here.
Most of these commands are not affected by commands like IF and LOOP: they take effect only once, unconditionally, at the time that they are encountered in the input.
ADD DOCUMENT
'line one' 'line two' ... 'last line' .
ADD DOCUMENT adds one or more lines of descriptive commentary to the active file. Documents added in this way are saved to system files. They can be viewed using SYSFILE INFO or DISPLAY DOCUMENTS. They can be removed from the active file with DROP DOCUMENTS.
Each line of documentary text must be enclosed in quotation marks, and may not be more than 80 bytes long. See DOCUMENT.
CD 'new directory' .
CD changes the current directory. The new directory will become that specified by the command.
Two possibles syntaxes:
COMMENT comment text ... .
*comment text ... .
COMMENT is ignored. It is used to provide information to the author and other readers of the PSPP syntax file.
COMMENT can extend over any number of lines. Don't forget to terminate it with a dot or a blank line.
DOCUMENT documentary_text.
DOCUMENT adds one or more lines of descriptive commentary to the active file. Documents added in this way are saved to system files. They can be viewed using SYSFILE INFO or DISPLAY DOCUMENTS. They can be removed from the active file with DROP DOCUMENTS.
Specify the documentary text following the DOCUMENT keyword. It is interpreted literally — any quotes or other punctuation marks will be included in the file. You can extend the documentary text over as many lines as necessary. Lines are truncated at 80 bytes. Don't forget to terminate the command with a dot or a blank line. See ADD DOCUMENT.
DISPLAY DOCUMENTS.
DISPLAY DOCUMENTS displays the documents in the active file. Each document is preceded by a line giving the time and date that it was added. See DOCUMENT.
DISPLAY FILE LABEL.
DISPLAY FILE LABEL displays the file label contained in the active file, if any. See FILE LABEL.
This command is a PSPP extension.
DROP DOCUMENTS.
DROP DOCUMENTS removes all documents from the active file. New documents can be added with DOCUMENT (see DOCUMENT).
DROP DOCUMENTS changes only the active file. It does not modify any system files stored on disk.
ECHO 'arbitrary text' .
Use ECHO to write arbitrary text to the output stream. The text should be enclosed in quotation marks following the normal rules for string tokens (see Tokens).
ERASE FILE file_name.
ERASE FILE deletes a file from the local filesystem. file_name must be quoted. This command cannot be used if the SAFER setting is active.
EXECUTE.
EXECUTE causes the active file to be read and all pending transformations to be executed.
FILE LABEL file_label.
FILE LABEL provides a title for the active file. This title will be saved into system files and portable files that are created during this PSPP run.
file_label need not be quoted. If quotes are included, they become part of the file label.
FINISH.
FINISH terminates the current PSPP session and returns control to the operating system.
HOST.
HOST suspends the current PSPP session and temporarily returns control to the operating system. This command cannot be used if the SAFER setting is active.
INCLUDE [FILE=]'file-name'.
INCLUDE causes the PSPP command processor to read an additional command file as if it were included bodily in the current command file. If errors are encountered in the included file, then command processing will stop and no more commands will be processed. Include files may be nested to any depth, up to the limit of available memory.
The INSERT command (see INSERT) may be used instead of INCLUDE if you require more flexible options. The syntax
INCLUDE FILE=file-name.
functions identically to
INSERT FILE=file-name ERROR=STOP CD=NO SYNTAX=BATCH.
INSERT [FILE=]'file-name'
[CD={NO,YES}]
[ERROR={CONTINUE,STOP}]
[SYNTAX={BATCH,INTERACTIVE}].
INSERT is similar to INCLUDE (see INCLUDE) but somewhat more flexible. It causes the command processor to read a file as if it were embedded in the current command file.
If ‘CD=YES’ is specified, then before including the file, the current directory will be changed to the directory of the included file. The default setting is ‘CD=NO’. Note that this directory will remain current until it is changed explicitly (with the CD command, or a subsequent INSERT command with the ‘CD=YES’ option). It will not revert to its original setting even after the included file is finished processing.
If ‘ERROR=STOP’ is specified, errors encountered in the inserted file will cause processing to immediately cease. Otherwise processing will continue at the next command. The default setting is ‘ERROR=CONTINUE’.
If ‘SYNTAX=INTERACTIVE’ is specified then the syntax contained in the included file must conform to interactive syntax conventions. See Syntax Variants. The default setting is ‘SYNTAX=BATCH’.
PERMISSIONS
FILE='file-name'
/PERMISSIONS = {READONLY,WRITEABLE}.
PERMISSIONS changes the permissions of a file. There is one mandatory subcommand which specifies the permissions to which the file should be changed. If you set a file's permission to READONLY, then the file will become unwritable either by you or anyone else on the system. If you set the permission to WRITEABLE, then the file will become writeable by you; the permissions afforded to others will be unchanged. This command cannot be used if the SAFER setting is active.
SET
(data input)
/BLANKS={SYSMIS,'.',number}
/DECIMAL={DOT,COMMA}
/FORMAT=fmt_spec
/EPOCH={AUTOMATIC,year}
/RIB={NATIVE,MSBFIRST,LSBFIRST,VAX}
/RRB={NATIVE,ISL,ISB,IDL,IDB,VF,VD,VG,ZS,ZL}
(program input)
/ENDCMD='.'
/NULLINE={ON,OFF}
(interaction)
/CPROMPT='cprompt_string'
/DPROMPT='dprompt_string'
/ERRORBREAK={OFF,ON}
/MXERRS=max_errs
/MXWARNS=max_warnings
/PROMPT='prompt'
/WORKSPACE=workspace_size
(program execution)
/MEXPAND={ON,OFF}
/MITERATE=max_iterations
/MNEST=max_nest
/MPRINT={ON,OFF}
/MXLOOPS=max_loops
/SEED={RANDOM,seed_value}
/UNDEFINED={WARN,NOWARN}
(data output)
/CC{A,B,C,D,E}={'npre,pre,suf,nsuf','npre.pre.suf.nsuf'}
/DECIMAL={DOT,COMMA}
/FORMAT=fmt_spec
/WIB={NATIVE,MSBFIRST,LSBFIRST,VAX}
/WRB={NATIVE,ISL,ISB,IDL,IDB,VF,VD,VG,ZS,ZL}
(output routing)
/ECHO={ON,OFF}
/ERRORS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
/INCLUDE={ON,OFF}
/MESSAGES={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
/PRINTBACK={ON,OFF}
/RESULTS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
(output driver options)
/HEADERS={NO,YES,BLANK}
/LENGTH={NONE,length_in_lines}
/LISTING={ON,OFF,'file-name'}
/MORE={ON,OFF}
/WIDTH={NARROW,WIDTH,n_characters}
(logging)
/JOURNAL={ON,OFF} ['file-name']
(system files)
/COMPRESSION={ON,OFF}
/SCOMPRESSION={ON,OFF}
(security)
/SAFER=ON
(obsolete settings accepted for compatibility, but ignored)
/BOXSTRING={'xxx','xxxxxxxxxxx'}
/CASE={UPPER,UPLOW}
/CPI=cpi_value
/DISK={ON,OFF}
/HIGHRES={ON,OFF}
/HISTOGRAM='c'
/LOWRES={AUTO,ON,OFF}
/LPI=lpi_value
/MENUS={STANDARD,EXTENDED}
/MXMEMORY=max_memory
/SCRIPTTAB='c'
/TB1={'xxx','xxxxxxxxxxx'}
/TBFONTS='string'
/XSORT={YES,NO}
SET allows the user to adjust several parameters relating to PSPP's execution. Since there are many subcommands to this command, its subcommands will be examined in groups.
On subcommands that take boolean values, ON and YES are synonym, and as are OFF and NO, when used as subcommand values.
The data input subcommands affect the way that data is read from data files. The data input subcommands are
Z architecture also supports IEEE 754 floating point. The ZS and ZL formats are only for use with very old input files.
Program input subcommands affect the way that programs are parsed when they are typed interactively or run from a command file. They are
Interaction subcommands affect the way that PSPP interacts with an online user. The interaction subcommands are
Program execution subcommands control the way that PSPP commands execute. The program execution subcommands are
Data output subcommands affect the format of output data. These subcommands are
Output routing subcommands affect where the output of transformations and procedures is sent. These subcommands are
Output driver option subcommands affect output drivers' settings. These subcommands are
Logging subcommands affect logging of commands executed to external files. These subcommands are
The journal is named pspp.jnl by default. A different name may be specified.
System file subcommands affect the default format of system files produced by PSPP. These subcommands are
Security subcommands affect the operations that commands are allowed to perform. The security subcommands are
Be aware that this setting does not guarantee safety (commands can still overwrite files, for instance) but it is an improvement. When set, this setting cannot be reset during the same session, for obvious security reasons.
SHOW
[ALL]
[BLANKS]
[CC]
[CCA]
[CCB]
[CCC]
[CCD]
[CCE]
[COPYING]
[DECIMALS]
[ENDCMD]
[FORMAT]
[LENGTH]
[MXERRS]
[MXLOOPS]
[MXWARNS]
[SCOMPRESSION]
[UNDEFINED]
[WARRANTY]
[WEIGHT]
[WIDTH]
SHOW can be used to display the current state of PSPP's execution
parameters. Parameters that can be changed using SET
(see SET), can be examined using SHOW using the subcommand
with the same name. SHOW supports the following additional
subcommands:
ALLCCWARRANTYCOPYINGSpecifying SHOW without any subcommands is equivalent to SHOW ALL.
SUBTITLE 'subtitle_string'.
or
SUBTITLE subtitle_string.
SUBTITLE provides a subtitle to a particular PSPP run. This subtitle appears at the top of each output page below the title, if headers are enabled on the output device.
Specify a subtitle as a string in quotes. The alternate syntax that did not require quotes is now obsolete. If it is used then the subtitle is converted to all uppercase.
TITLE 'title_string'.
or
TITLE title_string.
TITLE provides a title to a particular PSPP run. This title appears at the top of each output page, if headers are enabled on the output device.
Specify a title as a string in quotes. The alternate syntax that did not require quotes is now obsolete. If it is used then the title is converted to all uppercase.
This chapter lists parts of the PSPP language that are not yet implemented.
PSPP does have bugs. We do our best to fix them, but our limited resources mean that some may remain for a long time. Our best alternative is to make you aware of PSPP's known bugs. To see a list, visit PSPP's project webpage at https://savannah.gnu.org/projects/pspp. You can also submit your own bug report there: click on “Bugs,” then on “Submit a Bug,” and fill out the form. Alternatively, PSPP bug reports may be sent by email to
For known bugs in individual language features, see the documentation for that feature.
(: Miscellaneous FunctionsABS: Miscellaneous MathematicsACOS: TrigonometryANY: Set MembershipARCOS: TrigonometryARSIN: TrigonometryARTAN: TrigonometryASIN: TrigonometryATAN: TrigonometryCDF.BERNOULLI: Discrete DistributionsCDF.BETA: Continuous DistributionsCDF.BINOMIAL: Discrete DistributionsCDF.CAUCHY: Continuous DistributionsCDF.CHISQ: Continuous DistributionsCDF.EXP: Continuous DistributionsCDF.F: Continuous DistributionsCDF.GAMMA: Continuous DistributionsCDF.GEOM: Discrete DistributionsCDF.HALFNRM: Continuous DistributionsCDF.HYPER: Discrete DistributionsCDF.IGAUSS: Continuous DistributionsCDF.LAPLACE: Continuous DistributionsCDF.LNORMAL: Continuous DistributionsCDF.LOGISTIC: Continuous DistributionsCDF.NEGBIN: Discrete DistributionsCDF.NORMAL: Continuous DistributionsCDF.PARETO: Continuous DistributionsCDF.POISSON: Discrete DistributionsCDF.RAYLEIGH: Continuous DistributionsCDF.SMOD: Continuous DistributionsCDF.SRANGE: Continuous DistributionsCDF.T: Continuous DistributionsCDF.T1G: Continuous DistributionsCDF.T2G: Continuous DistributionsCDF.UNIFORM: Continuous DistributionsCDF.VBNOR: Continuous DistributionsCDF.WEIBULL: Continuous DistributionsCDFNORM: Continuous DistributionsCFVAR: Statistical FunctionsCONCAT: String FunctionsCOS: TrigonometryCTIME.DAYS: Time ExtractionCTIME.HOURS: Time ExtractionCTIME.MINUTES: Time ExtractionCTIME.SECONDS: Time ExtractionDATE.DMY: Date ConstructionDATE.MDY: Date ConstructionDATE.MOYR: Date ConstructionDATE.QYR: Date ConstructionDATE.WKYR: Date ConstructionDATE.YRDAY: Date ConstructionDATEDIFF: Time & Date ArithmeticDATESUM: Time & Date ArithmeticEXP: MathematicsIDF.BETA: Continuous DistributionsIDF.CAUCHY: Continuous DistributionsIDF.CHISQ: Continuous DistributionsIDF.EXP: Continuous DistributionsIDF.F: Continuous DistributionsIDF.GAMMA: Continuous DistributionsIDF.HALFNRM: Continuous DistributionsIDF.IGAUSS: Continuous DistributionsIDF.LAPLACE: Continuous DistributionsIDF.LNORMAL: Continuous DistributionsIDF.LOGISTIC: Continuous DistributionsIDF.NORMAL: Continuous DistributionsIDF.PARETO: Continuous DistributionsIDF.RAYLEIGH: Continuous DistributionsIDF.SMOD: Continuous DistributionsIDF.SRANGE: Continuous DistributionsIDF.T: Continuous DistributionsIDF.T1G: Continuous DistributionsIDF.T2G: Continuous DistributionsIDF.UNIFORM: Continuous DistributionsIDF.WEIBULL: Continuous DistributionsINDEX: String FunctionsLAG: Miscellaneous FunctionsLENGTH: String FunctionsLG10: MathematicsLN: MathematicsLNGAMMA: MathematicsLOWER: String FunctionsLPAD: String FunctionsLTRIM: String FunctionsMAX: Statistical FunctionsMEAN: Statistical FunctionsMIN: Statistical FunctionsMISSING: Missing Value FunctionsMOD: Miscellaneous MathematicsMOD10: Miscellaneous MathematicsNCDF.BETA: Continuous DistributionsNCDF.CHISQ: Continuous DistributionsNCDF.F: Continuous DistributionsNCDF.T: Continuous DistributionsNMISS: Missing Value FunctionsNORMAL: Continuous DistributionsNPDF.BETA: Continuous DistributionsNPDF.CHISQ: Continuous DistributionsNPDF.F: Continuous DistributionsNPDF.T: Continuous DistributionsNUMBER: String FunctionsNVALID: Missing Value FunctionsPDF.BERNOULLI: Discrete DistributionsPDF.BETA: Continuous DistributionsPDF.BINOMIAL: Discrete DistributionsPDF.BVNOR: Continuous DistributionsPDF.CAUCHY: Continuous DistributionsPDF.CHISQ: Continuous DistributionsPDF.EXP: Continuous DistributionsPDF.F: Continuous DistributionsPDF.GAMMA: Continuous DistributionsPDF.GEOM: Discrete DistributionsPDF.HALFNRM: Continuous DistributionsPDF.HYPER: Discrete DistributionsPDF.IGAUSS: Continuous DistributionsPDF.LANDAU: Continuous DistributionsPDF.LAPLACE: Continuous DistributionsPDF.LNORMAL: Continuous DistributionsPDF.LOG: Discrete DistributionsPDF.LOGISTIC: Continuous DistributionsPDF.NEGBIN: Discrete DistributionsPDF.NORMAL: Continuous DistributionsPDF.NTAIL: Continuous DistributionsPDF.PARETO: Continuous DistributionsPDF.POISSON: Discrete DistributionsPDF.RAYLEIGH: Continuous DistributionsPDF.RTAIL: Continuous DistributionsPDF.T: Continuous DistributionsPDF.T1G: Continuous DistributionsPDF.T2G: Continuous DistributionsPDF.UNIFORM: Continuous DistributionsPDF.WEIBULL: Continuous DistributionsPDF.XPOWER: Continuous DistributionsPROBIT: Continuous DistributionsRANGE: Set MembershipRINDEX: String FunctionsRND: Miscellaneous MathematicsRPAD: String FunctionsRTRIM: String FunctionsRV.BERNOULLI: Discrete DistributionsRV.BETA: Continuous DistributionsRV.BINOMIAL: Discrete DistributionsRV.CAUCHY: Continuous DistributionsRV.CHISQ: Continuous DistributionsRV.EXP: Continuous DistributionsRV.F: Continuous DistributionsRV.GAMMA: Continuous DistributionsRV.GEOM: Discrete DistributionsRV.HALFNRM: Continuous DistributionsRV.HYPER: Discrete DistributionsRV.IGAUSS: Continuous DistributionsRV.LANDAU: Continuous DistributionsRV.LAPLACE: Continuous DistributionsRV.LEVY: Continuous DistributionsRV.LNORMAL: Continuous DistributionsRV.LOG: Discrete DistributionsRV.LOGISTIC: Continuous DistributionsRV.LVSKEW: Continuous DistributionsRV.NEGBIN: Discrete DistributionsRV.NORMAL: Continuous DistributionsRV.NTAIL: Continuous DistributionsRV.PARETO: Continuous DistributionsRV.POISSON: Discrete DistributionsRV.RAYLEIGH: Continuous DistributionsRV.RTAIL: Continuous DistributionsRV.T: Continuous DistributionsRV.UNIFORM: Continuous DistributionsRV.WEIBULL: Continuous DistributionsRV.XPOWER: Continuous DistributionsSD: Statistical FunctionsSIG.CHISQ: Continuous DistributionsSIG.F: Continuous DistributionsSIN: TrigonometrySQRT: MathematicsSTRING: String FunctionsSUBSTR: String FunctionsSUM: Statistical FunctionsSYSMIS: Missing Value FunctionsTAN: TrigonometryTIME.DAYS: Time ConstructionTIME.HMS: Time ConstructionTRUNC: Miscellaneous MathematicsUNIFORM: Continuous DistributionsUPCASE: String FunctionsVALUE: Missing Value FunctionsVARIANCE: Statistical FunctionsXDATE.DATE: Date ExtractionXDATE.HOUR: Date ExtractionXDATE.JDAY: Date ExtractionXDATE.MDAY: Date ExtractionXDATE.MINUTE: Date ExtractionXDATE.MONTH: Date ExtractionXDATE.QUARTER: Date ExtractionXDATE.SECOND: Date ExtractionXDATE.TDAY: Date ExtractionXDATE.TIME: Date ExtractionXDATE.WEEK: Date ExtractionXDATE.WKDAY: Date ExtractionXDATE.YEAR: Date ExtractionYRMODA: Miscellaneous Functions*: COMMENTADD DOCUMENT: ADD DOCUMENTADD VALUE LABELS: ADD VALUE LABELSAGGREGATE: AGGREGATEAPPLY DICTIONARY: APPLY DICTIONARYAUTORECODE: AUTORECODEBEGIN DATA: BEGIN DATABINOMIAL: BINOMIALBREAK: BREAKCD: CDCHISQUARE: CHISQUARECOMMENT: COMMENTCOMPUTE: COMPUTECOUNT: COUNTCROSSTABS: CROSSTABSDATA LIST: DATA LISTDATA LIST FIXED: DATA LIST FIXEDDATA LIST FREE: DATA LIST FREEDATA LIST LIST: DATA LIST LISTDELETE VARIABLES: DELETE VARIABLESDESCRIPTIVES: DESCRIPTIVESDISPLAY: DISPLAYDISPLAY DOCUMENTS: DISPLAY DOCUMENTSDISPLAY FILE LABEL: DISPLAY FILE LABELDISPLAY VECTORS: DISPLAY VECTORSDO IF: DO IFDO REPEAT: DO REPEATDOCUMENT: DOCUMENTDROP DOCUMENTS: DROP DOCUMENTSECHO: ECHOEND CASE: END CASEEND DATA: BEGIN DATAEND FILE: END FILEERASE: ERASEEXAMINE: EXAMINEEXECUTE: EXECUTEEXPORT: EXPORTFILE HANDLE: FILE HANDLEFILE LABEL: FILE LABELFILTER: FILTERFINISH: FINISHFLIP: FLIPFORMATS: FORMATSFREQUENCIES: FREQUENCIESGET: GETGET DATA: GET DATAHOST: HOSTIF: IFIMPORT: IMPORTINCLUDE: INCLUDEINPUT PROGRAM: INPUT PROGRAMINSERT: INSERTLEAVE: LEAVELIST: LISTLOOP: LOOPMATCH FILES: MATCH FILESMISSING VALUES: MISSING VALUESMODIFY VARS: MODIFY VARSN OF CASES: N OF CASESNEW FILE: NEW FILENPAR TESTS: NPAR TESTSNUMERIC: NUMERICONEWAY: ONEWAYPERMISSIONS: PERMISSIONSPRINT: PRINTPRINT EJECT: PRINT EJECTPRINT FORMATS: PRINT FORMATSPRINT SPACE: PRINT SPACERANK: RANKRECODE: RECODEREGRESSION: SyntaxRENAME VARIABLES: RENAME VARIABLESREPEATING DATA: REPEATING DATAREREAD: REREADSAMPLE: SAMPLESAVE: SAVESELECT IF: SELECT IFSET: SETSHOW: SHOWSORT CASES: SORT CASESSPLIT FILE: SPLIT FILESTRING: STRINGSUBTITLE: SUBTITLESYSFILE INFO: SYSFILE INFOT-TEST: T-TESTTEMPORARY: TEMPORARYTITLE: TITLEVALUE LABELS: VALUE LABELSVARIABLE ALIGNMENT: VARIABLE ALIGNMENTVARIABLE LABELS: VARIABLE LABELSVARIABLE LEVEL: VARIABLE LEVELVARIABLE WIDTH: VARIABLE WIDTHVECTOR: VECTORWEIGHT: WEIGHTWRITE: WRITEWRITE FORMATS: WRITE FORMATSXEXPORT: XEXPORTXSAVE: XSAVE$CASENUM: System Variables$DATE: System Variables$JDATE: System Variables$LENGTH: System Variables$SYSMIS: System Variables$TIME: System Variables$WIDTH: System Variables(: Functions): Functions.: BNF<: Relational Operators<=: Relational Operators<>: Relational Operators>=: Relational OperatorsAND: Logical OperatorsTO: Sets of VariablesEQ: Relational Operatorsexpression: BNFGE: Relational OperatorsGT: Relational Operatorsinteger: BNFLE: Relational OperatorsLT: Relational OperatorsNE: Relational OperatorsNOT: Logical Operatorsnumber: BNFOR: Logical Operatorsstring: BNFTO convention: Sets of Variablesvar-list: BNFvar-name: BNF~=: Relational OperatorsThis chapter describe how to configure PSPP for your system.
PSPP searches each directory in the configuration file path for most configuration files. The default configuration file path searches first $HOME/.pspp, then the package system configuration directory (usually /usr/local/etc/pspp or /etc/pspp). The value of environment variable PSPP_CONFIG_PATH, if defined, overrides this default path. Finally, ‘-B path’ or ‘--config-dir=path’ specified on the command line has highest priority.
There are many ways that PSPP can be configured. These are described in the list below. Values given by earlier items take precedence over those given by later items.
Some of the above may not apply to a particular setting.
Most configuration files have a common form:
(This is distinct from the use of a backslash as a line-splicing character.)
You may think the concept of environment variables is a fairly simple one. However, the author of PSPP has found a way to complicate even something so simple. Environment variables are further described in the sections below:
Much of the power of environment variables lies in the way that they may be substituted into configuration files. Variable substitutions are described below.
The line is scanned from left to right. In this scan, all characters other than dollar signs (‘$’) are retained without change. Dollar signs introduce environment variable references. References take three forms:
$var${var}$$Undefined variables expand to a empty value.
There are two environment variables predefined for use in environment substitutions:
Nothing prevents these values from being overridden, although it's a good idea not to do so.
Configuring output devices is the most complicated aspect of configuring PSPP. The output device configuration file is named devices. It is searched for using the usual algorithm for finding configuration files (see File locations). Each line in the file is read in the usual manner for configuration files (see Configuration files).
Lines in devices are divided into three categories, described briefly in the table below:
The following sections further elaborate the contents of the devices file.
Drivers can be divided into categories. Drivers are specified by their names, or by the names of the categories that they are contained in. Only certain drivers are enabled each time PSPP is run; by default, these are the drivers in the category `default'. To enable a different set of drivers, use the ‘-o device’ command-line option (see Invocation).
Categories are specified with a line of the form ‘category=driver1 driver2 driver3 ... drivern’. This line specifies that the category category is composed of drivers named driver1, driver2, and so on. There may be any number of drivers in the category, from zero on up.
Categories may also be specified on the command line (see Invocation).
This is all you need to know about categories. If you're still curious, read on.
First of all, the term `categories' is a bit of a misnomer. In fact, the internal representation is nothing like the hierarchy that the term seems to imply: a linear list is used to keep track of the enabled drivers.
When PSPP first begins reading devices, this list contains the name of any drivers or categories specified on the command line, or the single item `default' if none were specified.
Each time a category definition is specified, the list is searched for an item with the value of category. If a matching item is found, it is deleted. If there was a match, the list of drivers (driver1 through drivern) is then appended to the list.
Each time a driver definition line is encountered, the list is searched. If the list contains an item with that driver's name, the driver is enabled and the item is deleted from the list. Otherwise, the driver is not enabled.
It is an error if the list is not empty when the end of devices is reached.
Macro definitions take the form ‘define macroname definition’. In such a macro definition, the environment variable macroname is defined to expand to the value definition. Before the definition is made, however, any macros used in definition are expanded.
Please note the following nuances of macro usage:
Driver definitions are the ultimate purpose of the devices configuration file. These are where the real action is. Driver definitions tell PSPP where it should send its output.
Each driver definition line is divided into four fields. These fields are delimited by colons (‘:’). Each line is subjected to environment variable interpolation before it is processed further (see Environment substitutions). From left to right, the four fields are, in brief:
screenprinterlistingThese options are just hints to PSPP and do not cause the output to be
directed to the screen, or to the printer, or to a listing file—those
must be set elsewhere in the options. They are used primarily to decide
which devices should be enabled at any given time. See SET, for more
information.
The driver is enabled if:
default.
For more information on driver names, see Driver categories.
The class name must be one of those supported by PSPP. The classes supported depend on the options with which PSPP was compiled. See later sections in this chapter for descriptions of the available driver classes.
Options are dependent on the driver. See the driver descriptions for details.
Quite often in configuration it is necessary to specify a length or a size. PSPP uses a common syntax for all such, calling them collectively by the name dimensions.
inin = 2.54 cm)
"in = 2.54 cm)
ptin = 72.27 pt)
pcpt = 1 pc)
bpin = 72 bp)
cmmmmm = 1 cm)
dddd = 1238 pt)
cccc = 12 dd)
spsp = 1 pt)
The lines in devices are distinguished in the following manner:
define,
followed by one or more white space characters, the line is processed as
a macro definition.
Each driver definition line is run through a simple tokenizer. This tokenizer recognizes two basic types of tokens.
The first type is an equals sign (‘=’). Equals signs are both delimiters between tokens and tokens in themselves.
The second type is an identifier or string token. Identifiers and strings are equivalent after tokenization, though they are written differently. An identifier is any string of characters other than white space or equals sign.
A string is introduced by a single- or double-quote character (‘'’ or ‘"’) and, in general, continues until the next occurrence of that same character. The following standard C escapes can also be embedded within strings:
\'\"\?\\\a\b\f\n\r\t\v\ooo\xhhTokens, outside of quoted strings, are delimited by white space or equals signs.
The postscript driver class is used to produce output that is
acceptable to PostScript printers and other interpreters.
The available options are listed below.
output-file=file-name"pspp.ps"), a pipe (i.e., "|lpr"), or
stdout ("-"). Default: "pspp.ps".
headers=booleanon.
paper-size=paper-sizea4, letter)
or measurements (e.g. 210x297, 8.5x11in).
The default paper size is taken from the PAPERSIZE environment
variable or the file indicated by the PAPERCONF environment
variable, if either variable is set. If not, and your system supports
the LC_PAPER locale category, then the default paper size is
taken from the locale. Otherwise, if /etc/papersize exists,
the default paper size is read from it. As a last resort, A4 paper is
assumed.
orientation=orientationportrait or landscape. Default: portrait.
left-margin=dimensionright-margin=dimensiontop-margin=dimensionbottom-margin=dimension0.5in.
prop-font=afm-file[,font-file[,encoding-file]]emph-font=afm-file[,font-file[,encoding-file]]fixed-font=afm-file[,font-file[,encoding-file]]If specified, font-file will be downloaded to the printer at the beginning of the print job. The font file may be in PFA or PFB format.
The font is reencoded as specified in encoding-file, if specified. Each line in encoding-file should consist of a PostScript character name and a decimal encoding value (between 0 and 255), separated by white space. Blank lines and comments introduced by ‘#’ are also allowed.
The files specified on these options are located as follows. If
the file name begins with ‘/’, then it is taken as an absolute
path. Otherwise, PSPP searches its configuration path for the specified
name prefixed by psfonts/ (see File locations).
Default: proportional font Times-Roman.afm, emphasis font
Times-Italic.afm, fixed-pitch font Courier.afm.
font-size=font-sizeline-gutter=dimension1pt.
line-spacing=dimension1pt.
line-width=dimension0.5pt.
The ASCII driver class produces output that can be displayed on a terminal or output to printers. The ASCII driver has class name ‘ascii’.
The available options are listed below.
output-file=file-name"pspp.txt"), a pipe (e.g., "|more"), or
stdout ("-"). Default: "pspp.list".
chart-files=file-name-templatechart-type=type.You may specify ‘none’ to disable chart output. Charts are also
disabled if your installation of PSPP was compiled without
libplot.
paginate=booleanon.
tab-width=tab-width-value8.
headers=booleanon.
length=line-countauto to track the height of the
terminal as it changes. Default: 66.
width=character-countauto to track the width of the terminal
as it changes. Default: 79.
top-margin=top-margin-lines2.
bottom-margin=bottom-margin-lines2.
box[line-type]=box-charsline-type must be a 4-digit number. The digits are in the order `right', `bottom', `left', `top'. The possibilities for each digit are:
Examples:
box[0101]="|"box[2222]="#"box[1100]="\xda"Defaults:
box[0000]=" "
box[1000]="-"
box[0010]="-"
box[1010]="-"
box[0100]="|"
box[0001]="|"
box[0101]="|"
box[2000]="="
box[0020]="="
box[2020]="="
box[3000]="="
box[0030]="="
box[3030]="="
init=init-stringemphasis=emphasis-stylebold, underline,
or none. Bold and underline emphasis are achieved with
overstriking, which may not be supported by all the software to which
you might pass the output.
The html driver class is used to produce output for viewing in
tables-capable web browsers such as Emacs' w3-mode. Its configuration
is very simple. Currently, the output has a very plain format. In the
future, further work may be done on improving the output appearance.
There are only a few options:
output-file=file-name"pspp.ps"), a pipe (i.e., "|lpr"), or
stdout ("-"). Default: "pspp.html".
chart-files=file-name-templateThe following environment variables can be used to further configure PSPP:
HOMESTAT_INCLUDE_PATHTERMtermcap or ncurses will use, if such
support was compiled into PSPP.
STAT_OUTPUT_INIT_FILEdevices.
STAT_OUTPUT_INIT_PATHTMPDIRTEMPTMP Copyright © 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ascii without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.
A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.
To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (C) year your name.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with...Texts.” line with this:
with the Invariant Sections being list their titles, with
the Front-Cover Texts being list, and with the Back-Cover Texts
being list.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.