(ESTADISTICA) Pspp-Users-Guide
(ESTADISTICA) Pspp-Users-Guide
(ESTADISTICA) Pspp-Users-Guide
Table of Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Invoking pspp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.1 Main Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2 PDF, PostScript, SVG, and PNG Output Options . . . . . . . . . . . . . . 6
3.3 Plain Text Output Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4 SPV Output Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 TeX Output Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.6 HTML Output Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.7 OpenDocument Output Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.8 Comma-Separated Value Output Options . . . . . . . . . . . . . . . . . . . . . . . 9
4 Invoking psppire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1 The graphic user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Using pspp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.1 Preparation of Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.1.1 Defining Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2 Listing the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.3 Reading data from a text file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1.4 Reading data from a pre-prepared pspp file . . . . . . . . . . . . . . . 14
5.1.5 Saving data to a pspp file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.6 Reading data from other sources . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.7 Exiting PSPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Data Screening and Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.1 Identifying incorrect data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.2 Dealing with suspicious data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2.3 Inverting negatively coded variables . . . . . . . . . . . . . . . . . . . . . . . 17
5.2.4 Testing data consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2.5 Testing for normality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 Hypothesis Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.3.1 Testing for differences of means . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.3.2 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7 Mathematical Expressions . . . . . . . . . . . . . . . . . . . . . 44
7.1 Boolean Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7.2 Missing Values in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7.3 Grouping Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7.4 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7.5 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.6 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.7 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.7.1 Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.7.2 Miscellaneous Mathematical Functions . . . . . . . . . . . . . . . . . . . . 46
7.7.3 Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.7.4 Missing-Value Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.7.5 Set-Membership Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.7.6 Statistical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.7.7 String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
7.7.8 Time & Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.7.8.1 How times & dates are defined and represented . . . . . . . 51
7.7.8.2 Functions that Produce Times . . . . . . . . . . . . . . . . . . . . . . . 51
7.7.8.3 Functions that Examine Times . . . . . . . . . . . . . . . . . . . . . . . 51
7.7.8.4 Functions that Produce Dates . . . . . . . . . . . . . . . . . . . . . . . . 52
7.7.8.5 Functions that Examine Dates . . . . . . . . . . . . . . . . . . . . . . . 53
7.7.8.6 Time and Date Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.7.9 Miscellaneous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.7.10 Statistical Distribution Functions . . . . . . . . . . . . . . . . . . . . . . . . 55
7.7.10.1 Continuous Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.7.10.2 Discrete Distributions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.8 Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
iii
11 Manipulating Variables . . . . . . . . . . . . . . . . . . . . . . . 98
11.1 DISPLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
11.2 NUMERIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.3 STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.4 RENAME VARIABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.5 SORT VARIABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
11.6 DELETE VARIABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.7 VARIABLE LABELS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.8 PRINT FORMATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.9 WRITE FORMATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.10 FORMATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.11 VALUE LABELS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.12 ADD VALUE LABELS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.13 MISSING VALUES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.14 VARIABLE ATTRIBUTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.15 VARIABLE ALIGNMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
11.16 VARIABLE WIDTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
11.17 VARIABLE LEVEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.18 VARIABLE ROLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.19 VECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.20 MRSETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.21 LEAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
15 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
15.1 DESCRIPTIVES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
15.1.1 Descriptives Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
15.2 FREQUENCIES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
15.2.1 Frequencies Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
15.3 EXAMINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
15.4 GRAPH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.1 Scatterplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.2 Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
vi
16 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
16.1 Matrix Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
16.2 MATRIX DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
16.2.1 With ROWTYPE_ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
16.2.2 Without ROWTYPE_ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
16.2.2.1 Factor variables without ROWTYPE_ . . . . . . . . . . . . . . . . . 231
16.3 MCONVERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
16.4 MATRIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
16.4.1 Matrix Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
16.4.1.1 Matrix Construction Operator {} . . . . . . . . . . . . . . . . . . 235
16.4.1.2 Integer Sequence Operator ‘:’ . . . . . . . . . . . . . . . . . . . . . . 236
16.4.1.3 Index Operator () . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
16.4.1.4 Unary Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
16.4.1.5 Elementwise Binary Operators . . . . . . . . . . . . . . . . . . . . . 237
16.4.1.6 Matrix Multiplication Operator ‘*’ . . . . . . . . . . . . . . . . . 238
16.4.1.7 Matrix Exponentiation Operator ** . . . . . . . . . . . . . . . . 238
16.4.2 Matrix Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
16.4.2.1 Elementwise Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
16.4.2.2 Logical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
16.4.2.3 Matrix Construction Functions . . . . . . . . . . . . . . . . . . . . 241
16.4.2.4 Minimum, Maximum, and Sum Functions . . . . . . . . . . 243
16.4.2.5 Matrix Property Functions. . . . . . . . . . . . . . . . . . . . . . . . . 244
16.4.2.6 Matrix Rank Ordering Functions. . . . . . . . . . . . . . . . . . . 244
16.4.2.7 Matrix Algebra Functions. . . . . . . . . . . . . . . . . . . . . . . . . . 244
viii
17 Utilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
17.1 ADD DOCUMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
17.2 CACHE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
17.3 CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
17.4 COMMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
17.5 DOCUMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.6 DISPLAY DOCUMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.7 DISPLAY FILE LABEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.8 DROP DOCUMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.9 ECHO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.10 ERASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
17.11 EXECUTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
17.12 FILE LABEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
17.13 FINISH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
17.14 HOST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
17.15 INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
17.16 INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
17.17 OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
17.18 PERMISSIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
17.19 PRESERVE and RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
17.20 SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
17.21 SHOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
17.22 SUBTITLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
17.23 TITLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
22 Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
22.1 How to report bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
1 Introduction
pspp is a tool for statistical analysis of sampled data. It reads the data, analyzes the data
according to commands provided, and writes the results to a listing file, to the standard
output or to a window of the graphical display.
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 tables and charts as output, which it can produce in several formats;
currently, ASCII, PostScript, PDF, HTML, DocBook and TEX are supported.
The current version of pspp, 2.0.0-pre1, is incomplete in terms of its statistical procedure
support. pspp is a work in progress. The authors hope to fully support all features in
the products that pspp replaces, eventually. The authors welcome questions, comments,
donations, and code submissions. See Chapter 22 [Submitting Bug Reports], page 288, for
instructions on contacting the authors.
2
3 Invoking pspp
pspp has two separate user interfaces. This chapter describes pspp, pspp’s command-line
driven text-based user interface. The following chapter briefly describes PSPPIRE, the
graphical user interface to pspp.
The sections below describe the pspp program’s command-line interface.
Specify this option more than once to produce multiple output files, presumably
in different formats.
Use ‘-’ as output-file to write output to standard output.
If no -o option is used, then pspp writes text and CSV output to standard
output and other kinds of output to whose name is based on the format, e.g.
pspp.pdf for PDF output.
-O option=value
Sets an option for the output file configured by a preceding -o. Most options
are specific to particular output formats. A few options that apply generically
are listed below.
-O format=format
pspp uses the extension of the file name given on -o to select an output format.
Use this option to override this choice by specifying an alternate format, e.g.
-o pspp.out -O format=html to write HTML to a file named pspp.out. Use
--help to list the available formats.
-O device={terminal|listing}
Sets whether pspp considers the output device configured by the preceding -o
to be a terminal or a listing device. This affects what output will be sent to the
device, as configured by the SET command’s output routing subcommands (see
Section 17.20 [SET], page 266). By default, output written to standard output
is considered a terminal device and other output is considered a listing device.
--no-output
Disables output entirely, if neither -o nor -O is also used. If one of those options
is used, --no-output has no effect.
--table-look=file
Reads a table style from file and applies it to all pspp table output. The file
should be a TableLook .stt or .tlo file. pspp searches for file in the current
directory, then in .pspp/looks in the user’s home directory, then in a looks
subdirectory inside pspp’s data directory (usually /usr/local/share/pspp). If
pspp cannot find file under the given name, it also tries adding a .stt extension.
When this option is not specified, pspp looks for default.stt using the algo-
rithm above, and otherwise it falls back to a default built-in style.
Using SET TLOOK in pspp syntax overrides the style set on the command line
(see Section 17.20 [SET], page 266).
-e error-file
--error-file=error-file
Configures a file to receive pspp error, warning, and note messages in plain
text format. Use ‘-’ as error-file to write messages to standard output. The
default error file is standard output in the absence of these options, but this is
suppressed if an output device writes to standard output (or another terminal),
to avoid printing every message twice. Use ‘none’ as error-file to explicitly
suppress the default.
Chapter 3: Invoking pspp 5
-I dir
--include=dir
Appends dir to the set of directories searched by the INCLUDE (see Section 17.15
[INCLUDE], page 264) and INSERT (see Section 17.16 [INSERT], page 264)
commands.
-I-
--no-include
Clears all directories from the include path, including directories inserted in the
include path by default. The default include path is . (the current directory),
followed by .pspp in the user’s home directory, followed by pspp’s system
configuration directory (usually /etc/pspp or /usr/local/etc/pspp).
-b
--batch
-i
--interactive
These options forces syntax files to be interpreted in batch mode or interactive
mode, respectively, rather than the default “auto” mode. See Section 6.3 [Syntax
Variants], page 27, for a description of the differences.
-r
--no-statrc
By default, at startup pspp searches for a file named rc in the include path
(described above) and, if it finds one, runs the commands in it. This option
disables this behavior.
-a {enhanced|compatible}
--algorithm={enhanced|compatible}
With enhanced, the default, pspp uses the best implemented algorithms for
statistical procedures. With compatible, however, pspp will in some cases
use inferior algorithms to produce the same results as the proprietary program
SPSS.
Some commands have subcommands that override this setting on a per command
basis.
-x {enhanced|compatible}
--syntax={enhanced|compatible}
With enhanced, the default, pspp accepts its own extensions beyond those
compatible with the proprietary program SPSS. With compatible, pspp rejects
syntax that uses these extensions.
--syntax-encoding=encoding
Specifies encoding as the encoding for syntax files named on the command line.
The encoding also becomes the default encoding for other syntax files read during
the pspp session by the INCLUDE and INSERT commands. See Section 17.16
[INSERT], page 264, for the accepted forms of encoding.
--help Prints a message describing pspp command-line syntax and the available device
formats, then exits.
Chapter 3: Invoking pspp 6
-V
--version
Prints a brief message listing pspp’s version, warranties you don’t have, copying
conditions and copyright, and e-mail address for bug reports, then exits.
-s
--safer Disables certain unsafe operations. This includes the ERASE and HOST commands,
as well as use of pipes as input and output files.
--testing-mode
Invoke heuristics to assist with testing pspp. For use by make check and similar
scripts.
-O left-margin=dimension
-O right-margin=dimension
-O top-margin=dimension
-O bottom-margin=dimension
Sets the margins around the page. See below for the allowed forms of dimension.
Default: 0.5in.
-O object-spacing=dimension
Sets the amount of vertical space between objects (such as headings or tables).
-O prop-font=font-name
Sets the default font used for ordinary text. Most systems support CSS-like font
names such as “Sans Serif”, but a wide range of system-specific fonts are likely
to be supported as well.
Default: proportional font Sans Serif.
-O font-size=font-size
Sets the size of the default fonts, in thousandths of a point. Default: 10000 (10
point).
-O trim=true
This option makes PSPP trim empty space around each page of output, before
adding the margins. This can make the output easier to include in other
documents.
-O outline=boolean
For PDF output only, this option controls whether PSPP includes an outline
in the output file. PDF viewers usually display the outline as a side bar that
allows for easy navigation of the file. The default is true unless -O trim=true
is also specified. (The Cairo graphics library that PSPP uses to produce PDF
output has a bug that can cause a crash when outlines and trimming are used
together.)
-O font-resolution=dpi
Sets the resolution for font rendering, in dots per inch. For PDF, PostScript,
and SVG output, the default is 72 dpi, so that a 10-point font is rendered with
a height of 10 points. For PNG output, the default is 96 dpi, so that a 10-point
font is rendered with a height of 10/72 ∗ 96 = 13.3 pixels. Use a larger dpi to
enlarge text output, or a smaller dpi to shrink it.
-O charts={template.png|none}
Name for chart files included in output. The value should be a file name that
includes a single ‘#’ and ends in png. When a chart is output, the ‘#’ is replaced
by the chart number. The default is the file name specified on -o with the
extension stripped off and replaced by -#.png.
Specify none to disable chart output.
-O foreground-color=color
-O background-color=color
Sets color as the color to be used for the background or foreground to be used
for charts. Color should be given in the format #RRRRGGGGBBBB, where RRRR,
GGGG and BBBB are 4 character hexadecimal representations of the red, green
and blue components respectively. If charts are disabled, this option has no
effect.
-O width=columns
Width of a page, in columns. If unspecified or given as auto, the default is
the width of the terminal, for interactive output, or the WIDTH setting (see
Section 17.20 [SET], page 266), for output to a file.
-O box={ascii|unicode}
Sets the characters used for lines in tables. If set to ascii, output uses use the
characters ‘-’, ‘|’, and ‘+’ for single-width lines and ‘=’ and ‘#’ for double-width
lines. If set to unicode then, output uses Unicode box drawing characters.
The default is unicode if the locale’s character encoding is "UTF-8" or ascii
otherwise.
-O emphasis={none|bold|underline}
How to emphasize text. Bold and underline emphasis are achieved with over-
striking, which may not be supported by all the software to which you might
pass the output. Default: none.
-O format=csv
Specify the output format. This is only necessary if the file name given on -o
does not end in .csv.
-O separator=field-separator
Sets the character used to separate fields. Default: a comma (‘,’).
-O quote=qualifier
Sets qualifier as the character used to quote fields that contain white space, the
separator (or any of the characters in the separator, if it contains more than one
character), or the quote character itself. If qualifier is longer than one character,
only the first character is used; if qualifier is the empty string, then fields are
never quoted.
-O titles=boolean
Whether table titles (brief descriptions) should be printed. Default: on.
-O captions=boolean
Whether table captions (more extensive descriptions) should be printed. Default:
on.
The CSV format used is an extension to that specified in RFC 4180:
Tables Each table row is output on a separate line, and each column is output as a
field. The contents of a cell that spans multiple rows or columns is output only
for the top-left row and column; the rest are output as empty fields.
Titles When a table has a title and titles are enabled, the title is output just above
the table as a single field prefixed by ‘Table:’.
Captions When a table has a caption and captions are enabled, the caption is output just
below the table as a single field prefixed by ‘Caption:’.
Footnotes Within a table, footnote markers are output as bracketed letters following
the cell’s contents, e.g. ‘[a]’, ‘[b]’, . . . The footnotes themselves are output
following the body of the table, as a separate two-column table introduced with
a line that says ‘Footnotes:’. Each row in the table represent one footnote: the
first column is the marker, the second column is the text.
Text Text in output is printed as a field on a line by itself. The TITLE and SUBTITLE
produce similar output, prefixed by ‘Title:’ or ‘Subtitle:’, respectively.
Messages Errors, warnings, and notes are printed the same way as text.
Charts Charts are not included in CSV output.
Successive output items are separated by a blank line.
11
4 Invoking psppire
5 Using pspp
pspp is a tool for the statistical analysis of sampled data. You can use it to discover patterns
in the data, to explain differences in one subset of data in terms of another subset and to
find out whether certain beliefs about the data are justified. This chapter does not attempt
to introduce the theory behind the statistical analysis, but it shows how such analysis can
be performed using pspp.
For the purposes of this tutorial, it is assumed that you are using pspp in its interactive
mode from the command line. However, the example commands can also be typed into a
file and executed in a post-hoc mode by typing ‘pspp file-name’ at a shell prompt, where
file-name is the name of the file containing the commands. Alternatively, from the graphical
interface, you can select File → New → Syntax to open a new syntax window and use the
Run menu when a syntax fragment is ready to be executed. Whichever method you choose,
the syntax is identical.
When using the interactive method, pspp tells you that it’s waiting for your data with a
string like PSPP> or data>. In the examples of this chapter, whenever you see text like this,
it indicates the prompt displayed by pspp, not something that you should type.
Throughout this chapter reference is made to a number of sample data files. So that you
can try the examples for yourself, you should have received these files along with your copy
of pspp.1
Please note: Normally these files are installed in the directory
//share/pspp/examples. If however your system administrator or operating
system vendor has chosen to install them in a different location, you will have
to adjust the examples accordingly.
For example, a data set which has the variables height, weight, and name, might have the
observations:
1881 89.2 Ahmed
1192 107.01 Frank
1230 67 Julie
The following sections explain how to define a dataset.
1
These files contain purely fictitious data. They should not be used for research purposes.
Chapter 5: Using pspp 13
to list the data. The optional text ‘/format=numbered’ requests the case numbers to be
shown along with the data. It should show the following output:
Data List
+-----------+---------+------+
|Case Number| forename|height|
+-----------+---------+------+
|1 |Ahmed |188.00|
|2 |Bertram |167.00|
|3 |Catherine|134.23|
|4 |David |109.10|
+-----------+---------+------+
Note that the numeric variable height is displayed to 2 decimal places, because the format
for that variable is ‘F8.2’. For a complete description of the LIST command, see Section 8.10
[LIST], page 74.
variable’s minimum value seems to be very low. In fact, it is more than 5 standard deviations
from the mean, and is a seemingly bizarre height for an adult person.
We can look deeper into these discrepancies by issuing an additional EXAMINE command:
PSPP> examine height, weight /statistics=extreme(3).
This command produces the following additional output (in part):
Extreme Values
+-------------------------------+-----------+-----+
| |Case Number|Value|
+-------------------------------+-----------+-----+
|Height in millimeters Highest 1| 14| 1903|
| 2| 15| 1884|
| 3| 12| 1802|
| ----------+-----------+-----+
| Lowest 1| 30| 179|
| 2| 31| 1598|
| 3| 28| 1601|
+-------------------------------+-----------+-----+
|Weight in kilograms Highest 1| 13| 92.1|
| 2| 5| 92.1|
| 3| 17| 91.7|
| ----------+-----------+-----+
| Lowest 1| 38|-55.6|
| 2| 39| 54.5|
| 3| 33| 55.4|
+-------------------------------+-----------+-----+
From this new output, you can see that the lowest value of height is 179 (which we suspect
to be erroneous), but the second lowest is 1598 which we know from DESCRIPTIVES is within
1 standard deviation from the mean. Similarly, the lowest value of weight is negative, but
its second lowest value is plausible. This suggests that the two extreme values are outliers
and probably represent data entry errors.
The output also identifies the case numbers for each extreme value, so we can see that
cases 30 and 38 are the ones with the erroneous values.
Value Labels
+----------------------------------------------------+-----------------+
|Variable Value | Label |
+----------------------------------------------------+-----------------+
|I am satisfied with the level of service 1|Strongly Disagree|
| 2|Disagree |
| 3|No Opinion |
| 4|Agree |
| 5|Strongly Agree |
+----------------------------------------------------+-----------------+
|The value for money was good 1|Strongly Disagree|
| 2|Disagree |
| 3|No Opinion |
| 4|Agree |
| 5|Strongly Agree |
+----------------------------------------------------+-----------------+
|The staff were slow in responding 1|Strongly Disagree|
| 2|Disagree |
| 3|No Opinion |
| 4|Agree |
| 5|Strongly Agree |
+----------------------------------------------------+-----------------+
Chapter 5: Using pspp 18
Reliability Statistics
Chapter 5: Using pspp 19
+----------------+----------+
|Cronbach’s Alpha|N of Items|
+----------------+----------+
| .81| 3|
+----------------+----------+
As a rule of thumb, many statisticians consider a value of Cronbach’s Alpha of 0.7 or
higher to indicate reliable data.
Here, the value is 0.81, which suggests a high degree of reliability among variables v1, v3
and v4, so the data and the recoding that we performed are vindicated.
| ----------------------------------+---------+--------+
| Kurtosis | 3.41| .83|
+----------------------------------------------------------+---------+--------+
A normal distribution has a skewness and kurtosis of zero. The skewness of mtbf in the
output above makes it clear that the mtbf figures have a lot of positive skew and are therefore
not drawn from a normally distributed variable. Positive skew can often be compensated for
by applying a logarithmic transformation, as in the following continuation of the example:
PSPP> compute mtbf_ln = ln (mtbf).
PSPP> examine mtbf_ln
/statistics=descriptives.
which produces the following additional output:
Descriptives
+----------------------------------------------------+---------+----------+
| |Statistic|Std. Error|
+----------------------------------------------------+---------+----------+
|mtbf_ln Mean | 1.95| .13|
| ---------------------------------------------+---------+----------+
| 95% Confidence Interval for Mean Lower Bound| 1.69| |
| Upper Bound| 2.22| |
| ---------------------------------------------+---------+----------+
| 5% Trimmed Mean | 1.96| |
| ---------------------------------------------+---------+----------+
| Median | 2.11| |
| ---------------------------------------------+---------+----------+
| Variance | .49| |
| ---------------------------------------------+---------+----------+
| Std. Deviation | .70| |
| ---------------------------------------------+---------+----------+
| Minimum | .49| |
| ---------------------------------------------+---------+----------+
| Maximum | 3.28| |
| ---------------------------------------------+---------+----------+
| Range | 2.79| |
| ---------------------------------------------+---------+----------+
| Interquartile Range | .88| |
| ---------------------------------------------+---------+----------+
| Skewness | -.37| .43|
| ---------------------------------------------+---------+----------+
| Kurtosis | .01| .83|
+----------------------------------------------------+---------+----------+
The COMPUTE command in the first line above performs the logarithmic transformation:
compute mtbf_ln = ln (mtbf).
Rather than redefining the existing variable, this use of COMPUTE defines a new variable
mtbf ln which is the natural logarithm of mtbf. The final command in this example calls
EXAMINE on this new variable. The results show that both the skewness and kurtosis for
mtbf ln are very close to zero. This provides some confidence that the mtbf ln variable
is normally distributed and thus safe for linear analysis. In the event that no suitable
transformation can be found, then it would be worth considering an appropriate non-
parametric test instead of a linear one. See Section 15.12 [NPAR TESTS], page 202, for
information about non-parametric tests.
Chapter 5: Using pspp 21
2
This example assumes that it is already proven that B is not greater than A.
Chapter 5: Using pspp 22
+---------------------+-------------+
| | |
| | |
| | |
| | |
| | |
| +-------------+
Chapter 5: Using pspp 23
| | 95% |
| | Confidence |
| | Interval of |
| | the |
| | Difference |
| +------+------+
| | Lower| Upper|
+---------------------+------+------+
|Height in Equal |158.88|212.55|
|millimeters variances| | |
| assumed | | |
| Equal |160.76|210.67|
| variances| | |
| not | | |
| assumed | | |
+---------------------+------+------+
|Internal Equal | -1.91| .41|
|body variances| | |
|temperature assumed | | |
|in degrees Equal | -1.89| .39|
|Celcius variances| | |
| not | | |
| assumed | | |
+---------------------+------+------+
The T-TEST command tests for differences of means. Here, the height variable’s two
tailed significance is less than 0.05, so the null hypothesis can be rejected. Thus, the evidence
suggests there is a difference between the heights of male and female persons. However
the significance of the test for the temperature variable is greater than 0.05 so the null
hypothesis cannot be rejected, and there is insufficient evidence to suggest a difference in
body temperature.
6.1 Tokens
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 Identifiers are names that typically specify variables, commands, or subcom-
mands. The first character in an identifier must be a letter, ‘#’, or ‘@’. The
remaining characters in the identifier must be letters, digits, or one of the
following special characters:
. _ $ # @
Identifiers may be any length, but only the first 64 bytes are significant. Identi-
fiers 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
Keywords Keywords are a subclass of identifiers that form a fixed part of command syntax.
For example, command and subcommand names are keywords. Keywords may
be abbreviated to their first 3 characters if this abbreviation is unambiguous.
(Unique abbreviations of 3 or more characters are also accepted: ‘FRE’, ‘FREQ’,
and ‘FREQUENCIES’ are equivalent when the last is a keyword.)
Reserved identifiers are always used as keywords. Other identifiers may be used
both as keywords and as user-defined identifiers, such as variable names.
Numbers Numbers are expressed in decimal. A decimal point is optional. Numbers may
be expressed in scientific notation by adding ‘e’ and a base-10 exponent, so that
‘1.234e3’ has the value 1234. Here are some more examples of valid numbers:
-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.’ is interpreted as two tokens, ‘8945’ and ‘.’, if
it is the last token on a line. See Section 6.2 [Forming commands of tokens],
page 26.
Strings Strings are literal sequences of characters enclosed in pairs of single quotes (‘’’)
or double quotes (‘"’). To include the character used for quoting in the string,
double it, e.g. ‘’it’’s an apostrophe’’. White space and case of letters are
significant inside strings.
Chapter 6: The pspp language 26
Strings can be concatenated using ‘+’, so that ‘"a" + ’b’ + ’c’’ is equivalent
to ‘’abc’’. So that a long string may be broken across lines, a line break may
precede or follow, or both precede and follow, the ‘+’. (However, an entirely
blank line preceding or following the ‘+’ is interpreted as ending the current
command.)
Strings may also be expressed as hexadecimal character values by prefixing
the initial quote character by ‘x’ or ‘X’. Regardless of the syntax file or active
dataset’s encoding, the hexadecimal digits in the string are interpreted as
Unicode characters in UTF-8 encoding.
Individual Unicode code points may also be expressed by specifying the hex-
adecimal code point number in single or double quotes preceded by ‘u’ or ‘U’.
For example, Unicode code point U+1D11E, the musical G clef character, could
be expressed as U’1D11E’. Invalid Unicode code points (above U+10FFFF or in
between U+D800 and U+DFFF) are not allowed.
When strings are concatenated with ‘+’, each segment’s prefix is considered
individually. For example, ’The G clef symbol is:’ + u"1d11e" + "." inserts
a G clef symbol in the middle of an otherwise plain text string.
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 Section 6.1 [Tokens], page 25). A blank line, or one that consists only of white space or
comments, also ends a command.
Chapter 6: The pspp language 27
Procedures
Analyze data, writing results of analyses to the listing file. Cause transformations
specified earlier in the file to be performed. In a more general sense, a procedure
is any command that causes the active dataset (the data) to be read.
6.7 Datasets
pspp works with data organized into datasets. A dataset consists of a set of variables, which
taken together are said to form a dictionary, and one or more cases, each of which has one
value for each variable.
At any given time pspp has exactly one distinguished dataset, called the active dataset.
Most pspp commands work only with the active dataset. In addition to the active dataset,
pspp also supports any number of additional open datasets. The DATASET commands can
choose a new active dataset from among those that are open, as well as create and destroy
datasets (see Section 8.4 [DATASET], page 63).
The sections below describe variables in more detail.
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 capital-
izes variable names on output the same way they were capitalized at their point
of definition in the input.
Type Numeric or string.
Width (string variables only) String variables with a width of 8 characters or fewer
are called short string variables. Short string variables may be used in a few
contexts where long string variables (those with widths greater than 8) are not
allowed.
Position Variables in the dictionary are arranged in a specific order. DISPLAY can be
used to show this order: see Section 11.1 [DISPLAY], page 98.
Initialization
Either reinitialized to 0 or spaces for each case, or left at its existing value. See
Section 11.21 [LEAVE], page 107.
Missing values
Optionally, up to three values, or a range of values, or a specific value plus a
range, can be specified as user-missing values. There is also a system-missing
value that is assigned to an observation when there is no other obvious value for
that observation. Observations with missing values are automatically excluded
from analyses. User-missing values are actual data values, while the system-
missing value is not a value at all. See Section 6.6 [Missing Observations],
page 29.
Variable label
A string that describes the variable. See Section 11.7 [VARIABLE LABELS],
page 101.
Value label
Optionally, these associate each possible value of the variable with a string. See
Section 11.11 [VALUE LABELS], page 102.
Print format
Display width, format, and (for numeric variables) number of decimal places.
This attribute does not affect how data are stored, just how they are displayed.
Example: a width of 8, with 2 decimal places. See Section 6.7.4 [Input and
Output Formats], page 32.
Write format
Similar to print format, but used by the WRITE command (see Section 8.17
[WRITE], page 78).
Measurement level
One of the following:
Nominal Each value of a nominal variable represents a distinct category. The
possible categories are finite and often have value labels. The order
of categories is not significant. Political parties, US states, and
Chapter 6: The pspp language 31
$DATE Date the pspp process was started, in format A9, following the pattern DD-MMM-
YY.
$DATE11 Date the pspp process was started, in format A11, following the pattern DD-MMM-
YYYY.
$JDATE Number of days between 15 Oct 1582 and the time the pspp process was started.
$LENGTH Page length, in lines, in format F11.
$SYSMIS System missing value, in format F1.
$TIME Number of seconds between midnight 14 Oct 1582 and the time the active
dataset was read, in format F20.
$WIDTH Page width, in characters, in format F3.
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.
• COMMA, DOLLAR, and DOT formats ignore grouping characters within the integer
part of the input field. The identity of the grouping character depends on the format.
• DOLLAR format allows a dollar sign to precede the number. In a negative number, the
dollar sign may precede or follow the minus sign.
• PCT format allows a percent sign to follow the number.
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:
• As input formats, the basic numeric formats allow no more decimal places than the
field width. As output formats, the field width must be greater than the number of
decimal places; that is, large enough to allow for a decimal point and the number of
requested decimal places. DOLLAR and PCT formats must allow an additional column
for ‘$’ or ‘%’.
• The default output format for a given input format increases the field width enough to
make room for optional input characters. If an input format calls for decimal places,
the width is increased by 1 to make room for an implied decimal point. COMMA,
DOT, and DOLLAR formats also increase the output width to make room for grouping
characters. DOLLAR and PCT further increase the output field width by 1 to make
room for ‘$’ or ‘%’. The increased output width is capped at 40, the maximum field
width.
• The E format is exceptional. For output, E format has a minimum width of 7 plus the
number of decimal places. The default output format for an E input format is an E
format with at least 3 decimal places and thus a minimum width of 10.
More details of basic numeric output formatting are given below:
• Output rounds to nearest, with ties rounded away from zero. Thus, 2.5 is output as 3
in F1.0 format, and -1.125 as -1.13 in F5.1 format.
• The system-missing value is output as a period in a field of spaces, placed in the decimal
point’s position, or in the rightmost column if no decimal places are requested. A period
is used even if the decimal point character is a comma.
• A number that does not fill its field is right-justified within the field.
• A number is too large for its field causes decimal places to be dropped to make room.
If dropping decimals does not make enough room, scientific notation is used if the field
is wide enough. If a number does not fit in the field, even in scientific notation, the
overflow is indicated by filling the field with asterisks (‘*’).
• COMMA, DOT, and DOLLAR formats insert grouping characters only if space is
available for all of them. Grouping characters are never inserted when all decimal places
must be dropped. Thus, 1234.56 in COMMA5.2 format is output as ‘ 1235’ without a
comma, even though there is room for one, because all decimal places were dropped.
• DOLLAR or PCT format drop the ‘$’ or ‘%’ only if the number would not fit at all
without it. Scientific notation with ‘$’ or ‘%’ is preferred to ordinary decimal notation
without it.
• Except in scientific notation, a decimal point is included only when it is followed by
a digit. If the integer part of the number being output is 0, and a decimal point is
included, then pspp ordinarily drops the zero before the decimal point. However, in
Chapter 6: The pspp language 35
F, COMMA, or DOT formats, pspp keeps the zero if SET LEADZERO is set to ON (see [SET
LEADZERO], page 270).
In scientific notation, the number always includes a decimal point, even if it is not
followed by a digit.
• A negative number includes a minus sign only in the presence of a nonzero digit: -0.01
is output as ‘-.01’ in F4.2 format but as ‘ .0’ in F4.1 format. Thus, a “negative zero”
never includes a minus sign.
• In negative numbers output in DOLLAR format, the dollar sign follows the negative
sign. Thus, -9.99 in DOLLAR6.2 format is output as -$9.99.
• In scientific notation, the exponent is output as ‘E’ followed by ‘+’ or ‘-’ and exactly
three digits. Numbers with magnitude less than 10**-999 or larger than 10**999 are not
supported by most computers, but if they are supported then their output is considered
to overflow the field and they are output as asterisks.
• On most computers, no more than 15 decimal digits are significant in output, even
if more are printed. In any case, output precision cannot be any higher than input
precision; few data sets are accurate to 15 digits of precision. Unavoidable loss of
precision in intermediate calculations may also reduce precision of output.
• Special values such as infinities and “not a number” values are usually converted to the
system-missing value before printing. In a few circumstances, these values are output
directly. In fields of width 3 or greater, special values are output as however many
characters fit from +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.
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:
N Format
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.
Chapter 6: The pspp language 37
Z Format
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], page 268).
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.
P and PK Formats
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).
Chapter 6: The pspp language 38
RB Format
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], page 268) and SET WRB, similarly, for writing (see [SET
WRB], page 271).
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 do not produce useful
results. The maximum field width is 8. No decimal places may be specified.
The default output format is F8.2.
between human-readable dates and pspp’s numeric representation of dates and times. pspp
has several date formats:
seconds are optional. The DECIMAL setting controls the character accepted
and displayed as the decimal point (see [SET DECIMAL], page 268).
For 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:
4-digit year
A field 2 columns wider than the minimum includes a 4-digit year. (DATETIME
and YMDHMS formats always include a 4-digit year.)
seconds A field 3 columns wider than the minimum includes seconds as well as minutes.
A field 5 columns wider than minimum, or more, can also include a decimal
point and fractional seconds (but no more than allowed by the format’s decimal
places).
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 MTIME, 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.
Chapter 6: The pspp language 41
command file
syntax file These names (synonyms) refer to the file that contains instructions that tell
pspp what to do. The syntax file’s name is specified on the pspp command
line. Syntax files can also be read with INCLUDE (see Section 17.15 [INCLUDE],
page 264).
data file Data files contain raw data in text or binary format. Data can also be embedded
in a syntax file with BEGIN DATA and END DATA.
listing file One or more output files are created by pspp each time it is run. The output
files receive the tables and charts produced by statistical procedures. The output
files may be in any number of formats, depending on how pspp is configured.
system file
System files are binary files that store a dictionary and a set of cases. GET and
SAVE read and write system files.
portable file
Portable files are files in a text-based format that store a dictionary and a set of
cases. IMPORT and EXPORT read and write portable files.
7 Mathematical Expressions
Expressions 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.
a/b Divides a by b and yields the quotient. If a is 0, then the result is 0, even if b is
missing. If b is zero, the result is system-missing.
a ** b Yields the result of raising a to the power b. If a is negative and b is not an
integer, the result is system-missing. The result of 0**0 is system-missing as
well.
-a Reverses the sign of a.
7.7 Functions
pspp 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 a variable called EXP.
The sections below describe each function in detail.
2. **
3. -
4. */
5. +-
6. = >= > <= < <>
7. NOT
8. AND
9. OR
62
are reserved for pspp’s internal use, and attribute names that begin with @ or $@ are not
displayed by most pspp commands that display other attributes. Other attribute names are
not treated specially.
Attributes may also be organized into arrays. To assign to an array element, add an
integer array index enclosed in square brackets ([ and ]) between the attribute name and
value. Array indexes start at 1, not 0. An attribute array that has a single element (number
1) is not distinguished from a non-array attribute.
Use the DELETE subcommand to delete an attribute. Specify an attribute name by itself
to delete an entire attribute, including all array elements for attribute arrays. Specify an
attribute name followed by an array index in square brackets to delete a single element of an
attribute array. In the latter case, all the array elements numbered higher than the deleted
element are shifted down, filling the vacated position.
To associate custom attributes with particular variables, instead of with the entire active
dataset, use VARIABLE ATTRIBUTE (see Section 11.14 [VARIABLE ATTRIBUTE], page 103)
instead.
DATAFILE ATTRIBUTE takes effect immediately. It is not affected by conditional and
looping structures such as DO IF or LOOP.
The DATASET CLOSE command deletes a dataset. If the active dataset is specified by
name, or if ‘*’ is specified, then the active dataset becomes unnamed. If a different dataset
is specified by name, then it is deleted and becomes unavailable. Specifying ALL deletes all
datasets except for the active dataset, which becomes unnamed.
The DATASET DISPLAY command lists all the currently defined datasets.
Many DATASET commands accept an optional WINDOW subcommand. In the psppIRE
GUI, the value given for this subcommand influences how the dataset’s window is displayed.
Outside the GUI, the WINDOW subcommand has no effect. The valid values are:
ASIS Do not change how the window is displayed. This is the default for DATASET
NAME and DATASET ACTIVATE.
FRONT Raise the dataset’s window to the top. Make it the default dataset for running
syntax.
MINIMIZED
Display the window “minimized” to an icon. Prefer other datasets for running
syntax. This is the default for DATASET COPY and DATASET DECLARE.
HIDDEN Hide the dataset’s window. Prefer other datasets for running syntax.
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 Section 6.9 [File Handles],
page 42). If the FILE subcommand is not used, then input is assumed to be specified
within the command file using BEGIN DATA. . . END DATA (see Section 8.1 [BEGIN DATA],
page 62). The ENCODING subcommand may only be used if the FILE subcommand is also
used. It specifies the character encoding of the file. See Section 17.16 [INSERT], page 264,
for information on supported encodings.
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 Section 8.9
[INPUT PROGRAM], page 71, 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 is 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 Section 6.7.3 [Sets of Variables], page 32). 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 Section 6.7.4 [Input and Output Formats], page 32). (This default can be changed; see
Section 17.20 [SET], page 266, 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
Chapter 8: Data Input and Output 66
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 Section 6.7.4 [Input and Output
Formats], page 32), FORTRAN style defines some extensions:
X Advance the current column on this line by one character position.
Tx Set the current column on this line to column x, with column numbers considered
to begin with 1 at the left margin.
NEWRECx Skip forward x lines in the current record, resetting the active column to the
left margin.
Repeat count
Any format specifier may be preceded by a number. This causes the action of
that format specifier to be repeated the specified number of times.
(spec1, . . . , specN )
Group the given specifiers together. This is most useful when preceded by a
repeat count. Groups may be nested arbitrarily.
FORTRAN 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.
Examples
1.
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 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.
Chapter 8: Data Input and Output 67
2.
DATA LIST FILE="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 string variable, in columns 7-36 of the first record.
• SURNAME, a 30-character string variable, in columns 38-67 of the first record.
• MINITIAL, a 1-character string variable, in column 69 of the first record.
• Fifty variables 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.
in parentheses (see Section 6.7.4 [Input and Output Formats], page 32). 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.
/NAME=’file name’
/MODE=IMAGE
[/LRECL=rec len]
[ENCODING=’encoding’]
SPANNED mode, the third byte of each RDW is called the segment control
character (SCC). Odd SCC values cause the segment to be appended to a
record buffer maintained in memory; even values also append the segment
and then flush its contents to the input procedure. Canonically, SCC value
0 designates a record not spanned among multiple segments, and values 1
through 3 designate the first segment, the last segment, or an intermediate
segment, respectively, within a multi-segment record. The record buffer is
also flushed at end of file regardless of the final record’s SCC.
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.
The ENCODING subcommand specifies the encoding of text in the file. For reading text
files in CHARACTER mode, all of the forms described for ENCODING on the INSERT
command are supported (see Section 17.16 [INSERT], page 264). For reading in other
file-based modes, encoding autodetection is not supported; if the specified encoding requests
autodetection then the default encoding is used. This is also true when a file handle is used
for writing a file in any mode.
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.
INPUT PROGRAM must contain at least one DATA LIST or END FILE command.
DO IF NOT #A.
DATA LIST NOTABLE END=#A FILE=’a.txt’/X 1-10.
END IF.
DO IF NOT #B.
DATA LIST NOTABLE END=#B FILE=’b.txt’/Y 1-10.
END IF.
DO IF #A AND #B.
END FILE.
END IF.
END CASE.
END INPUT PROGRAM.
LIST.
DO IF #A.
DATA LIST NOTABLE END=#B FILE=’b.txt’/X 1-10.
DO IF #B.
END FILE.
ELSE.
END CASE.
END IF.
ELSE.
DATA LIST NOTABLE END=#A FILE=’a.txt’/X 1-10.
DO IF NOT #A.
END CASE.
END IF.
END IF.
END INPUT PROGRAM.
LIST.
COMPUTE #EOF = 0.
LOOP IF NOT #EOF.
DATA LIST NOTABLE END=#EOF FILE=’b.txt’/X 1-10.
DO IF NOT #EOF.
END CASE.
END IF.
END LOOP.
END FILE.
END INPUT PROGRAM.
LIST.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
LIST /FORMAT=NUMBERED.
8.10 LIST
LIST
/VARIABLES=var list
/CASES=FROM start index TO end index BY incr index
/FORMAT={UNNUMBERED,NUMBERED} {WRAP,SINGLE}
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 dataset 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.
Case numbers start from 1. They are counted after all transformations have been
considered.
LIST is a procedure. It causes the data to be read.
8.12 PRINT
PRINT
[OUTFILE=’file name’]
[RECORDS=n lines]
[{NOTABLE,TABLE}]
[ENCODING=’encoding’]
[/[line no] arg . . . ]
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 Section 17.11 [EXECUTE], page 263).
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 Section 6.9 [File Handles], page 42). If OUTFILE is
not present then output is sent to pspp’s output listing file. When OUTFILE is present, the
output is written to file name in a plain text format, with a space inserted at beginning of
each output line, even lines that otherwise would be blank.
The ENCODING subcommand may only be used if the OUTFILE subcommand is also used.
It specifies the character encoding of the file. See Section 17.16 [INSERT], page 264, for
information on supported encodings.
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 is specified. In the absence of
this line number, the next line number is 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, specifying the column on the line where the string should
start. Otherwise, the string is 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 Section 8.5.1 [DATA LIST FIXED], page 64). 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 is interpreted in 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 is truncated to that length, although
additional text being added will again extend the line to that length.
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 Section 8.12 [PRINT], page 74, for more information on syntax and usage.
8.15 REREAD
REREAD [FILE=handle] [COLUMN=column] [ENCODING=’encoding’].
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 Section 6.9 [File Handles],
page 42). If FILE is not specified then the last file specified on DATA LIST is 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 Chapter 7
[Expressions], page 44) evaluating to the first column that should be included in the re-read
line. Columns are numbered from 1 at the left margin.
The ENCODING subcommand may only be used if the FILE subcommand is also used.
It specifies the character encoding of the file. See Section 17.16 [INSERT], page 264, for
information on supported encodings.
Issuing REREAD multiple times will not back up in the data file. Instead, it will re-read
the same line multiple times.
Chapter 8: Data Input and Output 77
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 Section 14.5 [LOOP], page 149). Use DATA
LIST before, not after, REPEATING DATA.
8.17 WRITE
WRITE
OUTFILE=’file name’
RECORDS=n lines
{NOTABLE,TABLE}
/[line no] arg . . .
The commands in this chapter read, write, and examine system files and portable files.
APPLY DICTIONARY takes effect immediately. It does not read the active dataset. The
system file is not modified.
Chapter 9: System and Portable File I/O 80
9.2 EXPORT
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 dataset’s dictionary and data to a specified
portable 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 to be written as a file name string or a file handle (see Section 6.9 [File Handles], page 42).
DROP, KEEP, and RENAME follow the same format as the SAVE procedure (see Section 9.6
[SAVE], page 87).
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 dataset to be read.
9.3 GET
GET
/FILE={’file name’,file handle}
/DROP=var list
/KEEP=var list
/RENAME=(src names=target names). . .
/ENCODING=’encoding’
GET clears the current dictionary and active dataset and replaces them with the dictionary
and data from a specified file.
The FILE subcommand is the only required subcommand. Specify the SPSS system file,
SPSS/PC+ system file, or SPSS portable file to be read as a string file name or a file handle
(see Section 6.9 [File Handles], page 42).
Chapter 9: System and Portable File I/O 81
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 dataset read from the
file is affected by these subcommands.
pspp automatically detects the encoding of string data in the file, when possible. The char-
acter encoding of old SPSS system files cannot always be guessed correctly, and SPSS/PC+
system files do not include any indication of their encoding. Specify the ENCODING subcom-
mand with an IANA character set name as its string argument to override the default. Use
SYSFILE INFO to analyze the encodings that might be valid for a system file. The ENCODING
subcommand is a pspp extension.
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 is a pspp extension.
all Postgres data types. If pspp cannot support a datum, GET DATA issues a warning and
substitutes the system-missing value.
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 ASSUMEDSTRWIDTH 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 occurs. 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 is probably 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’.
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.
IMPORTCASES is ignored, for compatibility. Use N OF CASES to limit the number of cases
read from a file (see Section 13.2 [N OF CASES], page 128), or SAMPLE to obtain a random
sample of cases (see Section 13.3 [SAMPLE], page 129).
The remaining subcommands apply only to one of the two file arrangements, described
below.
/DELIMITERS="delimiters"
[/QUALIFIER="quotes"
[/DELCASE={LINE,VARIABLES n variables}]
/VARIABLES=del var1 [del var2]. . .
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
Section 8.5.2 [DATA LIST FREE], page 67), with a few enhancements.
The required FILE subcommand and optional FIRSTCASE and IMPORTCASE subcommands
are described above (see Section 9.4.3 [GET DATA /TYPE=TXT], page 83).
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.
Chapter 9: System and Portable File I/O 85
The character specified on QUALIFIER can be embedded within a field that it quotes by
doubling the qualifier. For example, if ‘’’ is specified on QUALIFIER, then ’a’’b’ specifies a
field that contains ‘a’b’.
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 Section 6.7.4 [Input and Output Formats],
page 32) in the order they should be read from the input file.
Examples
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), ,
Chapter 9: System and Portable File I/O 86
[/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 Section 8.5.1 [DATA LIST FIXED], page 64), with a few enhancements.
The required FILE subcommand and optional FIRSTCASE and IMPORTCASE subcommands
are described above (see Section 9.4.3 [GET DATA /TYPE=TXT], page 83).
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 an input format type (e.g. ‘F’) or a full
format specification (e.g. ‘DOLLAR12.2’). 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.
Examples
Consider the following data on used cars:
model year mileage price type age
Chapter 9: System and Portable File I/O 87
9.5 IMPORT
IMPORT
/FILE=’file name’
/TYPE={COMM,TAPE}
/DROP=var list
/KEEP=var list
/RENAME=(src names=target names). . .
The IMPORT transformation clears the active dataset dictionary and data and replaces
them with a dictionary and data from a system file or portable 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 Section 6.9 [File Handles], page 42).
The TYPE subcommand is currently not used.
DROP, KEEP, and RENAME follow the syntax used by GET (see Section 9.3 [GET], page 80).
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 is a pspp extension.
9.6 SAVE
SAVE
/OUTFILE={’file name’,file handle}
/UNSELECTED={RETAIN,DELETE}
/{UNCOMPRESSED,COMPRESSED,ZCOMPRESSED}
/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 dataset to be written to
a system file.
Chapter 9: System and Portable File I/O 88
OUTFILE is the only required subcommand. Specify the system file to be written as a
string file name or a file handle (see Section 6.9 [File Handles], page 42).
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 UNCOMPRESSED, COMPRESSED, and ZCOMPRESSED subcommand determine the system
file’s compression level:
UNCOMPRESSED
Data is not compressed. Each numeric value uses 8 bytes of disk space. Each
string value uses one byte per column width, rounded up to a multiple of 8
bytes.
COMPRESSED
Data is compressed with a simple algorithm. Each integer numeric value between
−99 and 151, inclusive, or system missing value uses one byte of disk space.
Each 8-byte segment of a string that consists only of spaces uses 1 byte. Any
other numeric value or 8-byte string segment uses 9 bytes of disk space.
ZCOMPRESSED
Data is compressed with the “deflate” compression algorithm specified in
RFC 1951 (the same algorithm used by gzip). Files written with this compres-
sion level cannot be read by PSPP 0.8.1 or earlier or by SPSS 20 or earlier.
COMPRESSED is the default compression level. The SET command (see Section 17.20
[SET], page 266) can change this default.
The PERMISSIONS subcommand specifies permissions for the new system file. WRITE-
ABLE, 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 dataset 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
dataset. 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 dataset. 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
are truncated. The two versions are otherwise identical.
Chapter 9: System and Portable File I/O 89
[/DROP=var list]
[/KEEP=var list]
[/RENAME=(src names=target names). . . ]
[/UNSELECTED={RETAIN,DELETE}]
[/MAP]
The OUTFILE and TYPE subcommands are mandatory. OUTFILE specifies the file to be
written, as a string file name or a file handle (see Section 6.9 [File Handles], page 42). TYPE
determines the type of the file or source to read. It must be one of the following:
CSV Comma-separated value format,
TAB Tab-delimited format.
By default, SAVE TRANSLATE does not overwrite an existing file. Use REPLACE to force an
existing file to be overwritten.
With MISSING=IGNORE, the default, SAVE TRANSLATE treats user-missing values as if
they were not missing. Specify MISSING=RECODE to output numeric user-missing values
like system-missing values and string user-missing values as all spaces.
By default, all the variables in the active dataset dictionary are saved to the system file,
but DROP or KEEP can select a subset of variable to save. The RENAME subcommand can also
be used to change the names under which variables are saved; because they are used only in
the output, these names do not have to conform to the usual PSPP variable naming rules.
UNSELECTED determines whether cases filtered out by the FILTER command are written to
the output file. These subcommands have the same syntax and meaning as on the SAVE
command (see Section 9.6 [SAVE], page 87).
Each supported file type has additional subcommands, explained in separate sections
below.
SAVE TRANSLATE causes the data to be read. It is a procedure.
[/DROP=var list]
[/KEEP=var list]
[/RENAME=(src names=target names). . . ]
[/UNSELECTED={RETAIN,DELETE}]
[/FIELDNAMES]
[/CELLS={VALUES,LABELS}]
[/TEXTOPTIONS DELIMITER=’delimiter’]
[/TEXTOPTIONS QUALIFIER=’qualifier’]
[/TEXTOPTIONS DECIMAL={DOT,COMMA}]
[/TEXTOPTIONS FORMAT={PLAIN,VARIABLE}]
The SAVE TRANSLATE command with TYPE=CSV or TYPE=TAB writes data in a
comma- or tab-separated value format similar to that described by RFC 4180. Each variable
becomes one output column, and each case becomes one line of output. If FIELDNAMES is
specified, an additional line at the top of the output file lists variable names.
Chapter 9: System and Portable File I/O 91
The CELLS and TEXTOPTIONS FORMAT settings determine how values are written
to the output file:
CELLS=VALUES FORMAT=PLAIN (the default settings)
Writes variables to the output in “plain” formats that ignore the details of
variable formats. Numeric values are written as plain decimal numbers with
enough digits to indicate their exact values in machine representation. Numeric
values include ‘e’ followed by an exponent if the exponent value would be less
than -4 or greater than 16. Dates are written in MM/DD/YYYY format and
times in HH:MM:SS format. WKDAY and MONTH values are written as
decimal numbers.
Numeric values use, by default, the decimal point character set with SET
DECIMAL (see [SET DECIMAL], page 268). Use DECIMAL=DOT or DECI-
MAL=COMMA to force a particular decimal point character.
CELLS=VALUES FORMAT=VARIABLE
Writes variables using their print formats. Leading and trailing spaces are
removed from numeric values, and trailing spaces are removed from string
values.
CELLS=LABEL FORMAT=PLAIN
CELLS=LABEL FORMAT=VARIABLE
Writes value labels where they exist, and otherwise writes the values themselves
as described above.
Regardless of CELLS and TEXTOPTIONS FORMAT, numeric system-missing values
are output as a single space.
For TYPE=TAB, tab characters delimit values. For TYPE=CSV, the TEXTOPTIONS
DELIMITER and DECIMAL settings determine the character that separate values within a
line. If DELIMITER is specified, then the specified string separate values. If DELIMITER
is not specified, then the default is a comma with DECIMAL=DOT or a semicolon with
DECIMAL=COMMA. If DECIMAL is not given either, it is implied by the decimal point
character set with SET DECIMAL (see [SET DECIMAL], page 268).
The TEXTOPTIONS QUALIFIER setting specifies a character that is output before and
after a value that contains the delimiter character or the qualifier character. The default is
a double quote (‘"’). A qualifier character that appears within a value is doubled.
specify ENCODING=’DETECT’ to analyze and report possibly valid encodings for the system
file. The ENCODING subcommand is a pspp extension.
SYSFILE INFO does not affect the current active dataset.
9.10 XEXPORT
XEXPORT
/OUTFILE=’file name’
/DIGITS=n
/DROP=var list
/KEEP=var list
/RENAME=(src names=target names). . .
/TYPE={COMM,TAPE}
/MAP
The XEXPORT transformation writes the active dataset dictionary and data to a specified
portable file.
This transformation is a pspp extension.
It is similar to the EXPORT procedure, with two differences:
• XEXPORT is a transformation, not a procedure. It is executed when the data is read by
a procedure or procedure-like command.
• XEXPORT does not support the UNSELECTED subcommand.
See Section 9.2 [EXPORT], page 80, for more information.
9.11 XSAVE
XSAVE
/OUTFILE=’file name’
/{UNCOMPRESSED,COMPRESSED,ZCOMPRESSED}
/PERMISSIONS={WRITEABLE,READONLY}
/DROP=var list
/KEEP=var list
/VERSION=version
/RENAME=(src names=target names). . .
/NAMES
/MAP
The XSAVE transformation writes the active dataset’s dictionary and data to a system
file. It is similar to the SAVE procedure, with two differences:
• XSAVE is a transformation, not a procedure. It is executed when the data is read by a
procedure or procedure-like command.
• XSAVE does not support the UNSELECTED subcommand.
See Section 9.6 [SAVE], page 87, for more information.
93
At least two FILE subcommands must be specified. If the active dataset is used as an
input source, then TEMPORARY must not be in effect.
Each FILE subcommand may be followed by any number of RENAME subcommands
that specify a parenthesized group or groups of variable names as they appear in the
input file, followed by those variables’ new names, separated by an equals sign (=), e.g.
/RENAME=(OLD1=NEW1)(OLD2=NEW2). To rename a single variable, the parentheses may
be omitted: /RENAME=old=new. Within a parenthesized group, variables are renamed
simultaneously, so that /RENAME=(A B=B A) exchanges the names of variables A and B.
Otherwise, renaming occurs in left-to-right order.
Each FILE subcommand may optionally be followed by a single IN subcommand, which
creates a numeric variable with the specified name and format F1.0. The IN variable takes
value 1 in an output case if the given input file contributed to that output case, and 0
otherwise. The DROP, KEEP, and RENAME subcommands have no effect on IN variables.
If BY is used (see below), the SORT keyword must be specified after a FILE if that input
file is not already sorted on the BY variables. When SORT is specified, pspp sorts the input
file’s data on the BY variables before it applies it to the command. When SORT is used, BY is
required. SORT is a pspp extension.
pspp merges the dictionaries of all of the input files to form the dictionary of the new
active dataset, like so:
• The variables in the new active dataset are the union of all the input files’ variables,
matched based on their name. When a single input file contains a variable with a given
name, the output file will contain exactly that variable. When more than one input file
contains a variable with a given name, those variables must be all string or all numeric.
If they are string variables, then the result will have the width of the longest variable
with that name, with narrower values padded on the right with spaces to fill the width.
Variables are matched after renaming with the RENAME subcommand. Thus, RENAME
can be used to resolve conflicts. Only variables in the output file can conflict, so DROP
or KEEP, as described below, can also resolve a conflict.
• The variable label for each output variable is taken from the first specified input file
that has a variable label for that variable, and similarly for value labels and missing
values.
• The file label of the new active dataset (see Section 17.12 [FILE LABEL], page 263) is
that of the first specified FILE that has a file label.
• The documents in the new active dataset (see Section 17.5 [DOCUMENT], page 262)
are the concatenation of all the input files’ documents, in the order in which the FILE
subcommands are specified.
• If all of the input files are weighted on the same variable, then the new active dataset is
weighted on that variable. Otherwise, the new active dataset is not weighted.
The remaining subcommands apply to the output file as a whole, rather than to individual
input files. They must be specified at the end of the command specification, following all
of the FILE and related subcommands. The most important of these subcommands is BY,
which specifies a set of one or more variables that may be used to find corresponding cases
in each of the input files. The variables specified on BY must be present in all of the input
files. Furthermore, if any of the input files are not sorted on the BY variables, then SORT
must be specified for those input files.
Chapter 10: Combining Data Files 95
The variables listed on BY may include (A) or (D) annotations to specify ascending or
descending sort order. See Section 12.8 [SORT CASES], page 124, for more details on this
notation. Adding (A) or (D) to the BY subcommand specification is a pspp extension.
The DROP subcommand can be used to specify a list of variables to exclude from the
output. By contrast, the KEEP subcommand can be used to specify variables to include in
the output; all variables not listed are dropped. DROP and KEEP are executed in left-to-right
order and may be repeated any number of times. DROP and KEEP do not affect variables
created by the IN, FIRST, and LAST subcommands, which are always included in the new
active dataset, but they can be used to drop BY variables.
The FIRST and LAST subcommands are optional. They may only be specified on MATCH
FILES and ADD FILES, and only when BY is used. FIRST and LIST each adds a numeric
variable to the new active dataset, with the name given as the subcommand’s argument
and F1.0 print and write formats. The value of the FIRST variable is 1 in the first output
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.
When any of these commands creates an output case, variables that are only in files that
are not present for the current case are set to the system-missing value for numeric variables
or spaces for string variables.
These commands may combine any number of files, limited only by the machine’s memory.
When ADD FILES creates an output case, variables that are not part of the input file from
which the case was drawn are set to the system-missing value for numeric variables or spaces
for string variables.
When MATCH FILES creates an output case, variables that are only in files that are not
present for the current case are set to the system-missing value for numeric variables or
spaces for string variables.
10.4 UPDATE
UPDATE
11 Manipulating Variables
Every value in a dataset is associated with a variable. Variables describe what the values
represent and properties of those values, such as the format in which they should be displayed,
whether they are numeric or alphabetic and how missing values should be represented. There
are several utility commands for examining and adjusting variables.
11.1 DISPLAY
The DISPLAY command displays information about the variables in the active dataset. A
variety of different forms of information can be requested. By default, all variables in
the active dataset are displayed. However you can select variables of interest using the
/VARIABLES subcommand.
DISPLAY [SORTED] NAMES [[/VARIABLES=]var list].
DISPLAY [SORTED] INDEX [[/VARIABLES=]var list].
DISPLAY [SORTED] LABELS [[/VARIABLES=]var list].
DISPLAY [SORTED] VARIABLES [[/VARIABLES=]var list].
DISPLAY [SORTED] DICTIONARY [[/VARIABLES=]var list].
DISPLAY [SORTED] SCRATCH [[/VARIABLES=]var list].
DISPLAY [SORTED] ATTRIBUTES [[/VARIABLES=]var list].
DISPLAY [SORTED] @ATTRIBUTES [[/VARIABLES=]var list].
DISPLAY [SORTED] VECTORS.
The following keywords primarily cause information about variables to be displayed.
With these keywords, by default information is displayed about all variable in the active
dataset, in the order that variables occur in the active dataset dictionary. The SORTED
keyword causes output to be sorted alphabetically by variable name.
NAMES The variables’ names are displayed.
INDEX The variables’ names are displayed along with a value describing their position
within the active dataset dictionary.
LABELS Variable names, positions, and variable labels are displayed.
VARIABLES
Variable names, positions, print and write formats, and missing values are
displayed.
DICTIONARY
Variable names, positions, print and write formats, missing values, variable
labels, and value labels are displayed.
SCRATCH
Variable names are displayed, for scratch variables only (see Section 6.7.5 [Scratch
Variables], page 41).
ATTRIBUTES
@ATTRIBUTES
Datafile and variable attributes are displayed. The first form of the command
omits those attributes whose names begin with @ or $@. In the second for, all
datafile and variable attributes are displayed.
Chapter 11: Manipulating Variables 99
With the VECTOR keyword, DISPLAY lists all the currently declared vectors. If the SORTED
keyword is given, the vectors are listed in alphabetical order; otherwise, they are listed in
textual order of definition within the pspp syntax file.
For related commands, see Section 17.6 [DISPLAY DOCUMENTS], page 262, and
Section 17.7 [DISPLAY FILE LABEL], page 262.
11.2 NUMERIC
NUMERIC explicitly declares new numeric variables, optionally setting their output formats.
NUMERIC var list [(fmt spec)] [/var list [(fmt spec)]]. . .
Specify the names of the new numeric variables as var list. If you wish to set the variables’
output formats, follow their names by an output format specification in parentheses (see
Section 6.7.4 [Input and Output Formats], page 32); otherwise, the default is F8.2.
Variables created with NUMERIC are initialized to the system-missing value.
11.3 STRING
STRING creates new string variables.
STRING var list (fmt spec) [/var list (fmt spec)] [. . . ].
Specify a list of names for the variable you want to create, followed by the desired
output format specification in parentheses (see Section 6.7.4 [Input and Output Formats],
page 32). Variable widths are implicitly derived from the specified output formats. The
created variables will be initialized to spaces.
If you want to create several variables with distinct output formats, you can either use
two or more separate STRING commands, or you can specify further variable list and format
specification pairs, each separated from the previous by a slash (‘/’).
The following example is one way to create three string variables; Two of the variables
have format A24 and the other A80:
STRING firstname lastname (A24) / address (A80).
Here is another way to achieve the same result:
STRING firstname lastname (A24).
STRING address (A80).
. . . and here is yet another way:
STRING firstname (A24).
STRING lastname (A24).
STRING address (A80).
parenthesized groups of variables may be specified. When the old and new variable names
contain only a single variable name, the parentheses are optional.
RENAME VARIABLES takes effect immediately. It does not cause the data to be read.
RENAME VARIABLES may not be specified following TEMPORARY (see Section 13.6 [TEMPO-
RARY], page 133).
ATTRIBUTE name
Sorts variables according to the first value of their name attribute. Variables
without attribute are sorted first. See Section 11.14 [VARIABLE ATTRIBUTE],
page 103.
Only one sort criterion can be specified. The sort is “stable,” so to sort on multiple
criteria one may perform multiple sorts. For example, the following will sort primarily based
on alignment, with variables that have the same alignment ordered based on display width:
SORT VARIABLES BY COLUMNS.
SORT VARIABLES BY ALIGNMENT.
Specify (D) to reverse the sort order.
11.10 FORMATS
FORMATS var list (fmt spec) [var list (fmt spec)]. . . .
FORMATS set both print and write formats for the specified variables to the specified
format specification. See Section 6.7.4 [Input and Output Formats], page 32.
Specify a list of variables followed by a format specification in parentheses. The print and
write formats of the specified variables will be changed. All of the variables listed together
must have the same type and, for string variables, the same width.
Additional lists of variables and formats may be included following the first one.
FORMATS takes effect immediately. It is not affected by conditional and looping structures
such as DO IF or LOOP.
desired value, in parentheses, as a quoted string. The specified attributes are then added
or modified in the variables specified on VARIABLES. Attribute names that begin with $
are reserved for pspp’s internal use, and attribute names that begin with @ or $@ are not
displayed by most pspp commands that display other attributes. Other attribute names are
not treated specially.
Attributes may also be organized into arrays. To assign to an array element, add an
integer array index enclosed in square brackets ([ and ]) between the attribute name and
value. Array indexes start at 1, not 0. An attribute array that has a single element (number
1) is not distinguished from a non-array attribute.
Use the DELETE subcommand to delete an attribute from the variable specified on
VARIABLES. Specify an attribute name by itself to delete an entire attribute, including all
array elements for attribute arrays. Specify an attribute name followed by an array index
in square brackets to delete a single element of an attribute array. In the latter case, all
the array elements numbered higher than the deleted element are shifted down, filling the
vacated position.
To associate custom attributes with the entire active dataset, instead of with particular
variables, use DATAFILE ATTRIBUTE (see Section 8.3 [DATAFILE ATTRIBUTE], page 62)
instead.
VARIABLE ATTRIBUTE takes effect immediately. It is not affected by conditional and
looping structures such as DO IF or LOOP.
11.19 VECTOR
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. The variables must be all
numeric or all string, and string variables must 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 create variables named vec1 through veccount.
By default, the new variables are numeric with 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. With a string format such as A8, the variables will be string variables;
with a numeric format, they will be numeric. Variable names including the 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 Section 6.7.5 [Scratch Variables], page 41).
Variables within a vector may be referenced in expressions using vector(index) syntax.
Chapter 11: Manipulating Variables 106
11.20 MRSETS
MRSETS creates, modifies, deletes, and displays multiple response sets. A multiple response
set is a set of variables that represent multiple responses to a survey question.
Multiple responses are represented in one of the two following ways:
• A multiple dichotomy set is analogous to a survey question with a set of checkboxes.
Each variable in the set is treated in a Boolean fashion: one value (the "counted value")
means that the box was checked, and any other value means that it was not.
• A multiple category set represents a survey question where the respondent is instructed
to list up to n choices. Each variable represents one of the responses.
MRSETS
/MDGROUP NAME=name VARIABLES=var list VALUE=value
[CATEGORYLABELS={VARLABELS,COUNTEDVALUES}]
[{LABEL=’label’,LABELSOURCE=VARLABEL}]
/DELETE NAME={[names],ALL}
/DISPLAY NAME={[names],ALL}
Any number of subcommands may be specified in any order.
The MDGROUP subcommand creates a new multiple dichotomy set or replaces an existing
multiple response set. The NAME, VARIABLES, and VALUE specifications are required. The
others are optional:
• NAME specifies the name used in syntax for the new multiple dichotomy set. The name
must begin with ‘$’; it must otherwise follow the rules for identifiers (see Section 6.1
[Tokens], page 25).
• VARIABLES specifies the variables that belong to the set. At least two variables must be
specified. The variables must be all string or all numeric.
• VALUE specifies the counted value. If the variables are numeric, the value must be an
integer. If the variables are strings, then the value must be a string that is no longer
than the shortest of the variables in the set (ignoring trailing spaces).
• CATEGORYLABELS optionally specifies the source of the labels for each category in the
set:
− VARLABELS, the default, uses variable labels or, for variables without variable labels,
variable names. pspp warns if two variables have the same variable label, since
these categories cannot be distinguished in output.
− COUNTEDVALUES instead uses each variable’s value label for the counted value. pspp
warns if two variables have the same value label for the counted value or if one of
the variables lacks a value label, since such categories cannot be distinguished in
output.
• LABEL optionally specifies a label for the multiple response set. If neither LABEL nor
LABELSOURCE=VARLABEL is specified, the set is unlabeled.
• LABELSOURCE=VARLABEL draws the multiple response set’s label from the first
variable label among the variables in the set; if none of the variables has a label,
Chapter 11: Manipulating Variables 107
the name of the first variable is used. LABELSOURCE=VARLABEL must be used with
CATEGORYLABELS=COUNTEDVALUES. It is mutually exclusive with LABEL.
The MCGROUP subcommand creates a new multiple category set or replaces an existing
multiple response set. The NAME and VARIABLES specifications are required, and LABEL is
optional. Their meanings are as described above in MDGROUP. pspp warns if two variables in
the set have different value labels for a single value, since each of the variables in the set
should have the same possible categories.
The DELETE subcommand deletes multiple response groups. A list of groups may be
named within a set of required square brackets, or ALL may be used to delete all groups.
The DISPLAY subcommand displays information about defined multiple response sets. Its
syntax is the same as the DELETE subcommand.
Multiple response sets are saved to and read from system files by, e.g., the SAVE and GET
command. Otherwise, multiple response sets are currently used only by third party software.
11.21 LEAVE
LEAVE prevents the specified variables from being reinitialized whenever a new case is
processed.
LEAVE var list.
Normally, when a data file is processed, every variable in the active dataset 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.
108
12 Data transformations
The pspp procedures examined in this chapter manipulate data and prepare the active
dataset for later analyses. They do not produce output, as a rule.
12.1 AGGREGATE
AGGREGATE
[OUTFILE={*,’file name’,file handle} [MODE={REPLACE,ADDVARIABLES}]]
[/MISSING=COLUMNWISE]
[/PRESORTED]
[/DOCUMENT]
[/BREAK=var list]
/dest var[’label’]. . . =agr func(src vars[, args]. . . ). . .
AGGREGATE summarizes groups of cases into single cases. It divides cases into groups that
have the same values for one or more variables called break variables. Several functions are
available for summarizing case contents.
The AGGREGATE syntax consists of subcommands to control its behavior, all of which are
optional, followed by one or more destination variable assigments, each of which uses an
aggregation function to define how it is calculated.
The OUTFILE subcommand, which must be first, names the destination for AGGREGATE
output. It may name a system file by file name or file handle (see Section 6.9 [File Handles],
page 42), a dataset by its name (see Section 6.7 [Datasets], page 29), or ‘*’ to replace the
active dataset. AGGREGATE writes its output to this file.
With OUTFILE=* only, MODE may be specified immediately afterward with the value
ADDVARIABLES or REPLACE:
• With REPLACE, the default, the active dataset is replaced by a new dataset which
contains just the break variables and the destination varibles. The new file contains as
many cases as there are unique combinations of the break variables.
• With ADDVARIABLES, the destination variables are added to those in the existing active
dataset. Cases that have the same combination of values in their break variables
receive identical values for the destination variables. The number of cases in the active
dataset remains unchanged. The data must be sorted on the break variables, that is,
ADDVARIABLES implies PRESORTED
If OUTFILE is omitted, AGGREGATE acts as if OUTFILE=* MODE=ADDVARIABLES were speci-
fied.
By default, AGGREGATE first sorts the data on the break variables. If the active dataset
is already sorted or grouped by the break variables, specify PRESORTED to save time. With
MODE=ADDVARIABLES, the data must be pre-sorted.
Specify DOCUMENT to copy the documents from the active dataset into the aggregate file
(see Section 17.5 [DOCUMENT], page 262). Otherwise, the aggregate file does not contain
any documents, even if the aggregate file replaces the active dataset.
Normally, AGGREGATE produces a non-missing value whenever there is enough non-missing
data for the aggregation function in use, that is, just one non-missing value or, for the SD
Chapter 12: Data transformations 109
FIRST(var_name...)
LAST(var_name...)
First or last non-missing value, respectively, in break group. The aggregation
variable receives the complete dictionary information from the source variable.
The sort performed by AGGREGATE (and by SORT CASES) is stable. This means
that the first (or last) case with particular values for the break variables before
sorting is also the first (or last) case in that break group after sorting.
MIN(var_name...)
MAX(var_name...)
Minimum or maximum value, respectively. The aggregation variable receives
the complete dictionary information from the source variable.
N(var_name...)
NMISS(var_name...)
Total weight of non-missing or missing values, respectively. The default format
is F7.0 if weighting is not enabled, F8.2 if it is (see Section 13.7 [WEIGHT],
page 134).
NU(var_name...)
NUMISS(var_name...)
Count of non-missing or missing values, respectively, ignoring case weights. The
default format is F7.0.
PGT(var_name..., value)
PLT(var_name..., value)
PIN(var_name..., low, high)
POUT(var_name..., low, high)
Percentage between 0 and 100 of values greater than or less than VALUE or
inside or outside the closed range [low,high], respectively. The default format is
F5.1.
N Total weight of cases aggregated to form this group. The default format is F7.0
if weighting is not enabled, F8.2 if it is (see Section 13.7 [WEIGHT], page 134).
NU Count of cases aggregated to form this group, ignoring case weights. The default
format is F7.0.
GET FILE="personnel.sav".
AGGREGATE OUTFILE=* MODE=REPLACE
/BREAK=occupation
/occ_mean_salary=MEAN(salary)
/occ_median_salary=MEDIAN(salary)
/occ_std_dev_salary=SD(salary).
LIST.
Example 12.1: Calculating aggregated statistics from the personnel.sav file.
Since we chose the ‘MODE=REPLACE’ option, in Results 12.1 cases for the individual persons
are no longer present. They have each been replaced by a single case per aggregated value.
Data List
+------------------+---------------+-----------------+------------------+
| occupation |occ_mean_salary|occ_median_salary|occ_std_dev_salary|
+------------------+---------------+-----------------+------------------+
|Artist | 37836.18| 34712.50| 7631.48|
|Baker | 45075.20| 45075.20| 4411.21|
|Barrister | 39504.00| 39504.00| .|
|Carpenter | 39349.11| 36190.04| 7453.40|
|Cleaner | 41142.50| 39647.49| 14378.98|
|Cook | 40357.79| 43194.00| 11064.51|
|Manager | 46452.14| 45657.56| 6901.69|
|Mathematician | 34531.06| 34763.06| 5267.68|
|Painter | 45063.55| 45063.55| 15159.67|
|Payload Specialist| 34355.72| 34355.72| .|
|Plumber | 40413.91| 40410.00| 4726.05|
|Scientist | 36687.07| 36803.83| 10873.54|
|Scrientist | 42530.65| 42530.65| .|
|Tailor | 34586.79| 34586.79| 3728.98|
+------------------+---------------+-----------------+------------------+
Results 12.1: Aggregated mean, median and standard deviation per occupation.
Note that some values for the standard deviation are blank. This is because there is only
one case with the respective occupation.
12.2 AUTORECODE
AUTORECODE VARIABLES=src vars INTO dest vars
[ /DESCENDING ]
[ /PRINT ]
[ /GROUP ]
[ /BLANK = {VALID, MISSING} ]
The AUTORECODE procedure considers the n values that a variable takes on and maps
them onto values 1. . . n on a new numeric variable.
Chapter 12: Data transformations 112
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.
AUTORECODE ordinarily assigns each increasing non-missing value of a source variable (for
a string, this is based on character code comparisons) to consecutive values of its target
variable. For example, the smallest non-missing value of the source variable is recoded to
value 1, the next smallest to 2, and so on. If the source variable has user-missing values,
they are recoded to consecutive values just above the non-missing values. For example, if a
source variables has seven distinct non-missing values, then the smallest missing value would
be recoded to 8, the next smallest to 9, and so on.
Use DESCENDING to reverse the sort order for non-missing values, so that the largest
non-missing value is recoded to 1, the second-largest to 2, and so on. Even with DESCENDING,
user-missing values are still recoded in ascending order just above the non-missing values.
The system-missing value is always recoded into the system-missing variable in target
variables.
If a source value has a value label, then that value label is retained for the new value in
the target variable. Otherwise, the source value itself becomes each new value’s label.
Variable labels are copied from the source to target variables.
PRINT is currently ignored.
The GROUP subcommand is relevant only if more than one variable is to be recoded. It
causes a single mapping between source and target values to be used, instead of one map
per variable. With GROUP, user-missing values are taken from the first source variable that
has any user-missing values.
If /BLANK=MISSING is given, then string variables which contain only whitespace are
recoded as SYSMIS. If /BLANK=VALID is specified then they are allocated a value like any
other. /BLANK is not relevant to numeric values. /BLANK=VALID is the default.
AUTORECODE is a procedure. It causes the data to be read.
1
One must use care when correcting such data input errors rather than msimply marking them as missing.
For example, if an occupation has been entered “Barister”, did the person mean “Barrister” or did she
mean “Barista”?
Chapter 12: Data transformations 113
get file=’personnel.sav’.
autorecode
variables = occupation into occ
/blank = missing.
Example 12.2: Changing a string variable to a numeric variable using AUTORECODE after
correcting a data entry error
Screenshot 12.1: Autorecode dialog box set to recode occupation to occ
Notice in Result 12.1, how the new variable has been automatically allocated value labels
which correspond to the strings of the old variable. This means that in future analyses the
descriptive strings are reported instead of the numeric values.
Chapter 12: Data transformations 114
Variables
+----------+--------+--------------+-----+-----+---------+----------+---------+
| | | Measurement | | | | Print | Write |
|Name |Position| Level | Role|Width|Alignment| Format | Format |
+----------+--------+--------------+-----+-----+---------+----------+---------+
|occupation| 6|Unknown |Input| 8|Right |F2.0 |F2.0 |
+----------+--------+--------------+-----+-----+---------+----------+---------+
Value Labels
+---------------+------------------+
|Variable Value | Label |
+---------------+------------------+
|occupation 1 |Artist |
| 2 |Baker |
| 3 |Barrister |
| 4 |Carpenter |
| 5 |Cleaner |
| 6 |Cook |
| 7 |Manager |
| 8 |Mathematician |
| 9 |Painter |
| 10 |Payload Specialist|
| 11 |Plumber |
| 12 |Scientist |
| 13 |Tailor |
+---------------+------------------+
Result 12.1: The properties of the occupation variable following AUTORECODE
12.3 COMPUTE
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 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 Section 11.19
[VECTOR], page 105). In this case, an expression index must be specified in parentheses
following the vector name. The expression index 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 Section 11.21 [LEAVE],
page 107) 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 dataset to be read.
Chapter 12: Data transformations 115
get file=’physiology.sav’.
Example 12.3: Computing the body mass index from weight and height
Example 12.3 shows how you can use COMPUTE to generate a new variable called bmi and
have every case’s value calculated from the existing values of weight and height. It also
shows how you can add a label to this new variable (see Section 11.7 [VARIABLE LABELS],
page 101), so that a more descriptive label appears in subsequent analyses, and this can be
seen in the ouput from the DESCRIPTIVES command in Results 12.2.
Screenshot 12.2: Using the dialog box to generate a new variable and compute its values
The expression which follows the ‘=’ sign can be as complicated as necessary. See Chapter 7
[Expressions], page 44, for a precise description of the language accepted. Normally it is
easiest to enter the code directly, however there is a dialog box available if desired. This is
2
Since BMI is a quantity with a ratio scale and has units, the term “index” is a misnomer, but that is
what it is called.
Chapter 12: Data transformations 116
illustrated in Screenshot 12.2. One advantage is that it offers a list of mathematical functions
which can be selected and pasted into the expression.
Descriptive Statistics
+---------------------+--+-------+-------+-------+-------+
| | N| Mean |Std Dev|Minimum|Maximum|
+---------------------+--+-------+-------+-------+-------+
|Weight in kilograms |40| 72.12| 26.70| -55.6| 92.1|
|Height in millimeters|40|1677.12| 262.87| 179| 1903|
|Body Mass Index |40| 67.46| 274.08| -21.62|1756.82|
|Valid N (listwise) |40| | | | |
|Missing N (listwise) | 0| | | | |
+---------------------+--+-------+-------+-------+-------+
Results 12.2: An analysis which includes bmi in its results
12.4 COUNT
COUNT var name = var . . . (value . . . )
[/var name = var . . . (value . . . )]. . .
get file="hotel.sav".
Example 12.4: Counting low values to responses v1, v2 and v3
In Example 12.4 the COUNT transformation creates a new variable, low counts and its
values are shown using the LIST command.
If using the graphic user interface, a two step process must be used to set up the COUNT
transformation. The first dialog box (Screenshot 12.3) provides for the variables to be chosen.
Then, one must click on the button marked “Define Values...” to reveal the dialog box for
selecting the values to count.
Screenshot 12.3: The variables v1, v2 and v3 selected, ready to define values to count
In this dialog box, you must select the values you wish to count — in this case all values
up to and including 2 — as shown in Screenshot 12.4 and click “Add”. As many ranges or
may be added as you desire. When all desired ranges have been added click “Continue”.
Chapter 12: Data transformations 118
Screenshot 12.4: Count “Define Values” dialog with ‘lowest thru 2’ selected
In Result 12.2 we can see the values of low counts after the COUNT transformation has
completed. The first value is 1, because there is only one variable amoung v1, v2 and 3
which has a value of 2 or less. The second value is 2, because both v1 and v2 are 2 or less.
Chapter 12: Data transformations 119
Data List
+--+--+--+----------+
|v1|v2|v3|low_counts|
+--+--+--+----------+
| 4| 2| 3| 1.00|
| 1| 1| 4| 2.00|
| 4| 2| 2| 2.00|
| 3| 1| 3| 1.00|
| 5| 3| 1| 1.00|
| 2| 2| 5| 2.00|
| 3| 2| 4| 1.00|
| 1| 4| 5| 1.00|
| 3| 2| 3| 1.00|
| 2| 5| 4| 1.00|
| 4| 2| 2| 2.00|
| 2| 1| 4| 2.00|
| 1| 2| 5| 2.00|
| 2| 3| 3| 1.00|
| 4| 1| 1| 2.00|
| 1| 1| 5| 2.00|
| 1| 5| 5| 1.00|
+--+--+--+----------+
Result 12.2: The values of v1, v2, v3 and low counts after the COUNT transformation has
run
12.5 FLIP
FLIP /VARIABLES=var list /NEWNAMES=var name.
FLIP transposes rows and columns in the active dataset. It causes cases to be swapped
with variables, and vice versa.
All variables in the transposed active dataset are numeric. String variables take on the
system-missing value in the transposed file.
N 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 FLIP is called again on this dataset, the
CASE LBL variable can be passed to the NEWNAMES subcommand to recreate the original
variable names.
Chapter 12: Data transformations 120
FLIP honors N OF CASES (see Section 13.2 [N OF CASES], page 128). It ignores TEMPORARY
(see Section 13.6 [TEMPORARY], page 133), so that “temporary” transformations become
permanent.
data list notable list /heading (a16) v1 v2 v3 v4 v5 v6
begin data.
date-of-birth 1970 1989 2001 1966 1976 1982
sex 1 0 0 1 0 1
score 10 10 9 3 8 9
end data.
Example 12.5: Using FLIP to exchange variables and cases in a dataset
As you can see in Results 12.3 before the FLIP command has run there are seven variables
(six containing data and one for the heading) and three cases. Afterwards there are four
variables (one per case, plus the CASE LBL variable) and six cases. You can delete the
CASE LBL variable (see Section 11.6 [DELETE VARIABLES], page 101) if you don’t need
it.
Chapter 12: Data transformations 121
Before FLIP:
Variables
+-------+--------+------------+------------+
|Name |Position|Print Format|Write Format|
+-------+--------+------------+------------+
|heading| 1|A16 |A16 |
|v1 | 2|F8.2 |F8.2 |
|v2 | 3|F8.2 |F8.2 |
|v3 | 4|F8.2 |F8.2 |
|v4 | 5|F8.2 |F8.2 |
|v5 | 6|F8.2 |F8.2 |
|v6 | 7|F8.2 |F8.2 |
+-------+--------+------------+------------+
Data List
+-------------+-------+-------+-------+-------+-------+-------+
| heading | v1 | v2 | v3 | v4 | v5 | v6 |
+-------------+-------+-------+-------+-------+-------+-------+
|date-of-birth|1970.00|1989.00|2001.00|1966.00|1976.00|1982.00|
|sex | 1.00| .00| .00| 1.00| .00| 1.00|
|score | 10.00| 10.00| 9.00| 3.00| 8.00| 9.00|
+-------------+-------+-------+-------+-------+-------+-------+
After FLIP:
Variables
+-------------+--------+------------+------------+
|Name |Position|Print Format|Write Format|
+-------------+--------+------------+------------+
|CASE_LBL | 1|A8 |A8 |
|date_of_birth| 2|F8.2 |F8.2 |
|sex | 3|F8.2 |F8.2 |
|score | 4|F8.2 |F8.2 |
+-------------+--------+------------+------------+
Data List
+--------+-------------+----+-----+
|CASE_LBL|date_of_birth| sex|score|
+--------+-------------+----+-----+
|v1 | 1970.00|1.00|10.00|
|v2 | 1989.00| .00|10.00|
|v3 | 2001.00| .00| 9.00|
|v4 | 1966.00|1.00| 3.00|
|v5 | 1976.00| .00| 8.00|
|v6 | 1982.00|1.00| 9.00|
+--------+-------------+----+-----+
Results 12.3: The results of using FLIP to exchange variables and cases in a dataset
12.6 IF
IF condition variable=expression.
or
IF condition vector(index)=expression.
Chapter 12: Data transformations 122
12.7 RECODE
The RECODE command is used to transform existing values into other, user specified values.
The general form is:
RECODE src vars
(src value src value . . . = dest value)
(src value src value . . . = dest value)
(src value src value . . . = dest value) . . .
[INTO dest vars].
Following the RECODE keyword itself comes src vars which is a list of variables whose
values are to be transformed. These variables may be string variables or they may be
numeric. However the list must be homogeneous; you may not mix string variables and
numeric variables in the same recoding.
After the list of source variables, there should be one or more mappings. Each mapping
is enclosed in parentheses, and contains the source values and a destination value separated
by a single ‘=’. The source values are used to specify the values in the dataset which need to
change, and the destination value specifies the new value to which they should be changed.
Each src value may take one of the following forms:
number If the source variables are numeric then src value may be a literal number.
string If the source variables are string variables then src value may be a literal string
(like all strings, enclosed in single or double quotes).
num1 THRU num2
This form is valid only when the source variables are numeric. It specifies all
values in the range between num1 and num2, including both endpoints of the
range. By convention, num1 should be less than num2. Open-ended ranges may
be specified using ‘LO’ or ‘LOWEST’ for num1 or ‘HI’ or ‘HIGHEST’ for num2.
Chapter 12: Data transformations 123
‘MISSING’ The literal keyword ‘MISSING’ matches both system missing and user missing
values. It is valid for both numeric and string variables.
‘SYSMIS’ The literal keyword ‘SYSMIS’ matches system missing values. It is valid for both
numeric variables only.
‘ELSE’ The ‘ELSE’ keyword may be used to match any values which are not matched
by any other src value appearing in the command. If this keyword appears, it
should be used in the last mapping of the command.
After the source variables comes an ‘=’ and then the dest value. The dest value may
take any of the following forms:
number A literal numeric value to which the source values should be changed. This
implies the destination variable must be numeric.
string A literal string value (enclosed in quotation marks) to which the source values
should be changed. This implies the destination variable must be a string
variable.
‘SYSMIS’ The keyword ‘SYSMIS’ changes the value to the system missing value. This
implies the destination variable must be numeric.
‘COPY’ The special keyword ‘COPY’ means that the source value should not be modified,
but copied directly to the destination value. This is meaningful only if ‘INTO
dest_vars’ is specified.
Mappings are considered from left to right. Therefore, if a value is matched by a src value
from more than one mapping, the first (leftmost) mapping which matches is considered.
Any subsequent matches are ignored.
The clause ‘INTO dest_vars’ is optional. The behaviour of the command is slightly
different depending on whether it appears or not.
If ‘INTO dest_vars’ does not appear, then values are recoded “in place”. This means
that the recoded values are written back to the source variables from whence the original
values came. In this case, the dest value for every mapping must imply a value which has
the same type as the src value. For example, if the source value is a string value, it is not
permissible for dest value to be ‘SYSMIS’ or another forms which implies a numeric result.
It is also not permissible for dest value to be longer than the width of the source variable.
The following example two numeric variables x and y are recoded in place. Zero is
recoded to 99, the values 1 to 10 inclusive are unchanged, values 1000 and higher are recoded
to the system-missing value and all other values are changed to 999:
recode x y
(0 = 99)
(1 THRU 10 = COPY)
(1000 THRU HIGHEST = SYSMIS)
(ELSE = 999).
If ‘INTO dest_vars’ is given, then recoded values are written into the variables specified
in dest vars, which must therefore contain a list of valid variable names. The number of
variables in dest vars must be the same as the number of variables in src vars and the
respective order of the variables in dest vars corresponds to the order of src vars. That
Chapter 12: Data transformations 124
is to say, the recoded value whose original value came from the nth variable in src vars
is placed into the nth variable in dest vars. The source variables are unchanged. If any
mapping implies a string as its destination value, then the respective destination variable
must already exist, or have been declared using STRING or another transformation. Numeric
variables however are automatically created if they don’t already exist. The following
example deals with two source variables, a and b which contain string values. Hence there
are two destination variables v1 and v2. Any cases where a or b contain the values ‘apple’,
‘pear’ or ‘pomegranate’ result in v1 or v2 being filled with the string ‘fruit’ whilst cases
with ‘tomato’, ‘lettuce’ or ‘carrot’ result in ‘vegetable’. Any other values produce the
result ‘unknown’:
string v1 (a20).
string v2 (a20).
recode a b
("apple" "pear" "pomegranate" = "fruit")
("tomato" "lettuce" "carrot" = "vegetable")
(ELSE = "unknown")
into v1 v2.
There is one very special mapping, not mentioned above. If the source variable is a string
variable then a mapping may be specified as ‘(CONVERT)’. This mapping, if it appears must
be the last mapping given and the ‘INTO dest_vars’ clause must also be given and must not
refer to a string variable. ‘CONVERT’ causes a number specified as a string to be converted to
a numeric value. For example it converts the string ‘"3"’ into the numeric value 3 (note that
it does not convert ‘three’ into 3). If the string cannot be parsed as a number, then the
system-missing value is assigned instead. In the following example, cases where the value of
x (a string variable) is the empty string, are recoded to 999 and all others are converted to
the numeric equivalent of the input value. The results are placed into the numeric variable
y:
recode x
("" = 999)
(convert)
into y.
It is possible to specify multiple recodings on a single command. Introduce additional
recodings with a slash (‘/’) to separate them from the previous recodings:
recode
a (2 = 22) (else = 99)
/b (1 = 3) into z
.
Here we have two recodings. The first affects the source variable a and recodes in-place the
value 2 into 22 and all other values to 99. The second recoding copies the values of b into
the variable z, changing any instances of 1 into 3.
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. This means records which have equal
values of the sort variables have the same relative order before and after sorting. Thus,
re-sorting an already sorted file does not affect the ordering of cases.
SORT CASES attempts to sort the entire active dataset in main memory. If workspace is
exhausted, it falls back to a merge sort algorithm which creates numerous temporary files.
get file=’physiology.sav’.
sort cases by sex (D) temperature(A).
list.
Example 12.6: Sorting cases by two variables.
In Results 12.4 you can see that all the cases with a sex of ‘1’ (female) appear before
those with a sex of ‘0’ (male). This is because they have been sorted in descending order.
Within each sex, the data is sorted on the temperature variable, this time in ascending
order.
Chapter 12: Data transformations 126
Data List
+---+------+------+-----------+
|sex|height|weight|temperature|
+---+------+------+-----------+
| 1| 1606| 56.1| 34.56|
| 1| 179| 56.3| 35.15|
| 1| 1609| 55.4| 35.46|
| 1| 1606| 56.0| 36.06|
| 1| 1607| 56.3| 36.26|
| 1| 1604| 56.0| 36.57|
| 1| 1604| 56.6| 36.81|
| 1| 1606| 56.3| 36.88|
| 1| 1604| 57.8| 37.32|
| 1| 1598| 55.6| 37.37|
| 1| 1607| 55.9| 37.84|
| 1| 1605| 54.5| 37.86|
| 1| 1603| 56.1| 38.80|
| 1| 1604| 58.1| 38.85|
| 1| 1605| 57.7| 38.98|
| 1| 1709| 55.6| 39.45|
| 1| 1604| -55.6| 39.72|
| 1| 1601| 55.9| 39.90|
| 0| 1799| 90.3| 32.59|
| 0| 1799| 89.0| 33.61|
| 0| 1799| 90.6| 34.04|
| 0| 1801| 90.5| 34.42|
| 0| 1802| 87.7| 35.03|
| 0| 1793| 90.1| 35.11|
| 0| 1801| 92.1| 35.98|
| 0| 1800| 89.5| 36.10|
| 0| 1645| 92.1| 36.68|
| 0| 1698| 90.2| 36.94|
| 0| 1800| 89.6| 37.02|
| 0| 1800| 88.9| 37.03|
| 0| 1801| 88.9| 37.12|
| 0| 1799| 90.4| 37.33|
| 0| 1903| 91.5| 37.52|
| 0| 1799| 90.9| 37.53|
| 0| 1800| 91.0| 37.60|
| 0| 1799| 90.4| 37.68|
| 0| 1801| 91.7| 38.98|
| 0| 1801| 90.9| 39.03|
| 0| 1799| 89.3| 39.77|
| 0| 1884| 88.6| 39.97|
+---+------+------+-----------+
Results 12.4: The physiology.sav file after sorting.
Note that SORT CASES, like all other transformations, affects only the active file. It does
not have any effect upon the physiology.sav file itself. For that, you would have to rewrite
the file using the SAVE command (see Section 9.6 [SAVE], page 87).
When using the graphic user interface, it is often simpler to perform a sort directly from
the data view. To do this, switch to the data view. Select the column corresponding to the
variable by which you want to sort and click button 1 and then click button 3. A popup
menu will appear like that shown in Screenshot 12.5. Select either “Sort Ascending” or
“Sort Descending” from this menu.
Chapter 12: Data transformations 127
Screenshot 12.5: Sorting the data on a single variable height
However, sometimes you will want to sort on two or more variables, and that is not
possible using this method. In this case, you must either use some code or the “Sort Cases”
dialog from the Data menu. Screenshot 12.6 shows the dialog box set up to perform a sort
on both sex and height. Note that the order in which you enter the variables is important.
In this case, the data will be first sorted on sex, and then all cases for which sex is the same
will then be sorted by height.
Screenshot 12.6: Sorting the data on two variables sex and height
128
This chapter documents pspp commands that temporarily or permanently select data records
from the active dataset for analysis.
13.1 FILTER
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.
13.2 N OF CASES
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
Section 13.6 [TEMPORARY], page 133). 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
dataset, 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 both randomly sample approximately half of the active dataset’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.
Chapter 13: Selecting data for analysis 129
13.3 SAMPLE
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
dataset.
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 dataset,
then after SAMPLE k., approximately k*N cases are selected.
The proportion to sample can also be specified in the style SAMPLE m FROM N. With this
style, cases are selected as follows:
1. If N is equal to the number of currently-selected cases in the active dataset, exactly m
cases are selected.
2. If N is greater than the number of currently-selected cases in the active dataset, an
equivalent proportion of cases are selected.
3. If N is less than the number of currently-selected cases in the active, exactly m cases
are selected from the first N cases in the active dataset.
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 Section 13.2 [N OF CASES], page 128).
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.
13.4 SELECT IF
SELECT IF expression.
SELECT IF selects cases for analysis based on the value of expression. Cases not selected
are permanently eliminated from the active dataset, unless TEMPORARY is in effect (see
Section 13.6 [TEMPORARY], page 133).
Specify a boolean expression (see Chapter 7 [Expressions], page 44). If the value of the
expression is true for a particular case, the case is analyzed. If the expression has a false or
missing value, then the case is 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. Once cases have been deleted from
the active dataset using SELECT IF they cannot be re-instated. If you want to be able to
re-instate cases, then use FILTER (see Section 13.1 [FILTER], page 128) instead.
When SELECT IF is specified following TEMPORARY (see Section 13.6 [TEMPORARY],
page 133), the LAG function may not be used (see [LAG], page 55).
in Example 13.1 shows how SELECT IF can be used to limit analysis only to those persons
born after December 31, 1999.
get file = ’personnel.sav’.
Example 13.1: Using SELECT IF to select persons born on or after a certain date.
From Result 13.1 one can see that there are 56 persons listed in the dataset, and 17 of
them were born after December 31, 1999.
Salaries of all personnel
Descriptive Statistics
+------------------------+--+--------+-------+-------+-------+
| | N| Mean |Std Dev|Minimum|Maximum|
+------------------------+--+--------+-------+-------+-------+
|Annual salary before tax|56|40028.97|8721.17|$23,451|$57,044|
|Valid N (listwise) |56| | | | |
|Missing N (listwise) | 0| | | | |
+------------------------+--+--------+-------+-------+-------+
Descriptive Statistics
+------------------------+--+--------+-------+-------+-------+
| | N| Mean |Std Dev|Minimum|Maximum|
+------------------------+--+--------+-------+-------+-------+
|Annual salary before tax|17|31828.59|4454.80|$23,451|$39,504|
|Valid N (listwise) |17| | | | |
|Missing N (listwise) | 0| | | | |
+------------------------+--+--------+-------+-------+-------+
Result 13.1: Salary descriptives before and after the SELECT IF transformation.
Note that the personnel.sav file from which the data were read is unaffected. The
transformation affects only the active file.
When a list of variable names is specified, one of the keywords LAYERED or SEPARATE
may also be specified. With LAYERED, which is the default, the separate analyses for each
group are presented together in a single table. With SEPARATE, each analysis is presented in
a separate table. Not all procedures honor the distinction.
Groups are formed only by adjacent cases. To create a split using a variable where
like values are not adjacent in the working file, first sort the data by that variable (see
Section 12.8 [SORT CASES], page 124).
Specify OFF to disable SPLIT FILE and resume analysis of the entire active dataset as a
single group of data.
When SPLIT FILE is specified after TEMPORARY, it affects only the next procedure (see
Section 13.6 [TEMPORARY], page 133).
get file=’horticulture.sav’.
Example 13.2: Running DESCRIPTIVES on each value of treatment
In Example 13.3 you can see that the table of descriptive statistics appears 3 times
— once for each value of treatment. In this example ‘N’, the number of observations are
identical in all splits. This is because that experiment was deliberately designed that way.
However in general one can expect a different ‘N’ for each split.
1
There are other, possibly better, ways to achieve a similar result using the MEANS or EXAMINE commands.
Chapter 13: Selecting data for analysis 132
Split Values
+---------+-------+
|Variable | Value |
+---------+-------+
|treatment|control|
+---------+-------+
Descriptive Statistics
+--------------------+--+-----+-------+-------+-------+
| | N| Mean|Std Dev|Minimum|Maximum|
+--------------------+--+-----+-------+-------+-------+
|yield |30|51.23| 8.28| 37.86| 68.59|
|Valid N (listwise) |30| | | | |
|Missing N (listwise)| 0| | | | |
+--------------------+--+-----+-------+-------+-------+
Split Values
+---------+------------+
|Variable | Value |
+---------+------------+
|treatment|conventional|
+---------+------------+
Descriptive Statistics
+--------------------+--+-----+-------+-------+-------+
| | N| Mean|Std Dev|Minimum|Maximum|
+--------------------+--+-----+-------+-------+-------+
|yield |30|53.57| 8.92| 36.30| 70.66|
|Valid N (listwise) |30| | | | |
|Missing N (listwise)| 0| | | | |
+--------------------+--+-----+-------+-------+-------+
Split Values
+---------+-----------+
|Variable | Value |
+---------+-----------+
|treatment|traditional|
+---------+-----------+
Descriptive Statistics
+--------------------+--+-----+-------+-------+-------+
| | N| Mean|Std Dev|Minimum|Maximum|
+--------------------+--+-----+-------+-------+-------+
|yield |30|56.87| 8.88| 39.08| 75.93|
|Valid N (listwise) |30| | | | |
|Missing N (listwise)| 0| | | | |
+--------------------+--+-----+-------+-------+-------+
Example 13.3: The results of running DESCRIPTIVES with an active split
Unless TEMPORARY was used, after a split has been defined for a dataset it remains active
until explicitly disabled. In the graphical user interface, the active split variable (if any) is
displayed in the status bar (see Screenshot 13.1. If a dataset is saved to a system file (see
Section 9.6 [SAVE], page 87) whilst a split is active, the split stastus is stored in the file and
will be automatically loaded when that file is loaded.
Chapter 13: Selecting data for analysis 133
Screenshot 13.1: The status bar indicating that the data set is split using the treatment
variable
13.6 TEMPORARY
TEMPORARY.
TEMPORARY is used to make the effects of transformations following its execution temporary.
These transformations affect only the execution of the next procedure or procedure-like
command. Their effects are not be saved to the active dataset.
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.
data list notable /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.
Example 13.4: Running a COMPUTE transformation after TEMPORARY
The data read by the first DESCRIPTIVES procedure are 4, 5, 8, 10.5, 13, 15. The data
read by the second DESCRIPTIVES procedure are 1, 2, 5, 7.5, 10, 12. This is because the
Chapter 13: Selecting data for analysis 134
second COMPUTE transformation has no effect on the second DESCRIPTIVES procedure. You
can check these figures in Result 13.2.
Descriptive Statistics
+--------------------+-+----+-------+-------+-------+
| |N|Mean|Std Dev|Minimum|Maximum|
+--------------------+-+----+-------+-------+-------+
|x |6|9.25| 4.38| 4| 15|
|Valid N (listwise) |6| | | | |
|Missing N (listwise)|0| | | | |
+--------------------+-+----+-------+-------+-------+
Descriptive Statistics
+--------------------+-+----+-------+-------+-------+
| |N|Mean|Std Dev|Minimum|Maximum|
+--------------------+-+----+-------+-------+-------+
|x |6|6.25| 4.38| 1| 12|
|Valid N (listwise) |6| | | | |
|Missing N (listwise)|0| | | | |
+--------------------+-+----+-------+-------+-------+
Result 13.2: The results of running two consecutive DESCRIPTIVES commands after a
temporary transformation
13.7 WEIGHT
WEIGHT BY var name.
WEIGHT OFF.
WEIGHT assigns cases varying weights, changing the frequency distribution of the active
dataset. 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 Section 6.7.5 [Scratch Variables], page 41).
When OFF is specified, subsequent statistical procedures weight all cases equally.
A positive integer weighting factor w on a case yields 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
Section 13.6 [TEMPORARY], page 133).
WEIGHT does not cause cases in the active dataset to be replicated in memory.
data list notable list /item (a16) quantity (f8.0).
begin data
nuts 345
screws 10034
washers 32012
bolts 876
end data.
weight by quantity.
Example 13.5: Setting the weight on the variable quantity
One analysis which most surely would be of interest is the relative amounts or each
item in stock. However without setting a weight variable, FREQUENCIES (see Section 15.2
[FREQUENCIES], page 153) does not tell us what we want to know, since there is only
one case for each stock item. Example 13.6 shows the difference between the weighted and
unweighted frequency tables.
Unweighted frequency table
item
+-------------+---------+-------+-------------+------------------+
| |Frequency|Percent|Valid Percent|Cumulative Percent|
+-------------+---------+-------+-------------+------------------+
|Valid bolts | 1| 25.0%| 25.0%| 25.0%|
| nuts | 1| 25.0%| 25.0%| 50.0%|
| screws | 1| 25.0%| 25.0%| 75.0%|
| washers| 1| 25.0%| 25.0%| 100.0%|
+-------------+---------+-------+-------------+------------------+
|Total | 4| 100.0%| | |
+-------------+---------+-------+-------------+------------------+
item
+-------------+---------+-------+-------------+------------------+
| |Frequency|Percent|Valid Percent|Cumulative Percent|
+-------------+---------+-------+-------------+------------------+
|Valid washers| 32012| 74.0%| 74.0%| 74.0%|
| screws | 10034| 23.2%| 23.2%| 97.2%|
| bolts | 876| 2.0%| 2.0%| 99.2%|
| nuts | 345| .8%| .8%| 100.0%|
+-------------+---------+-------+-------------+------------------+
|Total | 43267| 100.0%| | |
+-------------+---------+-------+-------------+------------------+
Example 13.6: Weighted and unweighted frequency tables of items
136
14.1 BREAK
BREAK.
BREAK terminates execution of the innermost currently executing LOOP construct.
BREAK is allowed only inside LOOP. . . END LOOP. See Section 14.5 [LOOP], page 149, for
more details.
14.2 DEFINE
14.2.1 Overview
DEFINE macro name([argument[/argument]. . . ])
. . . body . . .
!ENDDEFINE.
Each argument takes the following form:
{!arg name= | !POSITIONAL}
[!DEFAULT(default)]
[!NOEXPAND]
{!TOKENS(count) | !CHAREND(’token’) | !ENCLOSE(’start’ | ’end ’) | !CMDEND}
The following directives may be used within body:
!OFFEXPAND
!ONEXPAND
The following functions may be used within the body:
!BLANKS(count)
!CONCAT(arg . . . )
!EVAL(arg)
!HEAD(arg)
!INDEX(haystack , needle)
!LENGTH(arg)
!NULL
!QUOTE(arg)
!SUBSTR(arg, start[, count])
!TAIL(arg)
!UNQUOTE(arg)
!UPCASE(arg)
The body may also include the following constructs:
!IF (condition) !THEN true-expansion !ENDIF
!IF (condition) !THEN true-expansion !ELSE false-expansion !ENDIF
body
!DOEND
!DO !var !IN (expression)
body
!DOEND
14.2.2 Introduction
The DEFINE command creates a macro, which is a name for a fragment of PSPP syntax
called the macro’s body. Following the DEFINE command, syntax may call the macro by
name any number of times. Each call substitutes, or expands, the macro’s body in place of
the call, as if the body had been written in its place.
The following syntax defines a macro named !vars that expands to the variable names
v1 v2 v3. The macro’s name begins with ‘!’, which is optional for macro names. The ()
following the macro name are required:
DEFINE !vars()
v1 v2 v3
!ENDDEFINE.
Here are two ways that !vars might be called given the preceding definition:
DESCRIPTIVES !vars.
FREQUENCIES /VARIABLES=!vars.
With macro expansion, the above calls are equivalent to the following:
DESCRIPTIVES v1 v2 v3.
FREQUENCIES /VARIABLES=v1 v2 v3.
The !vars macro expands to a fixed body. Macros may have more sophisticated contents:
• Macro arguments that are substituted into the body whenever they are named. The
values of a macro’s arguments are specified each time it is called. See Section 14.2.4
[Macro Arguments], page 138.
• Macro functions, expanded when the macro is called. See Section 14.2.6 [Macro
Functions], page 141.
• !IF constructs, for conditional expansion. See Section 14.2.8 [Macro Conditional
Expansion], page 145.
• Two forms of !DO construct, for looping over a numerical range or a collection of tokens.
See Section 14.2.9 [Macro Loops], page 145.
• !LET constructs, for assigning to macro variables. See Section 14.2.10 [Macro Variable
Assignment], page 146.
Many identifiers associated with macros begin with ‘!’, a character not normally allowed
in identifiers. These identifiers are reserved only for use with macros, which helps keep them
from being confused with other kinds of identifiers.
The following sections provide more details on macro syntax and semantics.
Chapter 14: Conditional and Looping Constructs 138
• A positional argument has a required value that follows the macro’s name. Use the
!POSITIONAL keyword to declare a positional argument.
When a macro is called, the positional argument values appear in the same order as
their definitions, before any keyword argument values.
References to a positional argument in a macro body are numbered: !1 is the first
positional argument, !2 the second, and so on. In addition, !* expands to all of the
positional arguments’ values, separated by spaces.
The following example uses a positional argument:
DEFINE !analyze(!POSITIONAL !CMDEND)
DESCRIPTIVES !1.
FREQUENCIES /VARIABLES=!1.
!ENDDEFINE.
!analyze v1 v2 v3.
!analyze v4 v5.
• A keyword argument has a name. In the macro call, its value is specified with the
syntax name=value. The names allow keyword argument values to take any order in
the call.
In declaration and calls, a keyword argument’s name may not begin with ‘!’, but
references to it in the macro body do start with a leading ‘!’.
The following example uses a keyword argument that defaults to ALL if the argument
is not assigned a value:
DEFINE !analyze_kw(vars=!DEFAULT(ALL) !CMDEND)
DESCRIPTIVES !vars.
FREQUENCIES /VARIABLES=!vars.
!ENDDEFINE.
DESCRIPTIVES !1.
FREQUENCIES /VARIABLES=!1.
!ENDDEFINE.
!analyze_one_var v1.
!CHAREND(’token’)
Any number of tokens up to token, which should be an operator or punctuator
token such as ‘/’ or ‘+’. The token does not become part of the value.
With the following variant of !analyze_kw, the variables must be following by
‘/’:
DEFINE !analyze_parens(vars=!CHARNED(’/’))
DESCRIPTIVES !vars.
FREQUENCIES /VARIABLES=!vars.
!ENDDEFINE.
declaration suppresses this expansion. See Section 14.2.5 [Controlling Macro Expansion],
page 141.
In the examples below, ‘_’ stands in for a space to make the results visible.
!BLANKS(0) 7→ empty
!BLANKS(1) 7 → _
!BLANKS(2) 7 → __
!QUOTE(!BLANKS(5)) 7 → ’_____’
!HEAD(!NULL) 7→ empty
!HEAD(’’) 7 → empty
!TAIL(’a b c’) 7→ b c
!TAIL(’a’) 7 → empty
!TAIL(!NULL) 7 → empty
!TAIL(’’) 7 → empty
!UNQUOTE(123.0) 7→ 123.0
!UNQUOTE( 123 ) 7→ 123
!UNQUOTE(’a b c’) 7→ a b c
!UNQUOTE("a b c") 7→ a b c
!UNQUOTE(!1) 7→ a ’b’ c if !1 is a ’b’ c
!QUOTE(!UNQUOTE(123.0)) 7→ ’123.0’
!QUOTE(!UNQUOTE( 123 )) 7→ ’123’
!QUOTE(!UNQUOTE(’a b c’)) 7→ ’a b c’
!QUOTE(!UNQUOTE("a b c")) 7→ ’a b c’
!QUOTE(!UNQUOTE(!1)) 7→ ’a ’’b’’ c’ if !1 is a ’b’ c
!SUBSTR(banana, 3, 0) 7→ empty
!SUBSTR(banana, 3, 10) 7 → nana
!SUBSTR(banana, 10, 3) 7→ empty
These operators always compare their operands as strings. This can be surprising
when the strings are numbers because, e.g., 1 < 1.0 and 10 < 2 both evaluate
to ‘1’ (true).
Comparisons are case sensitive, so that a = A evaluates to ‘0’ (false).
!NOT ~
!AND &
!OR | Logical operators interpret their operands as Boolean values, where quoted or
unquoted ‘0’ is false and anything else is true, and yield a Boolean result, either
‘0’ for false or ‘1’ for true.
Macro expressions do not include any arithmetic operators.
An operand in an expression may be a single token (including a macro argument name)
or a macro function invocation. Either way, the expression evaluator unquotes the operand,
so that 1 = ’1’ is true.
Macro functions are not supported as part of the arguments in a macro call. To get the
same effect, use !LET to define a macro variable, then pass the macro variable to the macro.
When macro A calls macro B, the order of their DEFINE commands doesn’t matter, as
long as macro B has been defined when A is called.
14.3 DO IF
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
Chapter 14: Conditional and Looping Constructs 148
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 Section 13.6 [TEMPORARY],
page 133), the LAG function may not be used (see [LAG], page 55).
14.4 DO REPEAT
DO REPEAT dummy name=expansion. . . .
...
END REPEAT [PRINT].
If PRINT is specified on END REPEAT, the commands after substitutions are made should be
printed to the listing file, prefixed by a plus sign (‘+’). This feature is not yet implemented.
14.5 LOOP
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 Chapter 7 [Expressions], page 44.)
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 the index clause is not present, then the global MXLOOPS setting, which defaults to 40,
limits the number of iterations (see [SET MXLOOPS], page 269).
BREAK also terminates LOOP execution (see Section 14.1 [BREAK], page 136).
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 Section 11.21 [LEAVE], page 107)
or by using a scratch variable as the loop index.
When LOOP or END LOOP is specified following TEMPORARY (see Section 13.6 [TEMPO-
RARY], page 133), the LAG function may not be used (see [LAG], page 55).
150
15 Statistics
This chapter documents the statistical procedures that pspp supports so far.
15.1 DESCRIPTIVES
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 dataset and outputs linear 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 has no effect. It is accepted for backward compatibility.
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. When Z scores are calculated, pspp ignores TEMPORARY,
treating temporary transformations as permanent.
The STATISTICS subcommand specifies the statistics to be displayed:
ALL All of the statistics below.
MEAN Arithmetic mean.
SEMEAN Standard error of the mean.
STDDEV Standard deviation.
VARIANCE Variance.
Chapter 15: Statistics 151
RANGE Range.
SUM Sum.
SEKURTOSIS
Standard error of the kurtosis.
SESKEWNESS
Standard error of the skewness.
The 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.
After the command has completed, this example runs DESCRIPTIVES again, this time on
the zheight and ztemperature variables, which are the two normalized (Z-score) variables
generated by the first DESCRIPTIVES command.
get file=’physiology.sav’.
descriptives
/variables = height temperature
/save.
descriptives
/variables = zheight ztemperature.
Example 15.1: Running two DESCRIPTIVES commands, one with the SAVE subcommand
Chapter 15: Statistics 152
Screenshot 15.1: The Descriptives dialog box with two variables and Z-Scores option
selected
In Result 15.1, we can see that there are 40 valid data for each of the variables and no
missing values. The mean average of the height and temperature is 16677.12 and 37.02
respectively. The descriptive statistics for temperature seem reasonable. However there is a
very high standard deviation for height and a suspiciously low minimum. This is due to a
data entry error in the data (see Section 5.2.1 [Identifying incorrect data], page 15).
In the second Descriptive Statistics command, one can see that the mean and standard
deviation of both Z score variables is 0 and 1 respectively. All Z score statistics should have
these properties since they are normalized versions of the original scores.
Chapter 15: Statistics 153
Descriptive Statistics
+------------------------------------------+--+-------+-------+-------+-------+
| | N| Mean |Std Dev|Minimum|Maximum|
+------------------------------------------+--+-------+-------+-------+-------+
|Height in millimeters |40|1677.12| 262.87| 179| 1903|
|Internal body temperature in degrees |40| 37.02| 1.82| 32.59| 39.97|
|Celcius | | | | | |
|Valid N (listwise) |40| | | | |
|Missing N (listwise) | 0| | | | |
+------------------------------------------+--+-------+-------+-------+-------+
Descriptive Statistics
+-----------------------------------------+--+---------+------+-------+-------+
| | | | Std | | |
| | N| Mean | Dev |Minimum|Maximum|
+-----------------------------------------+--+---------+------+-------+-------+
|Z-score of Height in millimeters |40|1.93E-015| 1.00| -5.70| .86|
|Z-score of Internal body temperature in |40|1.37E-015| 1.00| -2.44| 1.62|
|degrees Celcius | | | | | |
|Valid N (listwise) |40| | | | |
|Missing N (listwise) | 0| | | | |
+-----------------------------------------+--+---------+------+-------+-------+
Result 15.1: Descriptives statistics including two normalized variables (Z-scores)
15.2 FREQUENCIES
FREQUENCIES
/VARIABLES=var list
/FORMAT={TABLE,NOTABLE,LIMIT(limit)}
{AVALUE,DVALUE,AFREQ,DFREQ}
/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[(y max)],PERCENT[(y max)]}] [{NONORMAL,NORMAL}]
/PIECHART=[MINIMUM(x min)] [MAXIMUM(x max)]
[{FREQ,PERCENT}] [{NOMISSING,MISSING}]
/BARCHART=[MINIMUM(x min)] [MAXIMUM(x max)]
[{FREQ,PERCENT}]
/ORDER={ANALYSIS,VARIABLE}
Chapter 15: Statistics 154
is specified, then the pie chart includes a single slice representing all system missing and
user-missing cases.
The BARCHART subcommand produces a bar chart for each variable. The MINIMUM and
MAXIMUM keywords can be used to omit categories whose counts which lie outside the
specified limits. The FREQ option (default) causes the ordinate to display the frequency of
each category, whereas the PERCENT option displays relative percentages.
The FREQ and PERCENT options on HISTOGRAM and PIECHART are accepted but not
currently honoured.
The ORDER subcommand is accepted but ignored.
get file=’personnel.sav’.
Example 15.2: Running frequencies on the sex and occupation variables
If you are using the graphic user interface, the dialog box is set up such that by default,
several statistics are calculated. Some are not particularly useful for categorical variables, so
you may want to disable those.
Screenshot 15.2: The frequencies dialog box with the sex and occupation variables selected
From Result 15.2 it is evident that there are 33 males, 21 females and 2 persons for whom
their sex has not been entered.
Chapter 15: Statistics 156
One can also see how many of each occupation there are in the data. When dealing with
string variables used as nominal values, running a frequency analysis is useful to detect data
input entries. Notice that one occupation value has been mistyped as “Scrientist”. This
entry should be corrected, or marked as missing before using the data.
sex
+--------------+---------+-------+-------------+------------------+
| |Frequency|Percent|Valid Percent|Cumulative Percent|
+--------------+---------+-------+-------------+------------------+
|Valid Male | 33| 58.9%| 61.1%| 61.1%|
| Female| 21| 37.5%| 38.9%| 100.0%|
+--------------+---------+-------+-------------+------------------+
|Missing . | 2| 3.6%| | |
+--------------+---------+-------+-------------+------------------+
|Total | 56| 100.0%| | |
+--------------+---------+-------+-------------+------------------+
occupation
+------------------------+---------+-------+-------------+------------------+
| |Frequency|Percent|Valid Percent|Cumulative Percent|
+------------------------+---------+-------+-------------+------------------+
|Valid Artist | 8| 14.3%| 14.3%| 14.3%|
| Baker | 2| 3.6%| 3.6%| 17.9%|
| Barrister | 1| 1.8%| 1.8%| 19.6%|
| Carpenter | 4| 7.1%| 7.1%| 26.8%|
| Cleaner | 4| 7.1%| 7.1%| 33.9%|
| Cook | 7| 12.5%| 12.5%| 46.4%|
| Manager | 8| 14.3%| 14.3%| 60.7%|
| Mathematician | 4| 7.1%| 7.1%| 67.9%|
| Painter | 2| 3.6%| 3.6%| 71.4%|
| Payload Specialist| 1| 1.8%| 1.8%| 73.2%|
| Plumber | 5| 8.9%| 8.9%| 82.1%|
| Scientist | 7| 12.5%| 12.5%| 94.6%|
| Scrientist | 1| 1.8%| 1.8%| 96.4%|
| Tailor | 2| 3.6%| 3.6%| 100.0%|
+------------------------+---------+-------+-------------+------------------+
|Total | 56| 100.0%| | |
+------------------------+---------+-------+-------------+------------------+
Result 15.2: The relative frequencies of sex and occupation
15.3 EXAMINE
EXAMINE
VARIABLES= var1 [var2] . . . [varN ]
[BY factor1 [BY subfactor1]
[ factor2 [BY subfactor2]]
...
[ factor3 [BY subfactor3]]
]
/STATISTICS={DESCRIPTIVES, EXTREME[(n)], ALL, NONE}
/PLOT={BOXPLOT, NPPLOT, HISTOGRAM, SPREADLEVEL[(t)], ALL, NONE}
/CINTERVAL p
/COMPARE={GROUPS,VARIABLES}
/ID=identity variable
Chapter 15: Statistics 157
/{TOTAL,NOTOTAL}
/PERCENTILE=[percentiles]={HAVERAGE, WAVERAGE, ROUND, AEM-
PIRICAL, EMPIRICAL }
/MISSING={LISTWISE, PAIRWISE} [{EXCLUDE, INCLUDE}]
[{NOREPORT,REPORT}]
see the difference between the genders. Since the variable name was specified on the ID
subcommand, values of the name variable are used to label the extreme values.
Warning! If you specify many dependent variables or factor variables for which there are
many distinct values, then EXAMINE will produce a very large quantity of output.
15.4 GRAPH
GRAPH
/HISTOGRAM [(NORMAL)]= var
/SCATTERPLOT [(BIVARIATE)] = var1 WITH var2 [BY var3]
/BAR = {summary-function(var1) | count-function} BY var2 [BY var3]
[ /MISSING={LISTWISE, VARIABLE} [{EXCLUDE, INCLUDE}] ]
[{NOREPORT,REPORT}]
The GRAPH command produces graphical plots of data. Only one of the subcommands
HISTOGRAM, BAR or SCATTERPLOT can be specified, i.e. only one plot can be produced per
call of GRAPH. The MISSING is optional.
15.4.1 Scatterplot
The subcommand SCATTERPLOT produces an xy plot of the data. GRAPH uses the third
variable var3, if specified, to determine the colours and/or markers for the plot. The
following is an example for producing a scatterplot.
GRAPH
/SCATTERPLOT = height WITH weight BY gender.
This example produces a scatterplot where height is plotted versus weight. Depending
on the value of the gender variable, the colour of the datapoint is different. With this plot it
is possible to analyze gender differences for height versus weight relation.
15.4.2 Histogram
The subcommand HISTOGRAM produces a histogram. Only one variable is allowed for the
histogram plot. The keyword NORMAL may be specified in parentheses, to indicate that the
ideal normal curve should be superimposed over the histogram. For an alternative method to
produce histograms see Section 15.3 [EXAMINE], page 156. The following example produces
a histogram plot for the variable weight.
GRAPH
/HISTOGRAM = weight.
PCT The weighted counts of the cases in each category expressed as a percentage of
the total weights of the cases.
CUFREQ The cumulative weighted counts of the cases in each category.
CUPCT The cumulative weighted counts of the cases in each category expressed as a
percentage of the total weights of the cases.
The summary function is applied to var1 across all cases in each category. The recognised
summary functions are:
SUM The sum.
MEAN The arithmetic mean.
MAXIMUM The maximum value.
MINIMUM The minimum value.
The following examples assume a dataset which is the results of a survey. Each respondent
has indicated annual income, their sex and city of residence. One could create a bar chart
showing how the mean income varies between of residents of different cities, thus:
GRAPH /BAR = MEAN(income) BY city.
This can be extended to also indicate how income in each city differs between the sexes.
GRAPH /BAR = MEAN(income) BY city BY sex.
One might also want to see how many respondents there are from each city. This can be
achieved as follows:
GRAPH /BAR = COUNT BY city.
Bar charts can also be produced using the Section 15.2 [FREQUENCIES], page 153, and
Section 15.6 [CROSSTABS], page 161, commands.
15.5 CORRELATIONS
CORRELATIONS
/VARIABLES = var list [ WITH var list ]
[
.
.
.
/VARIABLES = var list [ WITH var list ]
/VARIABLES = var list [ WITH var list ]
]
rows of the table, and the variables following WITH are used as the columns of the table. If
no WITH subcommand is specified, then CORRELATIONS produces a square, symmetrical table
using all variables.
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.
If LISTWISE is set, then the entire case is excluded from analysis whenever any variable
specified in any /VARIABLES subcommand contains a missing value. If PAIRWISE is set, then
a case is considered missing only if either of the values for the particular coefficient are
missing. The default is PAIRWISE.
The PRINT subcommand is used to control how the reported significance values are
printed. If the TWOTAIL option is used, then a two-tailed test of significance is printed. If
the ONETAIL option is given, then a one-tailed test is used. The default is TWOTAIL.
If the NOSIG option is specified, then correlation coefficients with significance less than
0.05 are highlighted. If SIG is specified, then no highlighting is performed. This is the
default.
The STATISTICS subcommand requests additional statistics to be displayed. The keyword
DESCRIPTIVES requests that the mean, number of non-missing cases, and the non-biased
estimator of the standard deviation are displayed. These statistics are displayed in a
separated table, for all the variables listed in any /VARIABLES subcommand. The XPROD
keyword requests cross-product deviations and covariance estimators to be displayed for
each pair of variables. The keyword ALL is the union of DESCRIPTIVES and XPROD.
15.6 CROSSTABS
CROSSTABS
/TABLES=var list BY var list [BY var list]. . .
/MISSING={TABLE,INCLUDE,REPORT}
/FORMAT={TABLES,NOTABLES}
{AVALUE,DVALUE}
/CELLS={COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
ASRESIDUAL,ALL,NONE}
/COUNT={ASIS,CASE,CELL}
{ROUND,TRUNCATE}
/STATISTICS={CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
KAPPA,ETA,CORR,ALL,NONE}
/BARCHART
(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
Chapter 15: Statistics 162
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. 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 a footnote and excluded from statistical calculations.
The FORMAT subcommand controls the characteristics of the crosstabulation tables to be
displayed. It has a number of possible settings:
TABLES, the default, causes crosstabulation tables to be output. NOTABLES, which is
equivalent to CELLS=NONE, suppresses them.
AVALUE, the default, causes values to be sorted in ascending order. DVALUE asserts a
descending sort order.
The CELLS subcommand controls the contents of each cell in the displayed crosstabulation
table. The possible settings are:
COUNT Frequency count.
ROW Row percent.
COLUMN Column percent.
TOTAL Table percent.
EXPECTED
Expected value.
RESIDUAL
Residual.
SRESIDUAL
Standardized residual.
ASRESIDUAL
Adjusted standardized residual.
ALL All of the above.
NONE Suppress cells entirely.
Chapter 15: Statistics 163
‘/CELLS’ without any settings specified requests COUNT, ROW, COLUMN, and TOTAL. If CELLS
is not specified at all then only COUNT is selected.
By default, crosstabulation and statistics use raw case weights, without rounding. Use
the /COUNT subcommand to perform rounding: CASE rounds the weights of individual
weights as cases are read, CELL rounds the weights of cells within each crosstabulation
table after it has been constructed, and ASIS explicitly specifies the default non-rounding
behavior. When rounding is requested, ROUND, the default, rounds to the nearest integer
and TRUNCATE rounds toward zero.
The STATISTICS subcommand selects statistics for computation:
CHISQ
Pearson chi-square, likelihood ratio, Fisher’s exact test, continuity correction,
linear-by-linear association.
PHI Phi.
CC Contingency coefficient.
LAMBDA Lambda.
UC Uncertainty coefficient.
BTAU Tau-b.
CTAU Tau-c.
RISK Risk estimate.
GAMMA Gamma.
D Somers’ D.
KAPPA Cohen’s Kappa.
ETA Eta.
CORR Spearman correlation, Pearson’s r.
ALL All of the above.
NONE No statistics.
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.
The ‘/BARCHART’ subcommand produces a clustered bar chart for the first two variables
on each table. If a table has more than two variables, the counts for the third and subsequent
levels are aggregated and the chart is produced as if there were only two variables.
Please note: Currently the implementation of CROSSTABS has the following limitations:
• Significance of some directional measures is not calculated.
• Asymptotic standard error is not calculated for Goodman and Kruskal’s tau or symmetric
Somers’ d.
• Approximate T is not calculated for symmetric uncertainty coefficient.
Fixes for any of these deficiencies would be welcomed.
Chapter 15: Statistics 164
get file="personnel.sav".
crosstabs
/tables= occupation by sex
/cells = count expected
/statistics=chisq.
Example 15.3: Running crosstabs on the sex and occupation variables
The syntax in Example 15.3 conducts a chi-squared test of independence. The line
/tables = occupation by sex indicates that occupation and sex are the variables to be
tabulated. To do this using the graphic user interface you must place these variable names
respectively in the ‘Row’ and ‘Column’ fields as shown in Screenshot 15.3.
Screenshot 15.3: The Crosstabs dialog box with the sex and occupation variables selected
Chapter 15: Statistics 165
Similarly, the ‘Cells’ button shows a dialog box to select the count and expected
options. All other cell options can be deselected for this test.
You would use the ‘Format’ and ‘Statistics’ buttons to select options for the FORMAT
and STATISTICS subcommands. In this example, the ‘Statistics’ requires only the ‘Chisq’
option to be checked. All other options should be unchecked. No special settings are required
from the ‘Format’ dialog.
As shown in Results 15.1 CROSSTABS generates a contingency table containing the observed
count and the expected count of each sex and each occupation. The expected count is the
count which would be observed if the null hypothesis were true.
The significance of the Pearson Chi-Square value is very much larger than the normally
accepted value of 0.05 and so one cannot reject the null hypothesis. Thus the researcher
must conclude that a person’s sex has no relation to the person’s occupation.
Chapter 15: Statistics 166
Summary
+----------------+-------------------------------+
| | Cases |
| +----------+---------+----------+
| | Valid | Missing | Total |
| +--+-------+-+-------+--+-------+
| | N|Percent|N|Percent| N|Percent|
+----------------+--+-------+-+-------+--+-------+
|occupation × sex|54| 96.4%|2| 3.6%|56| 100.0%|
+----------------+--+-------+-+-------+--+-------+
occupation × sex
+--------------------------------------+-----------+-----+
| | sex | |
| +----+------+ |
| |Male|Female|Total|
+--------------------------------------+----+------+-----+
|occupation Artist Count | 2| 6| 8|
| Expected|4.89| 3.11| .15|
| ----------------------------+----+------+-----+
| Baker Count | 1| 1| 2|
| Expected|1.22| .78| .04|
| ----------------------------+----+------+-----+
| Barrister Count | 0| 1| 1|
| Expected| .61| .39| .02|
| ----------------------------+----+------+-----+
| Carpenter Count | 3| 1| 4|
| Expected|2.44| 1.56| .07|
| ----------------------------+----+------+-----+
| Cleaner Count | 4| 0| 4|
| Expected|2.44| 1.56| .07|
| ----------------------------+----+------+-----+
| Cook Count | 3| 2| 5|
| Expected|3.06| 1.94| .09|
| ----------------------------+----+------+-----+
| Manager Count | 4| 4| 8|
| Expected|4.89| 3.11| .15|
| ----------------------------+----+------+-----+
| Mathematician Count | 3| 1| 4|
| Expected|2.44| 1.56| .07|
| ----------------------------+----+------+-----+
| Painter Count | 1| 1| 2|
| Expected|1.22| .78| .04|
| ----------------------------+----+------+-----+
| Payload Specialist Count | 1| 0| 1|
| Expected| .61| .39| .02|
| ----------------------------+----+------+-----+
| Plumber Count | 5| 0| 5|
| Expected|3.06| 1.94| .09|
| ----------------------------+----+------+-----+
| Scientist Count | 5| 2| 7|
| Expected|4.28| 2.72| .13|
| ----------------------------+----+------+-----+
| Scrientist Count | 0| 1| 1|
| Expected| .61| .39| .02|
| ----------------------------+----+------+-----+
| Tailor Count | 1| 1| 2|
| Expected|1.22| .78| .04|
+--------------------------------------+----+------+-----+
|Total Count | 33| 21| 54|
| Expected| .61| .39| 1.00|
+--------------------------------------+----+------+-----+
Chi-Square Tests
+------------------+-----+--+--------------------------+
Chapter 15: Statistics 167
15.7 CTABLES
CTABLES has the following overall syntax. At least one TABLE subcommand is required:
CTABLES
. . . global subcommands . . .
[/TABLE axis [BY axis [BY axis]]
. . . per-table subcommands . . . ]. . .
where each axis may be empty or take one of the following forms:
variable
variable [{C | S}]
axis + axis
axis > axis
(axis)
axis [summary [string] [format]]
The following subcommands precede the first TABLE subcommand and apply to all of the
output tables. All of these subcommands are optional:
/FORMAT
[MINCOLWIDTH={DEFAULT | width}]
[MAXCOLWIDTH={DEFAULT | width}]
[UNITS={POINTS | INCHES | CM}]
[EMPTY={ZERO | BLANK | string}]
[MISSING=string]
/VLABELS
VARIABLES=variables
DISPLAY={DEFAULT | NAME | LABEL | BOTH | NONE}
/SMISSING {VARIABLE | LISTWISE}
/PCOMPUTE &postcompute=EXPR(expression)
/PPROPERTIES &postcompute . . .
[LABEL=string]
[FORMAT=[summary format]. . . ]
[HIDESOURCECATS={NO | YES}
/WEIGHT VARIABLE=variable
/HIDESMALLCOUNTS COUNT=count
The following subcommands follow TABLE and apply only to the previous TABLE. All of
these subcommands are optional:
/SLABELS
[POSITION={COLUMN | ROW | LAYER}]
[VISIBLE={YES | NO}]
/CLABELS {AUTO | {ROWLABELS|COLLABELS}={OPPOSITE|LAYER}}
/CATEGORIES VARIABLES=variables
{[value, value . . . ]
| [ORDER={A | D}]
[KEY={VALUE | LABEL | summary(variable)}]
[MISSING={EXCLUDE | INCLUDE}]}
[TOTAL={NO | YES} [LABEL=string] [POSITION={AFTER | BEFORE}]]
[EMPTY={INCLUDE | EXCLUDE}]
Chapter 15: Statistics 168
/TITLES
[TITLE=string . . . ]
[CAPTION=string . . . ]
[CORNER=string . . . ]
The CTABLES (aka “custom tables”) command produces multi-dimensional tables from
categorical and scale data. It offers many options for data summarization and formatting.
This section’s examples use data from the 2008 (USA) National Survey of Drinking and
Driving Attitudes and Behaviors, a public domain data set from the (USA) National Highway
Traffic Administration and available at https://data.transportation.gov. pspp includes
this data set, with a modified dictionary, as examples/nhtsa.sav.
15.7.1 Basics
The only required subcommand is TABLE, which specifies the variables to include along each
axis:
/TABLE rows [BY columns [BY layers]]
In TABLE, each of rows, columns, and layers is either empty or an axis expression that
specifies one or more variables. At least one must specify an axis expression.
| 16 to 25 | 594| 505|
| 26 to 35 | 476| 491|
| 36 to 45 | 489| 548|
| 46 to 55 | 526| 649|
| 56 to 65 | 516| 731|
| 66 or older | 531| 943|
+-----------------------+-----+------+
The ‘>’ “nesting” operator nests multiple variables on a single axis, e.g.:
CTABLES /TABLE likelihoodOfBeingStoppedByPolice BY ageGroup > gender.
Custom Tables
+---------------------------------+-------------------------------------------+
| | 86. In the past year, have you hosted a |
| | social event or party where alcohol was |
| | served to adults? |
| +---------------------+---------------------+
| | Yes | No |
| +---------------------+---------------------+
| | Count | Count |
+---------------------------------+---------------------+---------------------+
|Age 15 or S3a. Male | 0| 0|
|group younger GENDER: Female| 0| 0|
| ---------------------------+---------------------+---------------------+
| 16 to 25 S3a. Male | 208| 386|
| GENDER: Female| 202| 303|
| ---------------------------+---------------------+---------------------+
| 26 to 35 S3a. Male | 225| 251|
| GENDER: Female| 242| 249|
| ---------------------------+---------------------+---------------------+
| 36 to 45 S3a. Male | 223| 266|
| GENDER: Female| 240| 307|
| ---------------------------+---------------------+---------------------+
| 46 to 55 S3a. Male | 201| 325|
| GENDER: Female| 282| 366|
| ---------------------------+---------------------+---------------------+
| 56 to 65 S3a. Male | 196| 320|
| GENDER: Female| 279| 452|
| ---------------------------+---------------------+---------------------+
| 66 or S3a. Male | 162| 367|
| older GENDER: Female| 243| 700|
+---------------------------------+---------------------+---------------------+
The ‘+’ “stacking” operator allows a single output table to include multiple data analyses.
With ‘+’, CTABLES divides the output table into multiple sections, each of which includes an
analysis of the full data set. For example, the following command separately tabulates age
group and driving frequency by gender:
CTABLES /TABLE ageGroup + freqOfDriving BY gender.
Custom Tables
+----------------------------------------------------------------+------------+
| |S3a. GENDER:|
| +-----+------+
| | Male|Female|
| +-----+------+
| |Count| Count|
+----------------------------------------------------------------+-----+------+
|Age group 15 or younger | 0| 0|
| 16 to 25 | 594| 505|
Chapter 15: Statistics 170
| 26 to 35 | 476| 491|
| 36 to 45 | 489| 548|
| 46 to 55 | 526| 649|
| 56 to 65 | 516| 731|
| 66 or older | 531| 943|
+----------------------------------------------------------------+-----+------+
| 1. How often do you usually drive a car or Every day | 2305| 2362|
|other motor vehicle? Several days a week| 440| 834|
| Once a week or less| 125| 236|
| Only certain times | 58| 72|
| a year | | |
| Never | 192| 348|
+----------------------------------------------------------------+-----+------+
When ‘+’ and ‘>’ are used together, ‘>’ binds more tightly. Use parentheses to override
operator precedence. Thus:
CTABLES /TABLE hasConsideredReduction + hasBeenCriticized > gender.
CTABLES /TABLE (hasConsideredReduction + hasBeenCriticized) > gender.
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
|26. During the last 12 months, has there been a Yes | 513|
|time when you felt you should cut down on your ---------------------+-----+
|drinking? No | 3710|
+-----------------------------------------------------------------------+-----+
|27. During the last 12 months, has there been a Yes S3a. Male | 135|
|time when people criticized your drinking? GENDER: Female| 49|
| ---------------------+-----+
| No S3a. Male | 1916|
| GENDER: Female| 2126|
+-----------------------------------------------------------------------+-----+
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
|26. During the last 12 months, has there been a Yes S3a. Male | 333|
|time when you felt you should cut down on your GENDER: Female| 180|
|drinking? ---------------------+-----+
| No S3a. Male | 1719|
| GENDER: Female| 1991|
+-----------------------------------------------------------------------+-----+
|27. During the last 12 months, has there been a Yes S3a. Male | 135|
|time when people criticized your drinking? GENDER: Female| 49|
| ---------------------+-----+
| No S3a. Male | 1916|
| GENDER: Female| 2126|
+-----------------------------------------------------------------------+-----+
Custom Tables
+--------------------------+----+
| |Mean|
+--------------------------+----+
|D1. AGE: What is your age?| 48|
+--------------------------+----+
A scalar variable may nest with categorical variables. The following example shows the
mean age of survey respondents across gender and language groups:
CTABLES /TABLE gender > age BY region.
Custom Tables
+-------------------------------------+---------------------------------------+
| |Was this interview conducted in English|
| | or Spanish? |
| +-------------------+-------------------+
| | English | Spanish |
| +-------------------+-------------------+
| | Mean | Mean |
+-------------------------------------+-------------------+-------------------+
|D1. AGE: What is S3a. Male | 46| 37|
|your age? GENDER: Female| 51| 39|
+-------------------------------------+-------------------+-------------------+
The order of nesting of scalar and categorical variables affects table labeling, but it does
not affect the data displayed in the table. The following example shows how the output
changes when the nesting order of the scalar and categorical variable are interchanged:
CTABLES /TABLE age > gender BY region.
Custom Tables
+-------------------------------------+---------------------------------------+
| |Was this interview conducted in English|
| | or Spanish? |
| +-------------------+-------------------+
| | English | Spanish |
| +-------------------+-------------------+
| | Mean | Mean |
+-------------------------------------+-------------------+-------------------+
|S3a. Male D1. AGE: What is | 46| 37|
|GENDER: your age? | | |
| ---------------------------+-------------------+-------------------+
| Female D1. AGE: What is | 51| 39|
| your age? | | |
+-------------------------------------+-------------------+-------------------+
Only a single scalar variable may appear in each section; that is, a scalar variable may
not nest inside a scalar variable directly or indirectly. Scalar variables may only appear on
one axis within TABLE.
using the rules described in an earlier section (see [Measurement Level], page 30). Use the
VARIABLE LEVEL command to set or change a variable’s measurement level (see Section 11.17
[VARIABLE LEVEL], page 105).
To treat a variable as categorical or scalar only for one use on CTABLES, add ‘[C]’ or
‘[S]’, respectively, after the variable name. The following example shows the output when
variable monthDaysMin1drink is analyzed as scalar (the default for its measurement level)
and as categorical:
CTABLES
/TABLE monthDaysMin1drink BY gender
/TABLE monthDaysMin1drink [C] BY gender.
Custom Tables
+----------------------------------------------------------------+------------+
| |S3a. GENDER:|
| +----+-------+
| |Male| Female|
| +----+-------+
| |Mean| Mean |
+----------------------------------------------------------------+----+-------+
|20. On how many of the thirty days in this typical month did you| 7| 5|
|have one or more alcoholic beverages to drink? | | |
+----------------------------------------------------------------+----+-------+
Custom Tables
+----------------------------------------------------------------+------------+
| |S3a. GENDER:|
| +-----+------+
| | Male|Female|
| +-----+------+
| |Count| Count|
+----------------------------------------------------------------+-----+------+
|20. On how many of the thirty days in this typical month None | 152| 258|
|did you have one or more alcoholic beverages to drink? 1 | 403| 653|
| 2 | 284| 324|
| 3 | 169| 215|
| 4 | 178| 143|
| 5 | 107| 106|
| 6 | 67| 59|
| 7 | 31| 11|
| 8 | 101| 74|
| 9 | 6| 4|
| 10 | 95| 75|
| 11 | 4| 0|
| 12 | 58| 33|
| 13 | 3| 2|
| 14 | 13| 3|
| 15 | 79| 58|
| 16 | 10| 6|
| 17 | 4| 2|
| 18 | 5| 4|
| 19 | 2| 0|
| 20 | 105| 47|
| 21 | 2| 0|
| 22 | 3| 3|
| 23 | 0| 3|
| 24 | 3| 0|
Chapter 15: Statistics 173
| 25 | 35| 25|
| 26 | 1| 1|
| 27 | 3| 3|
| 28 | 13| 8|
| 29 | 3| 3|
| Every | 104| 43|
| day | | |
+----------------------------------------------------------------+-----+------+
Custom Tables
+-----------------------+-----------------------------+
| | S3a. GENDER: |
| +--------------+--------------+
| | Male | Female |
| +--------+-----+--------+-----+
| |Column %|Row %|Column %|Row %|
+-----------------------+--------+-----+--------+-----+
|Age group 15 or younger| .0%| .| .0%| .|
| 16 to 25 | 19.0%|54.0%| 13.1%|46.0%|
| 26 to 35 | 15.2%|49.2%| 12.7%|50.8%|
| 36 to 45 | 15.6%|47.2%| 14.2%|52.8%|
| 46 to 55 | 16.8%|44.8%| 16.8%|55.2%|
| 56 to 65 | 16.5%|41.4%| 18.9%|58.6%|
| 66 or older | 17.0%|36.0%| 24.4%|64.0%|
+-----------------------+--------+-----+--------+-----+
A summary specification may override the default label and format by appending a string
or format specification or both (in that order) to the summary function name. For example:
CTABLES /TABLE=ageGroup [COLPCT ’Gender %’ PCT5.0,
ROWPCT ’Age Group %’ PCT5.0]
Chapter 15: Statistics 174
BY gender.
Custom Tables
+-----------------------+-----------------------------------------+
| | S3a. GENDER: |
| +--------------------+--------------------+
| | Male | Female |
| +--------+-----------+--------+-----------+
| |Gender %|Age Group %|Gender %|Age Group %|
+-----------------------+--------+-----------+--------+-----------+
|Age group 15 or younger| 0%| .| 0%| .|
| 16 to 25 | 19%| 54%| 13%| 46%|
| 26 to 35 | 15%| 49%| 13%| 51%|
| 36 to 45 | 16%| 47%| 14%| 53%|
| 46 to 55 | 17%| 45%| 17%| 55%|
| 56 to 65 | 16%| 41%| 19%| 59%|
| 66 or older | 17%| 36%| 24%| 64%|
+-----------------------+--------+-----------+--------+-----------+
In addition to the standard formats, CTABLES allows the user to specify the following
special formats:
NEGPARENw.d Encloses negative numbers in 42.96 (42.96)
parentheses.
NEQUALw.d Adds a N= prefix. N=42.96 N=-42.96
| 3 | 11.0%| 8.2%|
| 4 | 4.2%| 3.2%|
| 5 | 1.1%| .9%|
| 6 or more | .4%| .4%|
+-------------------------------------------------------------+-------+-------+
The following sections list the available summary functions. After each function’s name
is given its default label and format. If no format is listed, then the default format is the
print format for the variable being summarized.
+---------------------------------+-----------------+------+
| | licensed |desDrv|
| +--------+--------+---+--+
| | Yes | No | | |
| +--------+--------+ | |
| | hostAlc| hostAlc| | |
| +----+---+----+---+ | |
| | Yes| No| Yes| No|Yes|No|
+---------------------------------+----+---+----+---+---+--+
|desPas Yes druPas Yes Table ID | 1| 1| 1| 1| 2| 2|
| Layer ID | 1| 1| 1| 1| 2| 2|
| Subtable ID| 1| 1| 2| 2| 3| 3|
| ----------------+----+---+----+---+---+--+
| No Table ID | 1| 1| 1| 1| 2| 2|
| Layer ID | 1| 1| 1| 1| 2| 2|
| Subtable ID| 1| 1| 2| 2| 3| 3|
| ---------------------------+----+---+----+---+---+--+
| No druPas Yes Table ID | 1| 1| 1| 1| 2| 2|
| Layer ID | 1| 1| 1| 1| 2| 2|
| Subtable ID| 4| 4| 5| 5| 6| 6|
| ----------------+----+---+----+---+---+--+
| No Table ID | 1| 1| 1| 1| 2| 2|
| Layer ID | 1| 1| 1| 1| 2| 2|
| Subtable ID| 4| 4| 5| 5| 6| 6|
+---------------------------------+----+---+----+---+---+--+
CTABLES also supports the following areas that further divide a subtable or a layer within
a section:
LAYERROW
LAYERCOL A row or column, respectively, in one layer of a section.
ROW
COL A row or column, respectively, in a subtable.
The following summary functions for groups of cells are available for each area described
above, for both categorical and scale variables:
areaPCT or areaPCT.COUNT (“Area %”, PCT40.1)
A percentage of total counts within area.
areaPCT.VALIDN (“Area Valid N %”, PCT40.1)
A percentage of total counts for valid values within area.
areaPCT.TOTALN (“Area Total N %”, PCT40.1)
A percentage of total counts for all values within area.
Scale variables and totals and subtotals for categorical variables may use the following
additional group cell summary function:
areaPCT.SUM (“Area Sum %”, PCT40.1)
Percentage of the sum of the values within area.
instead of the dictionary weight variable. Otherwise, they are equivalent to the summary
function without the ‘E’-prefix:
• ECOUNT (“Adjusted Count”, F40.0)
• ETOTALN (“Adjusted Total N”, F40.0)
• EVALIDN (“Adjusted Valid N”, F40.0)
+-----------------------+-----+------+
+-----+-----------------+
| | |
| +-----------------+
| | |
| +-----+-----+-----+
| |46 to|56 to|66 or|
| | 55 | 65 |older|
| +-----+-----+-----+
| |Count|Count|Count|
+-----+-----+-----+-----+
|Age | 649| 731| 943|
|group| | | |
+-----+-----+-----+-----+
Custom Tables
+------------------------------+------------+
| |S3a. GENDER:|
| +------------+
| | Count |
+------------------------------+------------+
|Age group 15 or younger Male | 0|
| Female| 0|
| ---------------------+------------+
| 16 to 25 Male | 594|
| Female| 505|
| ---------------------+------------+
| 26 to 35 Male | 476|
| Female| 491|
| ---------------------+------------+
| 36 to 45 Male | 489|
| Female| 548|
| ---------------------+------------+
| 46 to 55 Male | 526|
| Female| 649|
| ---------------------+------------+
Chapter 15: Statistics 181
| 56 to 65 Male | 516|
| Female| 731|
| ---------------------+------------+
| 66 or older Male | 531|
| Female| 943|
+------------------------------+------------+
ROWLABELS=LAYER or COLLABELS=LAYER move the innermost row or column variable
category labels, respectively, to the layer axis.
Only one axis’s labels may be moved, whether to the opposite axis or to the layer axis.
| ---------------------+------+--------+
| 36 to 45 Male |100.0%| 47.2%|
| Female|100.0%| 52.8%|
| ---------------------+------+--------+
| 46 to 55 Male |100.0%| 44.8%|
| Female|100.0%| 55.2%|
| ---------------------+------+--------+
| 56 to 65 Male |100.0%| 41.4%|
| Female|100.0%| 58.6%|
| ---------------------+------+--------+
| 66 or older Male |100.0%| 36.0%|
| Female|100.0%| 64.0%|
+------------------------------+------+--------+
Custom Tables
+-----------------------------+--------+-------+---------+----------+---------+
| | Almost | Very | Somewhat| Somewhat | Very |
| | certain| likely| likely | unlikely | unlikely|
Chapter 15: Statistics 183
| +--------+-------+---------+----------+---------+
| | Row % | Row % | Row % | Row % | Row % |
+-----------------------------+--------+-------+---------+----------+---------+
|105b. How likely is it that | 10.2%| 21.8%| 40.2%| 19.0%| 8.9%|
|drivers who have had too much| | | | | |
|to drink to drive safely will| | | | | |
|A. Get stopped by the police?| | | | | |
|105b. How likely is it that | 15.9%| 40.8%| 35.0%| 6.2%| 2.0%|
|drivers who have had too much| | | | | |
|to drink to drive safely will| | | | | |
|B. Have an accident? | | | | | |
+-----------------------------+--------+-------+---------+----------+---------+
number
’string’ A numeric or string category value, for variables that have the corresponding
type.
’date’
’time’ A date or time category value, for variables that have a date or time print
format.
Chapter 15: Statistics 184
If multiple elements of the list cover a given category, the last one in the list takes
precedence.
The following example syntax and output show how an explicit category can limit the
displayed categories:
CTABLES /TABLE freqOfDriving.
CTABLES /TABLE freqOfDriving /CATEGORIES VARIABLES=freqOfDriving [1, 2, 3].
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
| 1. How often do you usually drive a car or other Every day | 4667|
|motor vehicle? Several days a week | 1274|
| Once a week or less | 361|
| Only certain times a| 130|
| year | |
| Never | 540|
+-----------------------------------------------------------------------+-----+
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
| 1. How often do you usually drive a car or other Every day | 4667|
|motor vehicle? Several days a | 1274|
| week | |
| Once a week or | 361|
| less | |
+-----------------------------------------------------------------------+-----+
The KEY setting specifies the sort key. By default, or with KEY=VALUE, categories are
sorted by default. Categories may also be sorted by value label, with KEY=LABEL, or by the
value of a summary function, e.g. KEY=COUNT.
By default, or with ORDER=A, categories are sorted in ascending order. Specify ORDER=D
to sort in descending order.
User-missing values are excluded by default, or with MISSING=EXCLUDE. Specify
MISSING=INCLUDE to include user-missing values. The system-missing value is always
excluded.
The following example syntax and output show how MISSING=INCLUDE causes missing
values to be included in a category list.
CTABLES /TABLE freqOfDriving.
CTABLES /TABLE freqOfDriving
/CATEGORIES VARIABLES=freqOfDriving MISSING=INCLUDE.
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
| 1. How often do you usually drive a car or other Every day | 4667|
|motor vehicle? Several days a week | 1274|
| Once a week or less | 361|
| Only certain times a| 130|
| year | |
| Never | 540|
+-----------------------------------------------------------------------+-----+
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
| 1. How often do you usually drive a car or other Every day | 4667|
|motor vehicle? Several days a week | 1274|
| Once a week or less | 361|
| Only certain times a| 130|
| year | |
| Never | 540|
| Don’t know | 8|
| Refused | 19|
+-----------------------------------------------------------------------+-----+
/TABLE freqOfDriving
/CATEGORIES VARIABLES=freqOfDriving [OTHERNM, SUBTOTAL=’Valid Total’,
MISSING, SUBTOTAL=’Missing Total’]
TOTAL=YES LABEL=’Overall Total’.
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
| 1. How often do you usually drive a car or other Every day | 4667|
|motor vehicle? Several days a week | 1274|
| Once a week or less | 361|
| Only certain times a| 130|
| year | |
| Never | 540|
| Valid Total | 6972|
| Don’t know | 8|
| Refused | 19|
| Missing Total | 27|
| Overall Total | 6999|
+-----------------------------------------------------------------------+-----+
By default, or with POSITION=AFTER, totals are displayed in the output after the last
category and subtotals apply to categories that precede them. With POSITION=BEFORE,
totals come before the first category and subtotals apply to categories that follow them.
Only categorical variables may have totals and subtotals. Scalar variables may be
“totaled” indirectly by enabling totals and subtotals on a categorical variable within which
the scalar variable is summarized. For example, the following syntax produces a mean,
count, and valid count across all data by adding a total on the categorical region variable,
as shown:
CTABLES /TABLE=region > monthDaysMin1drink [MEAN, VALIDN]
/CATEGORIES VARIABLES=region TOTAL=YES LABEL=’All regions’.
Custom Tables
+-----------------------------------------------------------+----+-----+------+
| | | | Valid|
| |Mean|Count| N |
+-----------------------------------------------------------+----+-----+------+
|20. On how many of the thirty days in this Region NE | 5.6| 1409| 945|
|typical month did you have one or more MW | 5.0| 1654| 1026|
|alcoholic beverages to drink? S | 6.0| 2390| 1285|
| W | 6.5| 1546| 953|
| All | 5.8| 6999| 4209|
| regions | | | |
+-----------------------------------------------------------+----+-----+------+
By default, pspp uses the same summary functions for totals and subtotals as other
categories. To summarize totals and subtotals differently, specify the summary functions for
totals and subtotals after the ordinary summary functions inside a nested set of [] following
TOTALS. For example, the following syntax displays COUNT for individual categories and
totals and VALIDN for totals, as shown:
CTABLES
/TABLE isLicensedDriver [COUNT, TOTALS[COUNT, VALIDN]]
/CATEGORIES VARIABLES=isLicensedDriver TOTAL=YES MISSING=INCLUDE.
Custom Tables
Chapter 15: Statistics 187
+----------------------------------------------------------------+-----+------+
| | | Valid|
| |Count| N |
+----------------------------------------------------------------+-----+------+
|D7a. Are you a licensed driver; that is, do you have a Yes | 6379| |
|valid driver’s license? No | 572| |
| Don’t | 4| |
| know | | |
| Refused | 44| |
| Total | 6999| 6951|
+----------------------------------------------------------------+-----+------+
Custom Tables
+-----------------------------------------------------------------------+-----+
| |Count|
+-----------------------------------------------------------------------+-----+
|S1. Including yourself, how many members of this household are 1 | 1586|
|age 16 or older? 2 | 3031|
| 3 | 505|
| 4 | 194|
| 5 | 55|
| 6 or | 21|
| more | |
+-----------------------------------------------------------------------+-----+
15.7.6 Titles
/TITLES
Chapter 15: Statistics 188
[TITLE=string . . . ]
[CAPTION=string . . . ]
[CORNER=string . . . ]
The TITLES subcommand sets the title, caption, and corner text for the table output for
the previous TABLE subcommand. Any number of strings may be specified for each kind of
text, with each string appearing on a separate line in the output. The title appears above
the table, the caption below the table, and the corner text appears in the table’s upper left
corner. By default, the title is “Custom Tables” and the caption and corner text are empty.
With some table output styles, the corner text is not displayed.
The strings provided in this subcommand may contain the following macro-like keywords
that pspp substitutes at the time that it runs the command:
)DATE The current date, e.g. MM/DD/YY. The format is locale-dependent.
)TIME The current time, e.g. HH:MM:SS. The format is locale-dependent.
)TABLE The expression specified on the TABLE command. Summary and measurement
level specifications are omitted, and variable labels are used in place of variable
names.
VARIABLES and DISPLAY are required. The value of DISPLAY controls how variable labels
are displayed for the variables listed on VARIABLES. The supported values are:
DEFAULT Use the setting from SET TVARS (see [SET TVARS], page 272).
NAME Show only a variable name.
LABEL Show only a variable label.
BOTH Show variable name and label.
NONE Show nothing.
| 2 z|10000|
+---------+-----+
If, however, we add CATEGORIES specifications to include missing values for ‘y’ or for ‘x’
and ‘y’, the output table includes them, like so:
CTABLES /TABLE x > y > z [SUM] /CATEGORIES VARIABLES=y MISSING=INCLUDE.
CTABLES /TABLE x > y > z [SUM] /CATEGORIES VARIABLES=x y MISSING=INCLUDE.
Custom Tables
+---------+------+
| | Sum |
+---------+------+
|x 1 y 1 z| 1|
| ----+------+
| 2 z| 10|
| ----+------+
| 9 z| 100|
| --------+------+
| 2 y 1 z| 1000|
| ----+------+
| 2 z| 10000|
| ----+------+
| 9 z|100000|
+---------+------+
Custom Tables
+---------+---------+
| | Sum |
+---------+---------+
|x 1 y 1 z| 1|
| ----+---------+
| 2 z| 10|
| ----+---------+
| 9 z| 100|
| --------+---------+
| 2 y 1 z| 1000|
| ----+---------+
| 2 z| 10000|
| ----+---------+
| 9 z| 100000|
| --------+---------+
| 9 y 1 z| 1000000|
| ----+---------+
| 2 z| 10000000|
| ----+---------+
| 9 z|100000000|
+---------+---------+
By adding SMISSING=LISTWISE, only cases where ‘y’ and ‘z’ are both non-missing are
considered, so ‘x’’s mean becomes 15, as the average of 10 and 20, and ‘y’’s mean becomes
55, the average of 50 and 60:
CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
Custom Tables
+-----+-----+
| | Mean|
+-----+-----+
|y x 1|15.00|
+-----+-----+
|z x 1|55.00|
+-----+-----+
Even with SMISSING=LISTWISE, if ‘y’ and ‘z’ are separately nested with ‘x’, instead of using
a single ‘>’ operator, missing values revert to being considered on a variable-by-variable
basis:
CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
Custom Tables
+-----+-----+
| | Mean|
+-----+-----+
|y x 1|20.00|
+-----+-----+
|z x 1|50.00|
+-----+-----+
15.7.10.1 PCOMPUTE
/PCOMPUTE &postcompute=EXPR(expression)
The PCOMPUTE subcommand, which must precede the first TABLE command, defines
computed categories. It is optional and may be used any number of times to define multiple
postcomputes.
Each PCOMPUTE defines one postcompute. Its syntax consists of a name to identify the
postcompute as a pspp identifier prefixed by ‘&’, followed by ‘=’ and a postcompute expression
enclosed in EXPR(...). A postcompute expression consists of:
[category]
This form evaluates to the summary statistic for category, e.g. [1] evaluates
to the value of the summary statistic associated with category 1. The category
Chapter 15: Statistics 193
may be a number, a quoted string, or a quoted time or date value. All of the
categories for a given postcompute must have the same form. The category
must appear in all the CATEGORIES list in which the postcompute is used.
[min THRU max]
[LO THRU max]
[min THRU HI]
MISSING
OTHERNM These forms evaluate to the summary statistics for a category specified with the
same syntax, as described in previous section (see [CTABLES Explicit Category
List], page 183). The category must appear in all the CATEGORIES list in which
the postcompute is used.
SUBTOTAL The summary statistic for the subtotal category. This form is allowed only if
the CATEGORIES lists that include this postcompute have exactly one subtotal.
SUBTOTAL[index]
The summary statistic for subtotal category index, where 1 is the first subtotal,
2 is the second, and so on. This form may be used for CATEGORIES lists with
any number of subtotals.
TOTAL The summary statistic for the total. The CATEGORIES lsits that include this
postcompute must have a total enabled.
a + b
a - b
a * b
a / b
a ** b These forms perform arithmetic on the values of postcompute expressions a and
b. The usual operator precedence rules apply.
number Numeric constants may be used in postcompute expressions.
(a) Parentheses override operator precedence.
A postcompute is not associated with any particular variable. Instead, it may be
referenced within CATEGORIES for any suitable variable (e.g. only a string variable is suitable
for a postcompute expression that refers to a string category, only a variable with subtotals
for an expression that refers to subtotals, . . . ).
Normally a named postcompute is defined only once, but if a later PCOMPUTE redefines a
postcompute with the same name as an earlier one, the later one take precedence.
The following syntax and output shows how PCOMPUTE can compute a total over subto-
tals, summing the “Frequent Drivers” and “Infrequent Drivers” subtotals to form an “All
Drivers” postcompute. It also shows how to calculate and display a percentage, in this
case the percentage of valid responses that report never driving. It uses PPROPERTIES (see
Section 15.7.10.2 [CTABLES PPROPERTIES], page 194) to display the latter in PCT format.
CTABLES
/PCOMPUTE &all_drivers=EXPR([1 THRU 2] + [3 THRU 4])
/PPROPERTIES &all_drivers LABEL=’All Drivers’
/PCOMPUTE &pct_never=EXPR([5] / ([1 THRU 2] + [3 THRU 4] + [5]) * 100)
/PPROPERTIES &pct_never LABEL=’% Not Drivers’ FORMAT=COUNT PCT40.1
Chapter 15: Statistics 194
/TABLE=freqOfDriving BY gender
/CATEGORIES VARIABLES=freqOfDriving
[1 THRU 2, SUBTOTAL=’Frequent Drivers’,
3 THRU 4, SUBTOTAL=’Infrequent Drivers’,
&all_drivers, 5, &pct_never,
MISSING, SUBTOTAL=’Not Drivers or Missing’].
Custom Tables
+----------------------------------------------------------------+------------+
| |S3a. GENDER:|
| +-----+------+
| | Male|Female|
| +-----+------+
| |Count| Count|
+----------------------------------------------------------------+-----+------+
| 1. How often do you usually drive a car or Every day | 2305| 2362|
|other motor vehicle? Several days a week | 440| 834|
| Frequent Drivers | 2745| 3196|
| Once a week or less | 125| 236|
| Only certain times a| 58| 72|
| year | | |
| Infrequent Drivers | 183| 308|
| All Drivers | 2928| 3504|
| Never | 192| 348|
| % Not Drivers | 6.2%| 9.0%|
| Don’t know | 3| 5|
| Refused | 9| 10|
| Not Drivers or | 204| 363|
| Missing | | |
+----------------------------------------------------------------+-----+------+
15.7.10.2 PPROPERTIES
/PPROPERTIES &postcompute . . .
[LABEL=string]
[FORMAT=[summary format]. . . ]
[HIDESOURCECATS={NO | YES}
The PPROPERTIES subcommand, which must appear before TABLE, sets properties for one
or more postcomputes defined on prior PCOMPUTE subcommands. The subcommand syntax
begins with the list of postcomputes, each prefixed with ‘&’ as specified on PCOMPUTE.
All of the settings on PPROPERTIES are optional. Use LABEL to set the label shown for
the postcomputes in table output. The default label for a postcompute is the expression
used to define it.
A postcompute always uses same summary functions as the variable whose categories
contain it, but FORMAT allows control over the format used to display their values. It takes a
list of summary function names and format specifiers.
By default, or with HIDESOURCECATS=NO, categories referred to by computed categories
are displayed like other categories. Use HIDESOURCECATS=YES to hide them.
The previous section provides an example for PPROPERTIES.
The WEIGHT subcommand is optional and must appear before TABLE. If it appears, it
must name a numeric variable, known as the effective weight or adjustment weight. The
effective weight variable stands in for the dictionary’s weight variable (see Section 13.7
[WEIGHT], page 134), if any, in most calculations in CTABLES. The only exceptions are the
COUNT, TOTALN, and VALIDN summary functions, which use the dictionary weight instead.
Weights obtained from the pspp dictionary are rounded to the nearest integer at the case
level. Effective weights are not rounded. Regardless of the weighting source, pspp does not
analyze cases with zero, missing, or negative effective weights.
15.8 FACTOR
FACTOR {
VARIABLES=var list,
MATRIX IN ({CORR,COV}={*,file spec})
}
Chapter 15: Statistics 196
[ /ANALYSIS=var list ]
[ /EXTRACTION={PC, PAF}]
[ /PLOT=[EIGEN] ]
The /PRINT subcommand may be used to select which features of the analysis are
reported:
• UNIVARIATE A table of mean values, standard deviations and total weights are printed.
• INITIAL Initial communalities and eigenvalues are printed.
• EXTRACTION Extracted communalities and eigenvalues are printed.
• ROTATION Rotated communalities and eigenvalues are printed.
• CORRELATION The correlation matrix is printed.
• COVARIANCE The covariance matrix is printed.
• DET The determinant of the correlation or covariance matrix is printed.
• AIC The anti-image covariance and anti-image correlation matrices are printed.
• KMO The Kaiser-Meyer-Olkin measure of sampling adequacy and the Bartlett test of
sphericity is printed.
• SIG The significance of the elements of correlation matrix is printed.
• ALL All of the above are printed.
• DEFAULT Identical to INITIAL and EXTRACTION.
If /PLOT=EIGEN is given, then a “Scree” plot of the eigenvalues is printed. This can be
useful for visualizing the factors and deciding which factors (components) should be retained.
The /FORMAT subcommand determined how data are to be displayed in loading matrices.
If SORT is specified, then the variables are sorted in descending order of significance. If
BLANK(n) is specified, then coefficients whose absolute value is less than n are not printed.
If the keyword DEFAULT is specified, or if no /FORMAT subcommand is specified, then no
sorting is performed, and all coefficients are printed.
You can use the /CRITERIA subcommand to specify how the number of extracted factors
(components) are chosen. If FACTORS(n) is specified, where n is an integer, then n factors are
extracted. Otherwise, the MINEIGEN setting is used. MINEIGEN(l) requests that all factors
whose eigenvalues are greater than or equal to l are extracted. The default value of l is 1.
The ECONVERGE setting has effect only when using iterative algorithms for factor extraction
(such as Principal Axis Factoring). ECONVERGE(delta) specifies that iteration should cease
when the maximum absolute value of the communality estimate between one iteration and
the previous is less than delta. The default value of delta is 0.001.
The ITERATE(m) may appear any number of times and is used for two different purposes.
It is used to set the maximum number of iterations (m) for convergence and also to set
the maximum number of iterations for rotation. Whether it affects convergence or rotation
depends upon which subcommand follows the ITERATE subcommand. If EXTRACTION follows,
it affects convergence. If ROTATION follows, it affects rotation. If neither ROTATION nor
EXTRACTION follow a ITERATE subcommand, then the entire subcommand is ignored. The
default value of m is 25.
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 subcommand
contains a missing value.
Chapter 15: Statistics 198
If PAIRWISE is set, then a case is considered missing only if either of the values for the
particular coefficient are missing. The default is LISTWISE.
15.9 GLM
GLM dependent vars BY fixed factors
[/METHOD = SSTYPE(type)]
[/DESIGN = interaction 0 [interaction 1 [... interaction n]]]
[/INTERCEPT = {INCLUDE|EXCLUDE}]
[/MISSING = {INCLUDE|EXCLUDE}]
The GLM procedure can be used for fixed effects factorial Anova.
The dependent vars are the variables to be analysed. You may analyse several variables
in the same command in which case they should all appear before the BY keyword.
The fixed factors list must be one or more categorical variables. Normally it does not
make sense to enter a scalar variable in the fixed factors and doing so may cause pspp to do
a lot of unnecessary processing.
The METHOD subcommand is used to change the method for producing the sums of squares.
Available values of type are 1, 2 and 3. The default is type 3.
You may specify a custom design using the DESIGN subcommand. The design comprises
a list of interactions where each interaction is a list of variables separated by a ‘*’. For
example the command
GLM subject BY sex age group race
/DESIGN = age group sex group age group*sex age group*race
specifies the model subject = ageg roup + sex + race + ageg roup ∗ sex + ageg roup ∗ race. If
no DESIGN subcommand is specified, then the default is all possible combinations of the
fixed factors. That is to say
GLM subject BY sex age group race
implies the model subject = ageg roup + sex + race + ageg roup ∗ sex + ageg roup ∗ race +
sex ∗ race + ageg roup ∗ sex ∗ race.
The MISSING subcommand determines the handling of missing variables. If INCLUDE is
set then, for the purposes of GLM analysis, only system-missing values are considered to
be missing; user-missing values are not regarded as missing. If EXCLUDE is set, which is the
default, then user-missing values are considered to be missing as well as system-missing
values. A case for which any dependent variable or any factor variable has a missing value is
excluded from the analysis.
[/MISSING = {INCLUDE|EXCLUDE}]
Bivariate Logistic Regression is used when you want to explain a dichotomous dependent
variable in terms of one or more predictor variables.
The minimum command is
LOGISTIC REGRESSION y WITH x1 x2 ... xn.
Here, y is the dependent variable, which must be dichotomous and x1 . . . xn are the
predictor variables whose coefficients the procedure estimates.
By default, a constant term is included in the model. Hence, the full model is y =
b0 + b1 x1 + b2 x2 + . . . + bn xn
Predictor variables which are categorical in nature should be listed on the /CATEGORICAL
subcommand. Simple variables as well as interactions between variables may be listed here.
If you want a model without the constant term b0 , use the keyword /ORIGIN. /NOCONST
is a synonym for /ORIGIN.
An iterative Newton-Raphson procedure is used to fit the model. The /CRITERIA
subcommand is used to specify the stopping criteria of the procedure, and other parameters.
The value of cut point is used in the classification table. It is the threshold above which
predicted values are considered to be 1. Values of cut point must lie in the range [0,1].
During iterations, if any one of the stopping criteria are satisfied, the procedure is considered
complete. The stopping criteria are:
• The number of iterations exceeds max iterations. The default value of max iterations
is 20.
• The change in the all coefficient estimates are less than min delta. The default value of
min delta is 0.001.
• The magnitude of change in the likelihood estimate is less than min likelihood delta.
The default value of min delta is zero. This means that this criterion is disabled.
• The differential of the estimated probability for all cases is less than min epsilon. In
other words, the probabilities are close to zero or one. The default value of min epsilon
is 0.00000001.
The PRINT subcommand controls the display of optional statistics. Currently there is
one such option, CI, which indicates that the confidence interval of the odds ratio should be
displayed as well as its value. CI should be followed by an integer in parentheses, to indicate
the confidence level of the desired confidence interval.
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.
Chapter 15: Statistics 200
15.11 MEANS
MEANS [TABLES =]
{var list}
[ BY {var list} [BY {var list} [BY {var list} . . . ]]]
[ /{var list}
[ BY {var list} [BY {var list} [BY {var list} . . . ]]] ]
More than one table can be specified in a single command. Each table is separated by a
‘/’. For example
MEANS TABLES =
c d e BY x
/a b BY x y
/f BY y BY z.
has three tables (the ‘TABLE =’ is optional). The first table has three dependent variables
c, d and e and a single categorical variable x. The second table has two dependent variables
a and b, and two categorical variables x and y. The third table has a single dependent
variables f and a categorical variable formed by the combination of y and z.
By default values are omitted from the analysis only if missing values (either system
missing or user missing) for any of the variables directly involved in their calculation are
encountered. This behaviour can be modified with the /MISSING subcommand. Three
options are possible: TABLE, INCLUDE and DEPENDENT.
/MISSING = INCLUDE says that user missing values, either in the dependent variables or
in the categorical variables should be taken at their face value, and not excluded.
/MISSING = DEPENDENT says that user missing values, in the dependent variables should
be taken at their face value, however cases which have user missing values for the categorical
variables should be omitted from the calculation.
get file=’repairs.sav’.
Example 15.4: Running MEANS on the mtbf score with categories factory and environment
The results are shown in Result 15.3. The figures shown indicate the mean, standard
deviation and number of samples in each category. These figures however do not indicate
whether the results are statistically significant. For that, you would need to use the procedures
ONEWAY, GLM or T-TEST depending on the hypothesis being tested.
Case Processing Summary
+----------------------------+-------------------------------+
| | Cases |
| +----------+---------+----------+
| | Included | Excluded| Total |
| +--+-------+-+-------+--+-------+
| | N|Percent|N|Percent| N|Percent|
+----------------------------+--+-------+-+-------+--+-------+
|mtbf * factory * environment|30| 100.0%|0| .0%|30| 100.0%|
+----------------------------+--+-------+-+-------+--+-------+
Report
+--------------------------------------------+-----+--+--------------+
|Manufacturing facility Operating Environment| Mean| N|Std. Deviation|
+--------------------------------------------+-----+--+--------------+
|0 Temperate | 7.26| 9| 2.57|
| Tropical | 7.47| 7| 2.68|
| Total | 7.35|16| 2.53|
+--------------------------------------------+-----+--+--------------+
|1 Temperate |13.38| 6| 7.77|
| Tropical | 8.20| 8| 8.39|
| Total |10.42|14| 8.26|
+--------------------------------------------+-----+--+--------------+
|Total Temperate | 9.71|15| 5.91|
| Tropical | 7.86|15| 6.20|
| Total | 8.78|30| 6.03|
+--------------------------------------------+-----+--+--------------+
Result 15.3: The mtbf categorised by factory and environment
Note that there is no limit to the number of variables for which you can calculate statistics,
nor to the number of categorical variables per layer, nor the number of layers. However,
running MEANS on a large numbers of variables, or with categorical variables containing a
large number of distinct values may result in an extremely large output, which will not be
easy to interpret. So you should consider carefully which variables to select for participation
in the analysis.
[ /STATISTICS={DESCRIPTIVES} ]
The /CHISQUARE subcommand 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 keyword
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
equal frequencies are expected.
get file=’physiology.sav’.
npar test
/chisquare=sex.
Example 15.5: Performing a chi-square test to check for equal distribution of sexes
There is only one test variable, viz: sex. The other variables in the dataset are ignored.
Chapter 15: Statistics 205
Screenshot 15.4: Performing a chi-square test using the graphic user interface
In Result 15.4 the summary box shows that in the sample, there are more males than
females. However the significance of chi-square result is greater than 0.05 — the most
commonly accepted p-value — and therefore there is not enough evidence to reject the
null hypothesis and one must conclude that the evidence does not indicate that there is an
imbalance of the sexes in the population.
Sex of subject
+------+----------+----------+--------+
|Value |Observed N|Expected N|Residual|
+------+----------+----------+--------+
|Male | 22| 20.00| 2.00|
|Female| 18| 20.00| -2.00|
|Total | 40| | |
+------+----------+----------+--------+
Test Statistics
+--------------+----------+--+-----------+
| |Chi-square|df|Asymp. Sig.|
+--------------+----------+--+-----------+
|Sex of subject| .40| 1| .527|
+--------------+----------+--+-----------+
Result 15.4: The results of running a chi-square test on sex
The value of Q is displayed along with its Asymptotic significance based on a chi-square
distribution.
using these two values to determine the groups. If however, the first variable is less than
the second, then a k sample test is conducted and the group values used are all values
encountered which lie in the range [value1,value2].
15.13 T-TEST
T-TEST
/MISSING={ANALYSIS,LISTWISE} {EXCLUDE,INCLUDE}
/CRITERIA=CI(confidence)
TESTVAL=test value
/VARIABLES=var list
The T-TEST procedure outputs tables used in testing hypotheses about means. It operates
in one of three modes:
• One Sample mode.
• Independent Groups mode.
• Paired mode.
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.
As previously noted (see Section 5.2.1 [Identifying incorrect data], page 15), one sample
in the dataset contains a weight value which is clearly incorrect. So this is excluded from
the analysis using the SELECT command.
get file=’physiology.sav’.
Example 15.6: Running a one sample T-Test after excluding all non-positive values
Screenshot 15.5: Using the One Sample T-Test dialog box to test weight for a mean of
76.8kg
Results 15.2 shows that the mean of our sample differs from the test value by -1.40kg.
However the significance is very high (0.610). So one cannot reject the null hypothesis, and
must conclude there is not enough evidence to suggest that the mean weight of the persons
in our population is different from 76.8kg.
Chapter 15: Statistics 211
One-Sample Statistics
+-------------------+--+-----+--------------+---------+
| | N| Mean|Std. Deviation|S.E. Mean|
+-------------------+--+-----+--------------+---------+
|Weight in kilograms|39|75.40| 17.08| 2.73|
+-------------------+--+-----+--------------+---------+
One-Sample Test
+--------------+--------------------------------------------------------------+
| | Test Value = 76.8 |
| +----+--+------------+------------+----------------------------+
| | | | | | 95% Confidence Interval of |
| | | | | | the Difference |
| | | | Sig. (2- | Mean +--------------+-------------+
| | t |df| tailed) | Difference | Lower | Upper |
+--------------+----+--+------------+------------+--------------+-------------+
|Weight in |-.51|38| .610| -1.40| -6.94| 4.13|
|kilograms | | | | | | |
+--------------+----+--+------------+------------+--------------+-------------+
Results 15.2: The results of a one sample T-test of weight using a test value of 76.8kg
The variable given in the GROUPS subcommand is the independent variable which deter-
mines 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.
As previously noted (see Section 5.2.1 [Identifying incorrect data], page 15), one sample
in the dataset contains a height value which is clearly incorrect. So this is excluded from
the analysis using the SELECT command.
Chapter 15: Statistics 212
get file=’physiology.sav’.
Example 15.7: Running a independent samples T-Test after excluding all observations
less than 200kg
The null hypothesis is that both males and females are on average of equal height.
Screenshot 15.6: Using the Independent Sample T-test dialog, to test for differences of
height between values of sex
In this case, the grouping variable is sex, so this is entered as the variable for the GROUP
subcommand. The group values are 0 (male) and 1 (female).
If you are running the proceedure using syntax, then you need to enter the values
corresponding to each group within parentheses. If you are using the graphic user interface,
then you have to open the “Define Groups” dialog box and enter the values corresponding
to each group as shown in Screenshot 15.7. If, as in this case, the dataset has defined value
labels for the group variable, then you can enter them by label or by value.
Chapter 15: Statistics 213
Screenshot 15.7: Setting the values of the grouping variable for an Independent Samples
T-test
From Result 15.5, one can clearly see that the sample mean height is greater for males
than for females. However in order to see if this is a significant result, one must consult the
T-Test table.
The T-Test table contains two rows; one for use if the variance of the samples in each
group may be safely assumed to be equal, and the second row if the variances in each group
may not be safely assumed to be equal.
In this case however, both rows show a 2-tailed significance less than 0.001 and one must
therefore reject the null hypothesis and conclude that within the population the mean height
of males and of females are unequal.
Chapter 15: Statistics 214
Group Statistics
+----------------------------+--+-------+--------------+---------+
| Group | N| Mean |Std. Deviation|S.E. Mean|
+----------------------------+--+-------+--------------+---------+
|Height in millimeters Male |22|1796.49| 49.71| 10.60|
| Female|17|1610.77| 25.43| 6.17|
+----------------------------+--+-------+--------------+---------+
+---------------------+-------------+
| | |
| | |
| | |
| | |
| | |
| +-------------+
| | 95% |
| | Confidence |
| | Interval of |
| | the |
| | Difference |
| +------+------+
| | Lower| Upper|
+---------------------+------+------+
|Height in Equal |158.88|212.55|
|millimeters variances| | |
| assumed | | |
| Equal |160.76|210.67|
| variances| | |
| not | | |
| assumed | | |
+---------------------+------+------+
Result 15.5: The results of an independent samples T-test of height by sex
Chapter 15: Statistics 215
15.14 ONEWAY
ONEWAY
[/VARIABLES = ] var list BY var
/MISSING={ANALYSIS,LISTWISE} {EXCLUDE,INCLUDE}
/CONTRAST= value1 [, value2] ... [,valueN ]
/STATISTICS={DESCRIPTIVES,HOMOGENEITY}
/POSTHOC={BONFERRONI, GH, LSD, SCHEFFE, SIDAK, TUKEY, AL-
PHA ([value])}
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 dependent 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 ancillary information.
The options accepted are:
• DESCRIPTIVES Displays descriptive statistics about the groups factored by the
independent variable.
• HOMOGENEITY Displays the Levene test of Homogeneity of Variance for the variables
and their groups.
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. The
MISSING subcommand defines how missing values are handled. If LISTWISE is specified then
cases which have missing values for the independent variable or any dependent variable
are ignored. If ANALYSIS is specified, then cases are ignored if the independent variable is
missing or if the dependent variable currently being analysed is missing. The default is
ANALYSIS. A setting of EXCLUDE means that variables whose values are user-missing are to
be excluded from the analysis. A setting of INCLUDE means they are to be included. The
default is EXCLUDE.
Chapter 15: Statistics 216
Using the POSTHOC subcommand you can perform multiple pairwise comparisons on the
data. The following comparison methods are available:
• LSD Least Significant Difference.
• TUKEY Tukey Honestly Significant Difference.
• BONFERRONI Bonferroni test.
• SCHEFFE Scheffé’s test.
• SIDAK Sidak test.
• GH The Games-Howell test.
Use the optional syntax ALPHA(value) to indicate that ONEWAY should perform the posthoc
tests at a confidence level of value. If ALPHA(value) is not specified, then the confidence
level used is 0.05.
If LISTWISE is set, then the entire case is excluded from the analysis whenever any of the
clustering variables contains a missing value. If PAIRWISE is set, then a case is considered
missing only if all the clustering variables contain missing values. Otherwise it is clustered
on the basis of the non-missing values. The default is LISTWISE.
The PRINT subcommand requests additional output to be printed. If INITIAL is set, then
the initial cluster memberships will be printed. If CLUSTER is set, the cluster memberships
of the individual cases are displayed (potentially generating lengthy output).
You can specify the subcommand SAVE to ask that each case’s cluster membership and
the euclidean distance between the case and its cluster center be saved to a new variable in
the active dataset. To save the cluster membership use the CLUSTER keyword and to save the
distance use the DISTANCE keyword. Each keyword may optionally be followed by a variable
name in parentheses to specify the new variable which is to contain the saved parameter. If
no variable name is specified, then PSPP will create one.
15.16 RANK
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}
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.
15.17 REGRESSION
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 data set contains n observations of a dependent variable, say Y1 , . . . , Yn , and n
observations of one or more explanatory variables. Let X11 , X12 , . . . , X1n denote the n
observations of the first explanatory variable; X21 ,. . . ,X2n denote the n observations
of the second explanatory variable; Xk1 ,. . . ,Xkn denote the n observations of the kth
explanatory variable.
• The dependent variable Y has the following relationship to the explanatory variables:
Yi = b0 + b1 X1i + ... + bk Xki + Zi where b0 , b1 , . . . , bk are unknown coefficients, and
Z1 , . . . , Zn are independent, normally distributed noise terms with mean zero and
common variance. The noise, or error terms are unobserved. This relationship is called
the linear model.
The REGRESSION procedure estimates the coefficients b0 , . . . , bk and produces output
relevant to inferences for the linear model.
15.17.1 Syntax
REGRESSION
/VARIABLES=var list
/DEPENDENT=var list
/STATISTICS={ALL, DEFAULTS, R, COEFF, ANOVA, BCOV, CI[conf, TOL]}
{ /ORIGIN | /NOORIGIN }
/SAVE={PRED, RESID}
The REGRESSION procedure reads the active dataset 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 which statistics are to be displayed. The following
keywords are accepted:
Chapter 15: Statistics 219
15.17.2 Examples
The following pspp syntax will generate the default output and save the predicted values
and residuals to the active dataset.
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.
Chapter 15: Statistics 220
list.
regression /variables=v0 v1 v2 /statistics defaults /dependent=v2
/save pred resid /method=enter.
15.18 RELIABILITY
RELIABILITY
/VARIABLES=var list
/SCALE (name) = {var list, ALL}
/MODEL={ALPHA, SPLIT[(n)]}
/SUMMARY={TOTAL,ALL}
/MISSING={EXCLUDE,INCLUDE}
The RELIABILITY command performs reliability analysis on the data.
The VARIABLES subcommand is required. It determines the set of variables upon which
analysis is to be performed.
The SCALE subcommand determines the variables for which reliability is to be calculated.
If SCALE is omitted, then analysis for all variables named in the VARIABLES subcommand are
used. Optionally, the name parameter may be specified to set a string name for the scale.
The MODEL subcommand determines the type of analysis. If ALPHA is specified, then
Cronbach’s Alpha is calculated for the scale. If the model is SPLIT, then the variables are
divided into 2 subsets. An optional parameter n may be given, to specify how many variables
to be in the first subset. If n is omitted, then it defaults to one half of the variables in the
scale, or one half minus one if there are an odd number of variables. The default model is
ALPHA.
By default, any cases with user missing, or system missing values for any variables given
in the VARIABLES subcommand are omitted from the analysis. The MISSING subcommand
determines whether user missing values are included or excluded in the analysis.
The SUMMARY subcommand determines the type of summary analysis to be performed.
Currently there is only one type: SUMMARY=TOTAL, which displays per-item analysis tested
against the totals.
get file="hotel.sav".
reliability
/variables= all
/model=alpha.
Example 15.8: Investigating the reliability of survey responses
In this case, all variables in the data set are used. So we can use the special keyword
‘ALL’ (see Section 6.10 [BNF], page 43).
Screenshot 15.8: Reliability dialog box with all variables selected
Result 15.6 shows that Cronbach’s Alpha is 0.11 which is a value normally considered
too low to indicate consistency within the data. This is possibly due to the small number
of survey questions. The survey should be redesigned before serious use of the results are
applied.
Chapter 15: Statistics 222
Scale: ANY
Reliability Statistics
+----------------+----------+
|Cronbach’s Alpha|N of Items|
+----------------+----------+
| .11| 5|
+----------------+----------+
Result 15.6: The results of the reliability command on hotel.sav
15.19 ROC
ROC var list BY state var (state value)
/PLOT = { CURVE [(REFERENCE)], NONE }
/PRINT = [ SE ] [ COORDINATES ]
/CRITERIA = [ CUTOFF({INCLUDE,EXCLUDE}) ]
[ TESTPOS ({LARGE,SMALL}) ]
[ CI (confidence) ]
[ DISTRIBUTION ({FREE, NEGEXPO }) ]
/MISSING={EXCLUDE,INCLUDE}
The ROC command is used to plot the receiver operating characteristic curve of a dataset,
and to estimate the area under the curve. This is useful for analysing the efficacy of a
variable as a predictor of a state of nature.
The mandatory var list is the list of predictor variables. The variable state var is the
variable whose values represent the actual states, and state value is the value of this variable
which represents the positive state.
The optional subcommand PLOT is used to determine if and how the ROC curve is drawn.
The keyword CURVE means that the ROC curve should be drawn, and the optional keyword
REFERENCE, which should be enclosed in parentheses, says that the diagonal reference line
should be drawn. If the keyword NONE is given, then no ROC curve is drawn. By default, the
curve is drawn with no reference line.
The optional subcommand PRINT determines which additional tables should be printed.
Two additional tables are available. The SE keyword says that standard error of the area
under the curve should be printed as well as the area itself. In addition, a p-value for the null
hypothesis that the area under the curve equals 0.5 is printed. The COORDINATES keyword
says that a table of coordinates of the ROC curve should be printed.
The CRITERIA subcommand has four optional parameters:
• The TESTPOS parameter may be LARGE or SMALL. LARGE is the default, and says that
Chapter 15: Statistics 223
larger values in the predictor variables are to be considered positive. SMALL indicates
that smaller values should be considered positive.
• The CI parameter specifies the confidence interval that should be printed. It has no
effect if the SE keyword in the PRINT subcommand has not been given.
• The DISTRIBUTION parameter determines the method to be used when estimating
the area under the curve. There are two possibilities, viz : FREE and NEGEXPO. The
FREE method uses a non-parametric estimate, and the NEGEXPO method a bi-negative
exponential distribution estimate. The NEGEXPO method should only be used when the
number of positive actual states is equal to the number of negative actual states. The
default is FREE.
• The CUTOFF parameter is for compatibility and is ignored.
The MISSING subcommand determines whether user missing values are to be included or
excluded in the analysis. The default behaviour is to exclude them. Cases are excluded on a
listwise basis; if any of the variables in var list or if the variable state var is missing, then
the entire case is excluded.
224
16 Matrices
Some pspp procedures work with matrices by producing numeric matrices that report results
of data analysis, or by consuming matrices as a basis for further analysis. This chapter
documents the format of data files that store these matrices and commands for working
with them, as well as pspp’s general-purpose facility for matrix operations.
Row Types
Matrix files support a fixed set of types of matrix and vector data. The ROWTYPE_ variable
in each case of a matrix file indicates its row type.
The supported matrix row types are listed below. Each type is listed with the keyword
that identifies it in ROWTYPE_. All supported types of matrices are square, meaning that each
matrix must include one row per continuous variable, with the VARNAME_ variable indicating
each continuous variable in turn in the same order as the dictionary.
CORR Correlation coefficients.
COV Covariance coefficients.
MAT General-purpose matrix.
N_MATRIX Counts.
PROX Proximities matrix.
Chapter 16: Matrices 225
The supported vector row types are listed below, along with their associated keyword.
Vector row types only require a single row, whose VARNAME_ is blank:
COUNT Unweighted counts.
DFE Degrees of freedom.
MEAN Means.
MSE Mean squared errors.
N Counts.
STDDEV Standard deviations.
Only the row types listed above may appear in matrix files. The MATRIX DATA command,
however, accepts the additional row types listed below, which it changes into matrix file row
types as part of its conversion process:
N_VECTOR Synonym for N.
SD Synonym for STDDEV.
N_SCALAR Accepts a single number from the MATRIX DATA input and writes it as an N row
with the number replicated across all the continuous variables.
The FILE subcommand specifies the source of the command’s input. To read input from
a text file, specify its name in quotes. To supply input inline, omit FILE or specify INLINE.
Inline data must directly follow MATRIX DATA, inside BEGIN DATA (see Section 8.1 [BEGIN
DATA], page 62).
VARIABLES is the only required subcommand. It names the variables present in each input
record in the order that they appear. (MATRIX DATA reorders the variables in the matrix
file it produces, if needed to fit the matrix file format.) The variable list must include split
variables and factor variables, if they are present in the data, in addition to the continuous
variables that form matrix rows and columns. It may also include a special variable named
ROWTYPE_.
Matrix data may include split variables or factor variables or both. List split variables, if
any, on the SPLIT subcommand and factor variables, if any, on the FACTORS subcommand.
Split and factor variables must be numeric. Split and factor variables must also be listed
on VARIABLES, with one exception: if VARIABLES does not include ROWTYPE_, then SPLIT
may name a single variable that is not in VARIABLES (see [MATRIX DATA Example 8],
page 230).
The FORMAT subcommand accepts settings to describe the format of the input data:
LIST (default)
FREE LIST requires each row to begin at the start of a new input line. FREE allows
rows to begin in the middle of a line. Either setting allows a single row to
continue across multiple input lines.
LOWER (default)
UPPER
FULL With LOWER, only the lower triangle is read from the input data and the
upper triangle is mirrored across the main diagonal. UPPER behaves similarly
for the upper triangle. FULL reads the entire matrix.
DIAGONAL (default)
NODIAGONAL
With DIAGONAL, the main diagonal is read from the input data. With
NODIAGONAL, which is incompatible with FULL, the main diagonal is not
read from the input data but instead set to 1 for correlation matrices and
system-missing for others.
Example 3: N subcommand
This syntax uses the N subcommand in place of an N vector. It produces the same matrix
file as examples 1 and 2.
MATRIX DATA
VARIABLES=ROWTYPE_ var01 TO var08
/FORMAT=UPPER NODIAGONAL
/N 92.
BEGIN DATA.
MEAN 24.3 5.4 69.7 20.1 13.4 2.7 27.9 3.7
SD 5.7 1.5 23.5 5.8 2.8 4.5 5.4 1.5
CORR .17 .50 -.33 .27 .36 -.22 .18
CORR .29 .29 -.20 .32 .12 .38
CORR .05 .20 -.15 .16 .21
CORR .20 .32 -.17 .12
CORR .27 .12 -.24
CORR -.20 -.38
CORR .04
END DATA.
END DATA.
.7 .5 .4 1
44 45 34 39
23 15 51 46
98 34 87 23
1 .2 .3 .4
.2 1 .5 .6
.3 .5 1 .7
.4 .6 .7 1
END DATA.
.9 1
.8 .6 1
.7 .5 .4 1
END DATA.
16.3 MCONVERT
MCONVERT
[[MATRIX=]
[IN({‘*’|’file’})]
[OUT({‘*’|’file’})]]
[/{REPLACE,APPEND}].
The MCONVERT command converts matrix data from a correlation matrix and a vector of
standard deviations into a covariance matrix, or vice versa.
By default, MCONVERT both reads and writes the active file. Use the MATRIX subcommand
to specify other files. To read a matrix file, specify its name inside parentheses following IN.
To write a matrix file, specify its name inside parentheses following OUT. Use ‘*’ to explicitly
specify the active file for input or output.
When MCONVERT reads the input, by default it substitutes a correlation matrix and a
vector of standard deviations each time it encounters a covariance matrix, and vice versa.
Specify /APPEND to instead have MCONVERT add the other form of data without removing
the existing data. Use /REPLACE to explicitly request removing the existing data.
Chapter 16: Matrices 233
The MCONVERT command requires its input to be a matrix file. Use MATRIX DATA to
convert text input into matrix file format. See Section 16.2 [MATRIX DATA], page 225, for
details.
16.4 MATRIX
MATRIX.
. . . matrix commands . . .
END MATRIX.
The following basic matrix commands are supported:
COMPUTE variable[(index [,index ])]=expression.
CALL procedure(argument, . . . ).
PRINT [expression]
[/FORMAT=format]
[/TITLE=title]
[/SPACE={NEWPAGE | n}]
[{/RLABELS=string . . . | /RNAMES=expression}]
[{/CLABELS=string . . . | /CNAMES=expression}].
The following matrix commands offer support for flow control:
DO IF expression.
. . . matrix commands . . .
[ELSE IF expression.
. . . matrix commands . . . ]. . .
[ELSE
. . . matrix commands . . . ]
END IF.
BREAK.
The following matrix commands support matrix input and output:
READ variable[(index [,index ])]
[/FILE=file]
/FIELD=first TO last [BY width]
[/FORMAT=format]
[/SIZE=expression]
[/MODE={RECTANGULAR | SYMMETRIC}]
[/REREAD].
WRITE expression
[/OUTFILE=file]
/FIELD=first TO last [BY width]
[/MODE={RECTANGULAR | TRIANGULAR}]
[/HOLD]
[/FORMAT=format].
Chapter 16: Matrices 234
The following sections describe the details of the matrix language: first, the syntax of
matrix expressions, then each of the supported commands. The COMMENT command (see
Section 17.4 [COMMENT], page 261) is also supported.
{m, c; r, 10} ⇒ 3 4 8
5 6 10
7 14 5
{c, 2 * c, T(r)} ⇒
8 16 6
Chapter 16: Matrices 236
0 5 0 10
6 7 12 14
0 15 0 20
18 21 24 28
RANK (M) [Matrix Function]
Returns the rank of matrix M, a integer scalar whose value is the dimension of the
vector space spanned by its columns or, equivalently, by its rows.
RANK({1, 0, 1; -2, -3, 1; 3, 3, 0}) ⇒ 2
RANK({1, 1, 0, 2; -1, -1, 0, -2}) ⇒ 1
RANK({1, -1; 1, -1; 0, 0; 2, -2}) ⇒ 1
RANK({1, 2, 1; -2, -3, 1; 3, 5, 0}) ⇒ 2
RANK({1, 0, 2; 2, 1, 0; 3, 2, 1}) ⇒ 3
SOLVE (Ma, Mb) [Matrix Function]
Ma must be an n × n matrix, with det(Ma) 6= 0, and Mb an n × k matrix. Returns an
n × k matrix X such that Ma × X = Mb.
All of the following examples show approximate results:
SOLVE({2, 3; 4, 9}, {6, 2; 15, 5}) ⇒
1.50 .50
1.00 .33
SOLVE({1, 3, -2; 3, 5, 6; 2, 4, 3}, {5; 7; 8}) ⇒
-15.00
8.00
2.00
SOLVE({2, 1, -1; -3, -1, 2; -2, 1, 2}, {8; -11; -3}) ⇒
2.00
3.00
-1.00
SVAL (M) [Matrix Function]
Given n × k matrix M, returns a min(n, k)-element column vector containing the
singular values of M in descending order.
Use CALL SVD (see [CALL SVD], page 249) to compute the full singular value decom-
position of a matrix.
SVAL({1, 1; 0, 0}) ⇒ {1.41; .00}
SVAL({1, 0, 1; 0, 1, 1; 0, 0, 0}) ⇒ {1.73; 1.00; .00}
SVAL({2, 4; 1, 3; 0, 0; 0, 0}) ⇒ {5.46; .37}
SWEEP (M, nk) [Matrix Function]
Given r × c matrix M and integer scalar k = nk such that 1 ≤ k ≤ min(r, c), returns
the r × c sweep matrix A.
If M kk 6= 0, then:
Akk = 1/M kk ,
Aik = −M ik /M kk for i 6= k,
Akj = M kj /M kk for j 6= k, and
Aij = M ij − M ik M kj /M kk for i 6= k and j 6= k.
Chapter 16: Matrices 247
If M kk = 0, then:
Aik = Aki = 0 and
Aij = M ij , for i 6= k and j 6= k.
Given M = {0, 1, 2; 3, 4, 5; 6, 7, 8}, then (approximately):
SWEEP(M, 1) ⇒
.00 .00 .00
.00 4.00 5.00
.00 7.00 8.00
SWEEP(M, 2) ⇒
-.75 -.25 .75
.75 .25 1.25
.75 -1.75 -.75
SWEEP(M, 3) ⇒
-1.50 -.75 -.25
-.75 -.38 -.63
.75 .88 .13
The EOF function gives a matrix program the flexibility to read a file with text data
without knowing the length of the file in advance. For example, the following program will
read all the lines of data in data.txt, each consisting of three numbers, as rows in matrix
data:
MATRIX.
COMPUTE data={}.
LOOP IF NOT EOF(’data.txt’).
READ row/FILE=’data.txt’/FIELD=1 TO 1000/SIZE={1,3}.
COMPUTE data={data; row}.
Chapter 16: Matrices 248
END LOOP.
PRINT data.
END MATRIX.
eval
1
1
evec2
-.6666666667 .0000000000 .7453559925
Chapter 16: Matrices 249
eval2
8.0000000000
-1.0000000000
-1.0000000000
CALL SVD(M, U, S, V)
Computes the singular value decomposition of n × k matrix M, assigning S
a n × k diagonal matrix and to U and V unitary k × k matrices such that
M = U × S × V T . The main diagonal of Q contains the singular values of M.
Use the SVAL function (see [SVAL], page 246) to compute just the singular
values of a matrix.
For example, the following matrix program:
CALL SVD({3, 2, 2; 2, 3, -2}, u, s, v).
PRINT (u * s * T(v))/FORMAT F5.1.
yields this output:
(u * s * T(v))
3.0 2.0 2.0
2.0 3.0 -2.0
The final procedure is implemented via CALL to allow it to modify a matrix instead
of returning a modified version. For this procedure, the output argument must name an
existing variable.
CALL SETDIAG(M, V)
Replaces the main diagonal of n × p matrix M by the contents of k-element
vector V. If k = 1, so that V is a scalar, replaces all of the diagonal elements of
M by V. If k < min(n, p), only the upper k diagonal elements are replaced; if
k > min(n, p), then the extra elements of V are ignored.
Use the MDIAG function (see [MDIAG], page 242) to construct a new matrix
with a specified main diagonal.
For example, this matrix program:
COMPUTE x={1, 2, 3; 4, 5, 6; 7, 8, 9}.
CALL SETDIAG(x, 10).
PRINT x.
outputs the following:
x
10 2 3
4 10 6
7 8 10
[/TITLE=title]
[/SPACE={NEWPAGE | n}]
[{/RLABELS=string . . . | /RNAMES=expression}]
[{/CLABELS=string . . . | /CNAMES=expression}].
The PRINT command is commonly used to display a matrix. It evaluates the restricted
expression, if present, and outputs it either as text or a pivot table, depending on the setting
of MDISPLAY (see [SET MDISPLAY], page 270).
Use the FORMAT subcommand to specify a format, such as F8.2, for displaying the matrix
elements. FORMAT is optional for numerical matrices. When it is omitted, pspp chooses how
to format entries automatically using m, the magnitude of the largest-magnitude element in
the matrix to be displayed:
1. If m < 1011 and the matrix’s elements are all integers, pspp chooses the narrowest F
format that fits m plus a sign. For example, if the matrix is {1:10}, then m = 10,
which fits in 3 columns with room for a sign, the format is F3.0.
2. Otherwise, if m ≥ 109 or m ≤ 10−4 , pspp scales all of the numbers in the matrix by
10x , where x is the exponent that would be used to display m in scientific notation. For
example, for m = 5.123 × 1020 , the scale factor is 1020 . pspp displays the scaled values
in format F13.10 and notes the scale factor in the output.
3. Otherwise, pspp displays the matrix values, without scaling, in format F13.10.
The optional TITLE subcommand specifies a title for the output text or table, as a quoted
string. When it is omitted, the syntax of the matrix expression is used as the title.
Use the SPACE subcommand to request extra space above the matrix output. With a
numerical argument, it adds the specified number of lines of blank space above the matrix.
With NEWPAGE as an argument, it prints the matrix at the top of a new page. The SPACE
subcommand has no effect when a matrix is output as a pivot table.
The RLABELS and RNAMES subcommands, which are mutually exclusive, can supply a label
to accompany each row in the output. With RLABELS, specify the labels as comma-separated
strings or other tokens. With RNAMES, specify a single expression that evaluates to a vector
of strings. Either way, if there are more labels than rows, the extra labels are ignored, and if
there are more rows than labels, the extra rows are unlabeled. For output to a pivot table
with RLABELS, the labels can be any length; otherwise, the labels are truncated to 8 bytes.
The CLABELS and CNAMES subcommands work for labeling columns as RLABELS and
RNAMES do for labeling rows.
When the expression is omitted, PRINT does not output a matrix. Instead, it outputs
only the text specified on TITLE, if any, preceded by any space specified on the SPACE
subcommand, if any. Any other subcommands are ignored, and the command acts as if
MDISPLAY is set to TEXT regardless of its actual setting.
The following syntax demonstrates two different ways to label the rows and columns of a
matrix with PRINT:
MATRIX.
COMPUTE m={1, 2, 3; 4, 5, 6; 7, 8, 9}.
PRINT m/RLABELS=a, b, c/CLABELS=x, y, z.
BREAK.
The LOOP command executes a nested group of matrix commands, called the loop’s body,
repeatedly. It has three optional clauses that control how many times the loop body executes.
Regardless of these clauses, the global MXLOOPS setting, which defaults to 40, also limits the
number of iterations of a loop. To iterate more times, raise the maximum with SET MXLOOPS
outside of the MATRIX command (see [SET MXLOOPS], page 269).
The optional index clause causes var to be assigned successive values on each trip through
the loop: first first, then first + step, then first + 2 × step, and so on. The loop ends when
var > last, for positive step, or var < last, for negative step. If step is not specified, it
defaults to 1. All the index clause expressions must evaluate to scalars, and non-integers are
rounded toward zero. If step evaluates as zero (or rounds to zero), then the loop body never
executes.
The optional IF on LOOP is evaluated before each iteration through the loop body. If its
expression, which must evaluate to a scalar, is zero or negative, then the loop terminates
without executing the loop body.
The optional IF on END LOOP is evaluated after each iteration through the loop body. If
its expression, which must evaluate to a scalar, is zero or negative, then the loop terminates.
The following computes and prints l(n), whose value is the number of steps in the Juggler
sequence (https://en.wikipedia.org/wiki/Juggler_sequence) for n, for n from 2 to 10
inclusive:
COMPUTE l = {}.
LOOP n = 2 TO 10.
COMPUTE a = n.
LOOP i = 1 TO 100.
DO IF MOD(a, 2) = 0.
COMPUTE a = TRUNC(a &** (1/2)).
ELSE.
COMPUTE a = TRUNC(a &** (3/2)).
END IF.
END LOOP IF a = 1.
COMPUTE l = {l; i}.
END LOOP.
PRINT l.
COMPUTE i = 1.
LOOP.
DO IF MOD(a, 2) = 0.
COMPUTE a = TRUNC(a &** (1/2)).
ELSE.
COMPUTE a = TRUNC(a &** (3/2)).
END IF.
DO IF a = 1.
BREAK.
END IF.
COMPUTE i = i + 1.
END LOOP.
COMPUTE l = {l; i}.
END LOOP.
PRINT l.
4, 5, 6
1
2 3
4 5 6
1
23
456
The READ command will read as many lines of input as needed for a particular row, so
it’s also acceptable to break any of the lines above into multiple lines. For example, the first
line 1, 2, 4 could be written with a line break following either or both commas.
previously declared on FILE HANDLE (see Section 8.8 [FILE HANDLE], page 68). Later
WRITE commands (in syntax order) use the previous referenced file if FILE is omitted.
The FIELD and FORMAT subcommands specify how output lines are formed. FIELD is
required, but FORMAT is optional. See Section 16.4.8 [Matrix READ and WRITE Commands],
page 253, for details.
By default, or with MODE=RECTANGULAR, the command writes an entry for every row and
column. With MODE=TRIANGULAR, the command writes only the entries on and below the
matrix’s main diagonal. Entries above the diagonal are not written. Only square matrices
may be written with MODE=TRIANGULAR.
Ordinarily, each WRITE command writes complete lines to the output file. With HOLD,
the final line written by WRITE will be held back for the next WRITE command to augment.
This can be useful to write more than one matrix on a single output line.
• To read data into a submatrix, specify the name of an existing variable, followed by
an indexing expression, just after GET. The submatrix must have as many columns as
variables specified on VARIABLES and as many rows as cases in the input file.
Specify the name or handle of the file to be read on FILE. Use ‘*’, or simply omit
the FILE subcommand, to read from the active file. Reading from the active file is only
permitted if it was already defined outside MATRIX.
List the variables to be read as columns in the matrix on the VARIABLES subcommand.
The list can use TO for collections of variables or ALL for all variables. If VARIABLES is
omitted, all variables are read. Only numeric variables may be read.
If a variable is named on NAMES, then the names of the variables read as data columns
are stored in a string vector within the given name, replacing any existing matrix variable
with that name. Variable names are truncated to 8 bytes.
The MISSING and SYSMIS subcommands control the treatment of missing values in the
input file. By default, any user- or system-missing data in the variables being read from the
input causes an error that prevents GET from executing. To accept missing values, specify
one of the following settings on MISSING:
ACCEPT Accept user-missing values with no change.
By default, system-missing values still yield an error. Use the SYSMIS subcom-
mand to change this treatment:
OMIT Skip any case that contains a system-missing value.
number Recode the system-missing value to number.
OMIT Skip any case that contains any user- or system-missing value.
number Recode all user- and system-missing values to number.
The SYSMIS subcommand has an effect only with MISSING=ACCEPT.
By default, SAVE names the variables in the output file COL1 through COLn. Use VARIABLES
or NAMES to give the variables meaningful names. The VARIABLES subcommand accepts a
comma-separated list of variable names. Its alternative, NAMES, instead accepts an expression
that must evaluate to a row or column string vector of names. The number of names need
not exactly match the number of columns in the matrix to be written: extra names are
ignored; extra columns use default names.
By default, SAVE assumes that the matrix to be written is all numeric. To write string
columns, specify a comma-separated list of the string columns’ variable names on STRINGS.
17 Utilities
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.
17.2 CACHE
CACHE.
This command is accepted, for compatibility, but it has no effect.
17.3 CD
CD ’new directory’ .
CD changes the current directory. The new directory becomes that specified by the
command.
17.4 COMMENT
Comment commands:
COMMENT comment text . . . .
*comment text . . . .
17.5 DOCUMENT
DOCUMENT documentary text.
DOCUMENT adds one or more lines of descriptive commentary to the active dataset.
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 dataset with DROP
DOCUMENTS.
Specify the documentary text following the DOCUMENT keyword. It is interpreted literally—
any quotes or other punctuation marks are included in the file. You can extend the docu-
mentary text over as many lines as necessary, including blank lines to separate paragraphs.
Lines are truncated at 80 bytes. Don’t forget to terminate the command with a dot at the
end of a line. See Section 17.1 [ADD DOCUMENT], page 261.
17.9 ECHO
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 Section 6.1 [Tokens],
page 25).
17.10 ERASE
ERASE FILE file name.
ERASE FILE deletes a file from the local file system. file name must be quoted. This
command cannot be used if the SAFER (see Section 17.20 [SET], page 266) setting is active.
Chapter 17: Utilities 263
17.11 EXECUTE
EXECUTE.
EXECUTE causes the active dataset to be read and all pending transformations to be
executed.
17.13 FINISH
FINISH.
FINISH terminates the current pspp session and returns control to the operating system.
17.14 HOST
In the syntax below, the square brackets must be included in the command syntax and do
not indicate that that their contents are optional.
HOST COMMAND=[’command’...]
TIMELIMIT=secs.
HOST executes one or more commands, each provided as a string in the required COMMAND
subcommand, in the shell of the underlying operating system. PSPP runs each command in
a separate shell process and waits for it to finish before running the next one. If a command
fails (with a nonzero exit status, or because it is killed by a signal), then PSPP does not run
any remaining commands.
PSPP provides /dev/null as the shell’s standard input. If a process needs to read from
stdin, redirect from a file or device, or use a pipe.
PSPP displays the shell’s standard output and standard error as PSPP output. Redirect
to a file or /dev/null or another device if this is not desired.
The following example runs rsync to copy a file from a remote server to the local file
data.txt, writing rsync’s own output to rsync-log.txt. PSPP displays the command’s
error output, if any. If rsync needs to prompt the user (e.g. to obtain a password), the
command fails. Only if the rsync succeeds, PSPP then runs the sha512sum command.
HOST COMMAND=[’rsync remote:data.txt data.txt > rsync-log.txt’
’sha512sum -c data.txt.sha512sum].
By default, PSPP waits as long as necessary for the series of commands to complete. Use
the optional TIMELIMIT subcommand to limit the execution time to the specified number of
seconds.
PSPP built for mingw does not support all the features of HOST.
PSPP rejects this command if the SAFER (see Section 17.20 [SET], page 266) setting is
active.
Chapter 17: Utilities 264
17.15 INCLUDE
INCLUDE [FILE=]’file name’ [ENCODING=’encoding’].
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 stops and no more commands are processed. Include files
may be nested to any depth, up to the limit of available memory.
The INSERT command (see Section 17.16 [INSERT], page 264) is a more flexible alternative
to INCLUDE. An INCLUDE command acts the same as INSERT with ERROR=STOP CD=NO
SYNTAX=BATCH specified.
The optional ENCODING subcommand has the same meaning as with INSERT.
17.16 INSERT
INSERT [FILE=]’file name’
[CD={NO,YES}]
[ERROR={CONTINUE,STOP}]
[SYNTAX={BATCH,INTERACTIVE}]
[ENCODING={LOCALE, ’charset name’}].
INSERT is similar to INCLUDE (see Section 17.15 [INCLUDE], page 264) 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 becomes the
directory of the included file. The default setting is ‘CD=NO’. Note that this directory
remains current until it is changed explicitly (with the CD command, or a subsequent INSERT
command with the ‘CD=YES’ option). It does 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 causes processing to
immediately cease. Otherwise processing continues 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 Section 6.3 [Syntax Variants], page 27. The
default setting is SYNTAX=BATCH.
ENCODING optionally specifies the character set used by the included file. Its argument,
which is not case-sensitive, must be in one of the following forms:
LOCALE The encoding used by the system locale, or as overridden by the SET command
(see Section 17.20 [SET], page 266). On GNU/Linux and other Unix-like systems,
environment variables, e.g. LANG or LC_ALL, determine the system locale.
charset name
One of the character set names listed by IANA at http://www.iana.org/
assignments/character-sets. Some examples are ASCII (United States),
ISO-8859-1 (western Europe), EUC-JP (Japan), and windows-1252 (Windows).
Not all systems support all character sets.
Chapter 17: Utilities 265
Auto,encoding
Automatically detects whether a syntax file is encoded in an Unicode encoding
such as UTF-8, UTF-16, or UTF-32. If it is not, then pspp generally assumes
that the file is encoded in encoding (an IANA character set name). However, if
encoding is UTF-8, and the syntax file is not valid UTF-8, pspp instead assumes
that the file is encoded in windows-1252.
For best results, encoding should be an ASCII-compatible encoding (the most
common locale encodings are all ASCII-compatible), because encodings that are
not ASCII compatible cannot be automatically distinguished from UTF-8.
Auto
Auto,Locale
Automatic detection, as above, with the default encoding taken from the system
locale or the setting on SET LOCALE.
When ENCODING is not specified, the default is taken from the --syntax-encoding
command option, if it was specified, and otherwise it is Auto.
17.17 OUTPUT
OUTPUT MODIFY
/SELECT TABLES
/TABLECELLS SELECT = [ class... ]
FORMAT = fmt spec.
Please note: In the above synopsis the characters ‘[’ and ‘]’ are literals. They
must appear in the syntax to be interpreted.
OUTPUT changes the appearance of the tables in which results are printed. In particular,
it can be used to set the format and precision to which results are displayed.
After running this command, the default table appearance parameters will have been
modified and each new output table generated uses the new parameters.
Following /TABLECELLS SELECT = a list of cell classes must appear, enclosed in square
brackets. This list determines the classes of values should be selected for modification. Each
class can be:
RESIDUAL
Residual values. Default: F40.2.
CORRELATION
Correlations. Default: F40.3.
PERCENT
Percentages. Default: PCT40.1.
SIGNIFICANCE
Significance of tests (p-values). Default: F40.3.
COUNT Counts or sums of weights. For a weighted data set, the default is the weight
variable’s print format. For an unweighted data set, the default is F40.0.
Chapter 17: Utilities 266
For most other numeric values that appear in tables, SET FORMAT may be used to specify
the format (see [SET FORMAT], page 268).
The value of fmt spec must be a valid output format (see Section 6.7.4 [Input and Output
Formats], page 32). Note that not all possible formats are meaningful for all classes.
17.18 PERMISSIONS
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 becomes writeable by
you; the permissions afforded to others are unchanged. This command cannot be used if the
SAFER (see Section 17.20 [SET], page 266) setting is active.
17.20 SET
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}
(interaction)
/MXERRS=max errs
/MXWARNS=max warnings
/WORKSPACE=workspace size
(syntax execution)
/LOCALE=’locale’
/MXLOOPS=max loops
/SEED={RANDOM,seed value}
Chapter 17: Utilities 267
/UNDEFINED={WARN,NOWARN}
/FUZZBITS=fuzzbits
/SCALEMIN=count
(data output)
/CC{A,B,C,D,E}={’npre,pre,suf,nsuf ’,’npre.pre.suf.nsuf ’}
/DECIMAL={DOT,COMMA}
/FORMAT=fmt spec
/LEADZERO={ON,OFF}
/MDISPLAY={TEXT,TABLES}
/SMALL=number
/WIB={NATIVE,MSBFIRST,LSBFIRST,VAX}
/WRB={NATIVE,ISL,ISB,IDL,IDB,VF,VD,VG,ZS,ZL}
(output routing)
/ERRORS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
/MESSAGES={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
/PRINTBACK={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
/RESULTS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
(logging)
/JOURNAL={ON,OFF} [’file name’]
(system files)
/SCOMPRESSION={ON,OFF}
(miscellaneous)
/SAFER=ON
/LOCALE=’string’
(macros)
/MEXPAND={ON,OFF}
/MPRINT={ON,OFF}
/MITERATE=number
/MNEST=number
/BOX={’xxx’,’xxxxxxxxxxx’}
/CACHE={ON,OFF}
/CELLSBREAK=number
/COMPRESSION={ON,OFF}
/CMPTRANS={ON,OFF}
/HEADER={NO,YES,BLANK}
SET allows the user to adjust several parameters relating to pspp’s execution. Since there
are many subcommands to this command, its subcommands are examined in groups.
For subcommands that take boolean values, ON and YES are synonymous, 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
BLANKS This is the value assigned to an item data item that is empty or contains only
white space. An argument of SYSMIS or ’.’ causes the system-missing value to
be assigned to null items. This is the default. Any real value may be assigned.
DECIMAL
This value may be set to DOT or COMMA. Setting it to DOT causes the decimal
point character to be ‘.’ and the grouping character to be ‘,’. Setting it to
COMMA causes the decimal point character to be ‘,’ and the grouping character
to be ‘.’. If the setting is COMMA, then ‘,’ is not treated as a field separator in
the DATA LIST command (see Section 8.5 [DATA LIST], page 64). The default
value is determined from the system locale.
FORMAT Allows the default numeric input/output format to be specified. The default is
F8.2. See Section 6.7.4 [Input and Output Formats], page 32.
EPOCH Specifies the range of years used when a 2-digit year is read from a data file or
used in a date construction expression (see Section 7.7.8.4 [Date Construction],
page 52). If a 4-digit year is specified for the epoch, then 2-digit years are
interpreted starting from that year, known as the epoch. If AUTOMATIC (the
default) is specified, then the epoch begins 69 years before the current date.
RIB
pspp extension to set the byte ordering (endianness) used for reading data in IB
or PIB format (see Section 6.7.4.4 [Binary and Hexadecimal Numeric Formats],
page 37). In MSBFIRST ordering, the most-significant byte appears at the left
end of a IB or PIB field. In LSBFIRST ordering, the least-significant byte appears
at the left end. VAX ordering is like MSBFIRST, except that each pair of bytes is
in reverse order. NATIVE, the default, is equivalent to MSBFIRST or LSBFIRST
depending on the native format of the machine running pspp.
RRB
pspp extension to set the floating-point format used for reading data in RB
format (see Section 6.7.4.4 [Binary and Hexadecimal Numeric Formats], page 37).
The possibilities are:
NATIVE The native format of the machine running pspp. Equivalent to
either IDL or IDB.
Chapter 17: Utilities 269
SEED The initial pseudo-random number seed. Set it to a real number or to RANDOM,
to obtain an initial seed from the current time of day.
UNDEFINED
Currently not used.
FUZZBITS
The maximum number of bits of errors in the least-significant places to accept
for rounding up a value that is almost halfway between two possibilities for
rounding with the RND operator (see Section 7.7.2 [Miscellaneous Mathematics],
page 46). The default fuzzbits is 6.
SCALEMIN
The minimum number of distinct valid values for pspp to assume that a variable
has a scale measurement level. See [Measurement Level], page 30.
WORKSPACE
The maximum amount of memory (in kilobytes) that pspp uses to store data
being processed. If memory in excess of the workspace size is required, then
pspp starts to use temporary files to store the data. Setting a higher value
means that procedures run faster, but may cause other applications to run
slower. On platforms without virtual memory management, setting a very large
workspace may cause pspp to abort.
Data output subcommands affect the format of output data. These subcommands are
CCA
CCB
CCC
CCD
CCE
Set up custom currency formats. See Section 6.7.4.2 [Custom Currency Formats],
page 35, for details.
DECIMAL
The default DOT setting causes the decimal point character to be ‘.’. A setting
of COMMA causes the decimal point character to be ‘,’.
FORMAT Allows the default numeric input/output format to be specified. The default is
F8.2. See Section 6.7.4 [Input and Output Formats], page 32.
LEADZERO
Controls whether numbers with magnitude less than one are displayed with a
zero before the decimal point. For example, with SET LEADZERO=OFF, which is
the default, one-half is shown as 0.5, and with SET LEADZERO=ON, it is shown as
.5. This setting affects only the F, COMMA, and DOT formats.
MDISPLAY
Controls how the PRINT command within MATRIX. . . END MATRIX outputs ma-
trices. With the default TEXT, PRINT outputs matrices as text. Change this
setting to TABLES to instead output matrices as pivot tables. See Section 16.4.5
[Matrix PRINT Command], page 249, for more information.
Chapter 17: Utilities 271
SMALL This controls how pspp formats small numbers in pivot tables, in cases where
pspp does not otherwise have a well-defined format for the numbers. When
such a number has a magnitude less than the value set here, pspp formats the
number in scientific notation; otherwise, it formats it in standard notation. The
default is 0.0001. Set a value of 0 to disable scientific notation.
WIB
pspp extension to set the byte ordering (endianness) used for writing data in IB
or PIB format (see Section 6.7.4.4 [Binary and Hexadecimal Numeric Formats],
page 37). In MSBFIRST ordering, the most-significant byte appears at the left
end of a IB or PIB field. In LSBFIRST ordering, the least-significant byte appears
at the left end. VAX ordering is like MSBFIRST, except that each pair of bytes is
in reverse order. NATIVE, the default, is equivalent to MSBFIRST or LSBFIRST
depending on the native format of the machine running pspp.
WRB
pspp extension to set the floating-point format used for writing data in RB
format (see Section 6.7.4.4 [Binary and Hexadecimal Numeric Formats], page 37).
The choices are the same as SET RIB. The default is NATIVE.
In the pspp text-based interface, the output routing subcommands affect where output
is sent. The following values are allowed for each of these subcommands:
OFF
NONE Discard this kind of output.
TERMINAL
Write this output to the terminal, but not to listing files and other output
devices.
LISTING Write this output to listing files and other output devices, but not to the
terminal.
ON
BOTH Write this type of output to all output devices.
These output routing subcommands are:
ERRORS Applies to error and warning messages. The default is BOTH.
MESSAGES
Applies to notes. The default is BOTH.
PRINTBACK
Determines whether the syntax used for input is printed back as part of the
output. The default is NONE.
RESULTS Applies to everything not in one of the above categories, such as the results of
statistical procedures. The default is BOTH.
These subcommands have no effect on output in the pspp GUI environment.
Chapter 17: Utilities 272
Output driver option subcommands affect output drivers’ settings. These subcommands
are
HEADERS
LENGTH
WIDTH
TNUMBERS
The TNUMBERS option sets the way in which values are displayed in output tables.
The valid settings are VALUES, LABELS and BOTH. If TNUMBERS is set to VALUES,
then all values are displayed with their literal value (which for a numeric value
is a number and for a string value an alphanumeric string). If TNUMBERS is set
to LABELS, then values are displayed using their assigned labels if any. (See
Section 11.11 [VALUE LABELS], page 102.) If the value has no label, then
the literal value is used for display. If TNUMBERS is set to BOTH, then values are
displayed with both their label (if any) and their literal value in parentheses.
TVARS The TVARS option sets the way in which variables are displayed in output tables.
The valid settings are NAMES, LABELS and BOTH. If TVARS is set to NAMES, then
all variables are displayed using their names. If TVARS is set to LABELS, then
variables are displayed using their label if one has been set. If no label has been
set, then the name is used. (See Section 11.7 [VARIABLE LABELS], page 101.)
If TVARS is set to BOTH, then variables are displayed with both their label (if
any) and their name in parentheses.
TLOOK The TLOOK option sets the style used for subsequent table output. Specifying
NONE makes pspp use the default built-in style. Otherwise, specifying file makes
pspp search for an .stt or .tlo file in the same way as specifying --table-
look=file the pspp command line (see Section 3.1 [Main Options], page 3).
Logging subcommands affect logging of commands executed to external files. These
subcommands are
JOURNAL
LOG These subcommands, which are synonyms, control the journal. The default is
ON, which causes commands entered interactively to be written to the journal
file. Commands included from syntax files that are included interactively and
error messages printed by pspp are also written to the journal file, prefixed by
‘>’. OFF disables use of the journal.
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
SCOMPRESSION
Whether system files created by SAVE or XSAVE are compressed by default. The
default is ON.
Security subcommands affect the operations that commands are allowed to perform. The
security subcommands are
SAFER Setting this option disables the following operations:
• The ERASE command.
Chapter 17: Utilities 273
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.
LOCALE This item is used to set the default character encoding. The encoding may
be specified either as an encoding name or alias (see http://www.iana.org/
assignments/character-sets), or as a locale name. If given as a locale name,
only the character encoding of the locale is relevant.
System files written by pspp use this encoding. System files read by pspp, for
which the encoding is unknown, are interpreted using this encoding.
The full list of valid encodings and locale names/alias are operating system
dependent. The following are all examples of acceptable syntax on common
GNU/Linux systems.
SET LOCALE=’iso-8859-1’.
SET LOCALE=’ru_RU.cp1251’.
SET LOCALE=’japanese’.
Contrary to intuition, this command does not affect any aspect of the system’s
locale.
MEXPAND
Controls whether macros are expanded. The default is ON.
MPRINT Controls whether the expansion of macros is included in output. This is separate
from whether command syntax in general is included in output. The default is
OFF.
MITERATE
Limits the number of iterations executed in !DO loops within macros. This does
not affect other language constructs such as LOOP. This must be set to a positive
integer. The default is 1000.
MNEST Limits the number of levels of nested macro expansions. This must be set to a
positive integer. The default is 50.
The following subcommands are not yet implemented, but PSPP accepts them and
ignores the settings.
Chapter 17: Utilities 274
BASETEXTDIRECTION
BLOCK
BOX
CACHE
CELLSBREAK
COMPRESSION
CMPTRANS
HEADER
17.21 SHOW
SHOW
[ALL]
[BLANKS]
[CC]
[CCA]
[CCB]
[CCC]
[CCD]
[CCE]
[COPYING]
[DECIMAL]
[DIRECTORY]
[ENVIRONMENT]
[FORMAT]
[FUZZBITS]
[LENGTH]
[MEXPAND]
[MPRINT]
[MITERATE]
[MNEST]
[MXERRS]
[MXLOOPS]
[MXWARNS]
[N]
[SCOMPRESSION]
[SYSTEM]
[TEMPDIR]
[UNDEFINED]
[VERSION]
[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 Section 17.20 [SET], page 266), can be examined using
SHOW using the subcommand with the same name. SHOW supports the following additional
subcommands:
Chapter 17: Utilities 275
17.22 SUBTITLE
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.
17.23 TITLE
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.
276
18 Invoking pspp-convert
pspp-convert is a command-line utility accompanying pspp. It reads an SPSS or SPSS/PC+
system file or SPSS portable file or encrypted SPSS syntax file input and writes a copy of it
to another output in a different format. Synopsis:
pspp-convert [options] input output
pspp-convert --help
pspp-convert --version
The format of input is automatically detected, when possible. The character encoding of
old SPSS system files cannot always be guessed correctly, and SPSS/PC+ system files do
not include any indication of their encoding. Use -e encoding to specify the encoding in
this case.
By default, the intended format for output is inferred based on its extension:
csv
txt Comma-separated value. Each value is formatted according to its variable’s
print format. The first line in the file contains variable names.
sav
sys SPSS system file.
por SPSS portable file.
sps SPSS syntax file. (Only encrypted syntax files may be converted to this format.)
pspp-convert can convert most input formats to most output formats. Encrypted SPSS
file formats are exceptions: if the input file is in an encrypted format, then the output file
will be the same format (decrypted). To decrypt such a file, specify the encrypted file as
input. The output will be the equivalent plaintext file. Options for the output format are
ignored in this case.
The password for encrypted files can be specified a few different ways. If the password
is known, use the -p option (documented below) or allow pspp-convert to prompt for it.
If the password is unknown, use the -a and -l options to specify how to search for it, or
--password-list to specify a file of passwords to try.
Use -O format to override the inferred format or to specify the format for unrecognized
extensions.
pspp-convert accepts the following general options:
-O format
--output-format=format
Sets the output format, where format is one of the extensions listed above, e.g.:
-O csv. Use --help to list the supported output formats.
-c maxcases
--cases=maxcases
By default, all cases are copied from input to output. Specifying this option to
limit the number of cases written to output to maxcases.
Chapter 18: Invoking pspp-convert 277
-e charset
--encoding=charset
Overrides the encoding in which character strings in input are interpreted. This
option is necessary because old SPSS system files, and SPSS/PC+ system files,
do not self-identify their encoding.
-k variable...
--keep=variable...
By default, pspp-convert includes all the variables from the input file. Use
this option to list specific variables to include; any variables not listed will be
dropped. The variables in the output file will also be reordered into the given
order. The variable list may use TO in the same way as in PSPP syntax, e.g. if
the dictionary contains consecutive variables a, b, c, and d, then --keep=’a to
d’ will include all of them (and no others).
-d variable...
--drop=variable...
Drops the specified variables from the output.
When --keep and --drop are used together, --keep is processed first.
-h
--help Prints a usage message on stdout and exits.
-v
--version
Prints version information on stdout and exits.
The following options affect CSV output:
--recode By default, pspp-convert writes user-missing values to CSV output files as their
regular values. With this option, pspp-convert recodes them to system-missing
values (which are written as a single space).
--no-var-names
By default, pspp-convert writes the variable names as the first line of output.
With this option, pspp-convert omits this line.
--labels By default, pspp-convert writes variables’ values to CSV output files. With
this option, pspp-convert writes value labels.
--print-formats
By default, pspp-convert writes numeric variables as plain numbers. This
option makes pspp-convert honor variables’ print formats.
--decimal=decimal
This option sets the character used as a decimal point in output. The default is
‘.’.
--delimiter=delimiter
This option sets the character used to separate fields in output. The default is
‘,’, unless the decimal point is ‘,’, in which case ‘;’ is used.
--qualifier=qualifier
The option sets the character used to quote fields that contain the delimiter.
The default is ‘"’.
Chapter 18: Invoking pspp-convert 278
The following options specify how to obtain the password for encrypted files:
-p password
--password=password
Specifies the password to use to decrypt an encrypted SPSS system file or syntax
file. If this option is not specified, pspp-convert will prompt interactively for
the password as necessary.
Be aware that command-line options, including passwords, may be visible to
other users on multiuser systems.
When used with -a (or --password-alphabet) and -l (or --password-length),
this option specifies the starting point for the search. This can be used to restart
a search that was interrupted.
-a alphabet
--password-alphabet=alphabet
Specifies the alphabet of symbols over which to search for an encrypted file’s
password. alphabet may include individual characters and ranges delimited by
‘-’. For example, -a a-z searches lowercase letters, -a A-Z0-9 searches uppercase
letters and digits, and -a ’ -~’ searches all printable ASCII characters.
-l max-length
--password-length=max-length
Specifies the maximum length of the passwords to try.
--password-list=file
Specifies a file to read containing a list of passwords to try, one per line. If file
is -, reads from stdin.
279
19 Invoking pspp-output
pspp-output is a command-line utility accompanying pspp. It supports multiple operations
on SPSS viewer or .spv files, here called SPV files. SPSS 16 and later writes SPV files to
represent the contents of its output editor.
SPSS 15 and earlier versions instead use .spo files. pspp-output does not support this
format.
pspp-options may be invoked in the following ways:
pspp-output detect file
pspp-output --help
pspp-output --version
Each of these forms is documented separately below. pspp-output also has several
undocumented command forms that developers may find useful for debugging.
By default, the intended format for destination is inferred based on its extension, in the
same way that the pspp program does for its output files. See Chapter 3 [Invoking PSPP],
page 3, for details.
See Section 19.6 [Input Selection Options], page 281, for information on the options
available to select a subset of objects to include in the output. The following additional
options are accepted:
-O format=format
Overrides the format inferred from the output file’s extension. Use --help to
list the available formats. See Chapter 3 [Invoking PSPP], page 3, for details of
the available output formats.
-O option=value
Sets an option for the output file format. See Chapter 3 [Invoking PSPP], page 3,
for details of the available output options.
-F
--force By default, if the source is corrupt or otherwise cannot be processed, the
destination is not written. With -F or --force, the destination is written as
best it can, even with errors.
--table-look=file
Reads a table style from file and applies it to all of the output tables. The file
should be a TableLook .stt or .tlo file.
--use-page-setup
By default, the convert command uses the default page setup (for example,
page size and margins) for destination, or the one specified with -O options, if
any. Specify this option to ignore these sources of page setup in favor of the one
embedded in the SPV, if any.
--select=[^]class...
Include only objects of the given class; with leading ‘^’, include only objects not
in the class. Use commas to separate multiple classes. The supported classes
are:
charts headings logs models tables texts trees warnings
outlineheaders pagetitle notes unknown other
Use --select=help to print this list of classes.
--commands=[^]command...
--subtypes=[^]subtype...
--labels=[^]label...
Include only objects with the specified command, subtype, or label. With a
leading ‘^’, include only the objects that do not match. Multiple values may
be specified separated by commas. An asterisk at the end of a value acts as a
wildcard.
The --command option matches command identifiers, case insensitively. All of
the objects produced by a single command use the same, unique command
identifier. Command identifiers are always in English regardless of the language
used for output. They often differ from the command name in PSPP syntax.
Use the pspp-output program’s dir command to print command identifiers in
particular output.
The --subtypes option matches particular tables within a command, case
insensitively. Subtypes are not necessarily unique: two commands that produce
similar output tables may use the same subtype. Subtypes are always in English
and dir will print them.
The --labels option matches the labels in table output (that is, the table
titles). Labels are affected by the output language, variable names and labels,
split file settings, and other factors.
--nth-commands=n...
Include only objects from the nth command that matches --command (or the
nth command overall if --command is not specified), where n is 1 for the first
command, 2 for the second, and so on.
--instances=instance...
Include the specified instance of an object that matches the other criteria within
a single command. The instance may be a number (1 for the first instance, 2
for the second, and so on) or last for the last instance.
--show-hidden
Include hidden output objects in the output. By default, they are excluded.
Chapter 19: Invoking pspp-output 282
--or Separates two sets of selection options. Objects selected by either set of options
are included in the output.
The following additional input selection options are intended mainly for use by PSPP
developers:
--errors Include only objects that cause an error when read. With the convert command,
this is most useful in conjunction with the --force option.
--members=member...
Include only the objects that include a listed Zip file member. More than one
name may be included, comma-separated. The members in an SPV file may be
listed with the dir command by adding the --show-members option or with the
zipinfo program included with many operating systems. Error messages that
pspp-output prints when it reads SPV files also often include member names.
--member-names
Displays the name of the Zip member or members associated with each object
just above the object itself.
283
20 Invoking pspp-dump-sav
pspp-dump-sav is a command-line utility accompanying pspp. It is not installed by default,
so it may be missing from your PSPP installation. It reads one or more SPSS system files
and prints their contents. The output format is useful for debugging system file readers
and writers and for discovering how to interpret unknown or poorly understood records.
End users may find the output useful for providing the PSPP developers information about
system files that PSPP does not accurately read.
Synopsis:
pspp-dump-sav [-d[maxcases] | --data[=maxcases]] file . . .
pspp-dump-sav --help | -h
pspp-dump-sav --version | -v
The following options are accepted:
-d[maxcases]
--data[=maxcases]
By default, pspp-dump-sav does not print any of the data in a system file, only
the file headers. Specify this option to print the data as well. If maxcases is
specified, then it limits the number of cases printed.
-h
--help Prints a usage message on stdout and exits.
-v
--version
Prints version information on stdout and exits.
Some errors that prevent files from being interpreted successfully cause pspp-dump-sav
to exit without reading any additional files given on the command line.
284
21 Not Implemented
This chapter lists parts of the pspp language that are not yet implemented.
2SLS Two stage least squares regression
ACF Autocorrelation function
ALSCAL Multidimensional scaling
ANACOR Correspondence analysis
ANOVA Factorial analysis of variance
CASEPLOT Plot time series
CASESTOVARS
Restructure complex data
CATPCA Categorical principle components analysis
CATREG Categorical regression
CCF Time series cross correlation
CLEAR TRANSFORMATIONS
Clears transformations from active dataset
CLUSTER Hierarchical clustering
CONJOINT Analyse full concept data
CORRESPONDENCE
Show correspondence
COXREG Cox proportional hazards regression
CREATE Create time series data
CSDESCRIPTIVES
Complex samples descriptives
CSGLM Complex samples GLM
CSLOGISTIC
Complex samples logistic regression
CSPLAN Complex samples design
CSSELECT Select complex samples
CSTABULATE
Tabulate complex samples
CURVEFIT Fit curve to line plot
DATE Create time series data
DETECTANOMALY
Find unusual cases
Chapter 21: Not Implemented 285
DISCRIMINANT
Linear discriminant analysis
EDIT obsolete
END FILE TYPE
Ends complex data input
FILE TYPE Complex data input
FIT Goodness of Fit
GENLOG Categorical model fitting
GET TRANSLATE
Read other file formats
GGRAPH Custom defined graphs
HILOGLINEAR
Hierarchical loglinear models
HOMALS Homogeneity analysis
IGRAPH Interactive graphs
INFO Local Documentation
KEYED DATA LIST
Read nonsequential data
KM Kaplan-Meier
LOGLINEAR
General model fitting
MANOVA Multivariate analysis of variance
MAPS Geographical display
MIXED Mixed linear models
MODEL CLOSE
Close server connection
MODEL HANDLE
Define server connection
MODEL LIST
Show existing models
MODEL NAME
Specify model label
MULTIPLE CORRESPONDENCE
Multiple correspondence analysis
MULT RESPONSE
Multiple response analysis
Chapter 21: Not Implemented 286
RECORD TYPE
Defines a type of record within FILE TYPE
REFORMAT Read obsolete files
REPEATING DATA
Specify multiple cases per input record
REPORT Pretty print working file
RMV Replace missing values
SCRIPT Run script file
SEASON Estimate seasonal factors
SELECTPRED
Select predictor variables
SPCHART Plot control charts
SPECTRA Plot spectral density
STEMLEAF Plot stem-and-leaf display
SUMMARIZE
Univariate statistics
SURVIVAL Survival analysis
TDISPLAY Display active models
TREE Create classification tree
TSAPPLY Apply time series model
TSET Set time sequence variables
TSHOW Show time sequence variables
TSMODEL Estimate time series model
TSPLOT Plot time sequence variables
TWOSTEP CLUSTER
Cluster observations
UNIANOVA Univariate analysis
UNNUMBERED
obsolete
VALIDATEDATA
Identify suspicious cases
VARCOMP Estimate variance
VARSTOCASES
Restructure complex data
VERIFY Report time series
WLS Weighted least squares regression
XGRAPH High resolution charts
288
22 Bugs
Here is one example of a bug report that includes all of the elements above:
Chapter 22: Bugs 289
I’m running PSPP on a system where SHOW SYSTEM. outputs the
following:
System Information
+----------------+----------------------------------+
|Version |GNU pspp 2.0.0-pre1 |
|Host System |x86_64-pc-linux-gnu |
|Build System |x86_64-pc-linux-gnu |
|Locale Directory|//share/locale |
|Compiler Version|13.1.1 20230426 (Red Hat 13.1.1-1)|
+----------------+----------------------------------+
results in:
4
5
6
1
2
3
The following bug report, on the other hand, does not provide enough information for
PSPP developers to understand the problem. This means that the developers cannot identify
or fix the problem without additional rounds of questions, which is more work for both the
reporter and the developer:
I downloaded the latest version of PSPP and entered a sequence of numbers,
but when I analyse them it gives the wrong output.
pspp developers value all users’ feedback, but cannot promise an immediate response.
The bug reporting is not a consultancy or support service, although you can make private
Chapter 22: Bugs 290
arrangements for such services. Since pspp is free software, consultants have access to the
information they need to provide such support.
For general enquiries or help, please use the pspp-users mailing list (http://lists.gnu.
org/mailman/listinfo/pspp-users) instead of the bug mailing list or bug tracker.
The PSPP bug tracker and bug reporting mailing list are public. To privately report
a security vulnerability in GNU PSPP, please send your report to the closed mailing list
[email protected]. The PSPP developers will help you assess your report and fix
problems prior to public disclosure.
291
23 Function Index
! CDF.RAYLEIGH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!BLANKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 CDF.T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!CONCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 CDF.T1G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!EVAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 CDF.T2G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!HEAD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 CDF.UNIFORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CDF.WEIBULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
!LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CDFNORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
!NULL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CFVAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
!QUOTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CHOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
!SUBSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 CMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
!TAIL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 CMIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
!UNQUOTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CONCAT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
!UPCASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47, 239
CSSQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
CSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
( CTIME.DAYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
(variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 CTIME.HOURS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
CTIME.MINUTES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
CTIME.SECONDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 239
ACOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
ALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 D
ANY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48, 240 DATE.DMY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ARCOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 DATE.MDY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ARSIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47, 239 DATE.MOYR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ARTAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47, 239 DATE.QYR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 DATE.WKYR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 DATE.YRDAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
DATEDIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
B DATESUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
DESIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
BLOCK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
DET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
DIAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
C
CDF.BERNOULLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
CDF.BETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 E
CDF.BINOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
EOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
CDF.BVNOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
CDF.CAUCHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 EVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
CDF.CHISQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 239
CDF.EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
CDF.F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
CDF.GAMMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
CDF.GEOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
G
CDF.HYPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 GINV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
CDF.LAPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 GRADE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
CDF.LNORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 GSCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
CDF.LOGISTIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
CDF.NEGBIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
CDF.NORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
CDF.PARETO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
CDF.POISSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Chapter 23: Function Index 292
I N
IDENT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 NCDF.BETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
IDF.BETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 NCDF.CHISQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
IDF.CAUCHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 NCOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
IDF.CHISQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 NMISS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
IDF.EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 NORMAL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
IDF.F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 NPDF.BETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
IDF.GAMMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 NROW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
IDF.LAPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 NUMBER. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
IDF.LNORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 NVALID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
IDF.LOGISTIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
IDF.NORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
IDF.PARETO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
P
IDF.RAYLEIGH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.BERNOULLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
IDF.T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.BETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
IDF.T1G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.BINOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
IDF.T2G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.BVNOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
IDF.UNIFORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.CAUCHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
IDF.WEIBULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 PDF.EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 PDF.F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
INV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 PDF.GAMMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
PDF.GEOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
PDF.HYPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
PDF.LANDAU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
K PDF.LAPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
KRONEKER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 PDF.LNORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
PDF.LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
PDF.LOGISTIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
L PDF.NEGBIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
PDF.NORMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
LAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
PDF.NTAIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
LENGTH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
PDF.PARETO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
LG10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 239
PDF.POISSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 239 PDF.RAYLEIGH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
LNGAMMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 PDF.RTAIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 PDF.T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
LPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 PDF.T1G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 PDF.T2G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
PDF.UNIFORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
PDF.WEIBULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
M PDF.XPOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
MAGIC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 PROBIT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
MAKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
MDIAG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
R
MEAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 RANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
MEDIAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 RANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 REPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
MISSING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 RESHAPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
MMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 RINDEX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
MMIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 RMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 240 RMIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
MOD10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 RND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 240
MSSQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 RNKORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
MSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 RPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
RSSQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
RSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Chapter 23: Function Index 293
24 Command Index
L S
LEAVE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 SAMPLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13, 74 SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15, 87
LOGISTIC REGRESSION . . . . . . . . . . . . . . . . . . . . . . . . . 198 SAVE DATA COLLECTION . . . . . . . . . . . . . . . . . . . . . . . . . 89
LOOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 SAVE TRANSLATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
SELECT IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
M SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
M-W . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 SHOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
MANN-WHITNEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
MATCH FILES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 SORT CASES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Matrix file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 SORT VARIABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
MATRIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 SPLIT FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
MATRIX DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
MCNEMAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 SUBTITLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
MCONVERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 SYSFILE INFO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
MEANS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
MEDIAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
MISSING VALUES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
MRSETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 T
T-TEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 208
N TEMPORARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
N OF CASES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 TITLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
NEW FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
NPAR TESTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
NUMERIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
U
O UPDATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
ONEWAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
V
P VALUE LABELS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
PERMISSIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 VARIABLE ALIGNMENT . . . . . . . . . . . . . . . . . . . . . . . . . . 104
PRESERVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 VARIABLE ATTRIBUTE . . . . . . . . . . . . . . . . . . . . . . . . . . 103
PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 VARIABLE LABELS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
PRINT EJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 VARIABLE LEVEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
PRINT FORMATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
VARIABLE ROLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
PRINT SPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
VARIABLE WIDTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
VECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Q
QUICK CLUSTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
W
R WEIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
RANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 WILCOXON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
RECODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 WRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
REGRESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23, 218 WRITE FORMATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
RELIABILITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
RENAME VARIABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
REPEATING DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
REREAD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 X
RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
ROC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 XEXPORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
RUNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 XSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
296
25 Concept Index
" /
‘"’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘/’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
$ <
$CASENUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 < . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
$DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 <= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
$DATE11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 <> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
$JDATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
$LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
$SYSMIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 =
$TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 ‘=’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
$WIDTH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
>
& ‘>’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
‘&’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 >= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
’
‘’’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘_’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
( ‘
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 “is defined as” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
‘( )’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
|
) ‘|’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
~
* ‘~’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
‘*’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 ~= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
‘**’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
A
+ absolute value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
‘+’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
analysis of variance . . . . . . . . . . . . . . . . . . . . . . 198, 215
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
, ANOVA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198, 215
pspp, command structure . . . . . . . . . . . . . . . . . . . . . . 26 arccosine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
pspp, invoking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 arcsine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
pspp, language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 arctangent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Area under curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
arguments, invalid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
– arguments, minimum valid . . . . . . . . . . . . . . . . . . . . . 48
‘-’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 45 arguments, of date construction functions . . . . . . 52
arguments, of date extraction functions . . . . . . . . . 53
arithmetic mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
. arithmetic operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
‘.’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29, 43 attributes of variables . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 25: Concept Index 297
B D
Backus-Naur Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
bar chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155, 159, 163 data file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Batch syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 data files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
binary formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 data reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
binomial test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Data, embedding in syntax files . . . . . . . . . . . . . . . . 62
bivariate logistic regression . . . . . . . . . . . . . . . . . . . . 198 data, embedding in syntax files . . . . . . . . . . . . . . . . . 64
BNF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 data, fixed-format, reading . . . . . . . . . . . . . . . . . . . . . 64
Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 45 data, reading from a file . . . . . . . . . . . . . . . . . . . . . . . . 64
boxplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15, 82
bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
date examination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
date formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
date, Julian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
C dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
case conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 dates, concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
case-sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 dates, constructing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 dates, day of the month . . . . . . . . . . . . . . . . . . . . . . . . 53
changing directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 dates, day of the week . . . . . . . . . . . . . . . . . . . . . . . . . 54
changing file permissions . . . . . . . . . . . . . . . . . . . . . . 266 dates, day of the year . . . . . . . . . . . . . . . . . . . . . . . . . . 53
chi-square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 dates, day-month-year . . . . . . . . . . . . . . . . . . . . . . . . . 52
chi-square test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 dates, in days . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
chi-square test of independence . . . . . . . . . . . . . . . 164 dates, in hours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 dates, in minutes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Cochran Q test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 dates, in months . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
coefficient of concordance . . . . . . . . . . . . . . . . . . . . . 206 dates, in quarters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
coefficient of variation . . . . . . . . . . . . . . . . . . . . . . . . . . 48 dates, in seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
comma separated values. . . . . . . . . . . . . . . . . . . . . . . . 15 dates, in weekdays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
command file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 dates, in weeks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
command syntax, description of . . . . . . . . . . . . . . . . 43 dates, in years . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
commands, ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 dates, mathematical properties of . . . . . . . . . . . . . . 54
commands, structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 dates, month-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
commands, unimplemented . . . . . . . . . . . . . . . . . . . 284 dates, quarter-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 dates, time of day . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
conditionals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 dates, valid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 dates, week-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
constructing dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 dates, year-day. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
constructing times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 day of the month . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
control flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 day of the week . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
convention, TO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 day of the year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 day-month-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 days . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51, 53
cosine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 decimal places . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
covariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 description of command syntax . . . . . . . . . . . . . . . . . 43
Cronbach’s Alpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 deviation, standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
cross-case function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
currency formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
custom attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
custom tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 DocBook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 25: Concept Index 298
E H
embedding data in syntax files . . . . . . . . . . . . . . . . . 64 harmonic mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Embedding data in syntax files . . . . . . . . . . . . . . . . . 62 headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
embedding fixed-format data . . . . . . . . . . . . . . . . . . . 64 hexadecimal formats . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
encoding, characters . . . . . . . . . . . . . . . . . . . . . . . . . . 273 histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . 154, 157, 159
equality, testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
hours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51, 53
EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
hours-minutes-seconds . . . . . . . . . . . . . . . . . . . . . . . . . 51
erroneous data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 9
errors, in data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
examination, of times . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Hypothesis testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Exploratory data analysis . . . . . . . . . . . . . . . . 156, 159
exponentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
expressions, mathematical . . . . . . . . . . . . . . . . . . . . . . 44 I
extraction, of dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
extraction, of time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
identifiers, reserved . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
inequality, testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
F input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
input program commands . . . . . . . . . . . . . . . . . . . . . . 27
factor analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
factorial anova . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
false . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Interactive syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
file definition commands . . . . . . . . . . . . . . . . . . . . . . . 27
intersection, logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
file handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
file mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
file, command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 inverse cosine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
file, data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 inverse sine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
file, output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 inverse tangent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
file, portable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 inversion, logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
file, syntax file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Inverting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
file, system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
fixed effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . 276, 279, 283
fixed-format data, reading . . . . . . . . . . . . . . . . . . . . . . 64
flow of control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Friedman test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
function, cross-case . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
J
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Julian date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
functions, miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . 55
functions, missing-value . . . . . . . . . . . . . . . . . . . . . . . . 47
functions, statistical. . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
functions, string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
functions, time & date . . . . . . . . . . . . . . . . . . . . . . . . . 51
K
K-means clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Kendall’s W test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
G keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
geometric mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Kolmogorov-Smirnov test . . . . . . . . . . . . . . . . . . . . . 206
GE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Kruskal-Wallis test. . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Gnumeric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Graphic user interface . . . . . . . . . . . . . . . . . . . . . . . . . . 11
greater than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
greater than or equal to . . . . . . . . . . . . . . . . . . . . . . . . 45
grouping operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
GT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Chapter 25: Concept Index 299
L N
labels, value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 names, of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
labels, variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
pspp language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 NE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
language, pspp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 25 nonparametric tests . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
language, command structure . . . . . . . . . . . . . . . . . . 26 nonterminals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
language, lexical analysis . . . . . . . . . . . . . . . . . . . . . . . 25 normality, testing . . . . . . . . . . . . . . . . . . . . . 19, 156, 159
language, tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 npplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
less than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 null hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
less than or equal to . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
lexical analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
LE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 numbers, converting from strings . . . . . . . . . . . . . . . 50
licence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 numbers, converting to strings . . . . . . . . . . . . . . . . . 50
license . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 numeric formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Likert scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
linear regression . . . . . . . . . . . . . . . . . . . . . . . . . . . 23, 218
locale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
O
logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 obligations, your . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
logical intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
logical inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 OpenDocument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
logical operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 operations, order of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
logical union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 operator precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
logistic regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 43, 46
loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 operators, arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
LT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 operators, grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
operators, logical. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
order of commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
M order of operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Mann-Whitney U test. . . . . . . . . . . . . . . . . . . . . . . . . 207 output file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
mathematical expressions . . . . . . . . . . . . . . . . . . . . . . 44
mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
mathematics, advanced . . . . . . . . . . . . . . . . . . . . . . . . 46 P
mathematics, applied to times & dates . . . . . . . . . 54 p-value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
mathematics, miscellaneous . . . . . . . . . . . . . . . . . . . . 46 pager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
maximum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 parentheses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 46
McNemar test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1, 6
mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 percentiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154, 158
means . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 period . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
measurement level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 piechart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
median . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 PNG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Median test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 portable file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
membership, of set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 postgres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
memory, amount used to store cases . . . . . . . . . . . 270 Postscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 PostScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
minimum valid number of arguments . . . . . . . . . . . 48 precedence, operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
minutes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52, 53 precision, of output . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
missing values . . . . . . . . . . . . . . . . . . . . . . . . . . 29, 30, 47 principal axis factoring . . . . . . . . . . . . . . . . . . . . . . . . 195
mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 principal components analysis . . . . . . . . . . . . . . . . . 195
modulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 print format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
modulus, by 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
month-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 productions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
months . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 pspp-convert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 pspp-dump-sav . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
pspp-output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
PSPPIRE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 25: Concept Index 300
U variables, system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
U, Mann-Whitney U . . . . . . . . . . . . . . . . . . . . . . . . . . 207 variables, type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
unimplemented commands . . . . . . . . . . . . . . . . . . . . 284 variables, width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
union, logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
univariate analysis of variance . . . . . . . . . . . . . . . . . 198 variation, coefficient of . . . . . . . . . . . . . . . . . . . . . . . . . 48
utility commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
W
V week . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
value label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 week-year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
value labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 weekday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
values, Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 white space, trimming. . . . . . . . . . . . . . . . . . . . . . . . . . 50
values, missing. . . . . . . . . . . . . . . . . . . . . . . . . . 29, 30, 47 width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
values, system-missing . . . . . . . . . . . . . . . . . . . . . . . . . 45 width of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
var-list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 wilcoxon matched pairs signed ranks test . . . . . . 208
var-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 write format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
variable labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
variable names, ending with period . . . . . . . . . . . . . 29
variable role . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Y
variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 year-day . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 years . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
variables, attributes of . . . . . . . . . . . . . . . . . . . . . . . . . 29 your rights and obligations . . . . . . . . . . . . . . . . . . . . . . 2
302
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.
The “publisher” means any person or entity that distributes copies of the Document to
the public.
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.
2. VERBATIM COPYING
Appendix A: GNU Free Documentation License 304
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.
3. COPYING IN QUANTITY
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.
4. MODIFICATIONS
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:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any,
Appendix A: GNU Free Documentation License 305
be listed in the History section of the Document). You may use the same title as a
previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five
of the principal authors of the Document (all of its principal authors, if it has fewer
than five), unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled “History”, Preserve its Title, and add to it an item
stating at least the title, year, new authors, and publisher of the Modified Version as
given on the Title Page. If there is no section Entitled “History” in the Document,
create one stating the title, year, authors, and publisher of the Document as given
on its Title Page, then add an item describing the Modified Version as stated in
the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to
a Transparent copy of the Document, and likewise the network locations given in
the Document for previous versions it was based on. These may be placed in the
“History” section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
K. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title
of the section, and preserve in the section all the substance and tone of each of the
contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and
in their titles. Section numbers or the equivalent are not considered part of the
section titles.
M. Delete any section Entitled “Endorsements”. Such a section may not be included
in the Modified Version.
N. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in
title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
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
Appendix A: GNU Free Documentation License 306
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.
5. COMBINING DOCUMENTS
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.”
6. COLLECTIONS OF DOCUMENTS
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.
Appendix A: GNU Free Documentation License 307