[Top] [Contents] [Index] [ ? ]

PSPP

This file documents the PSPP package for statistical analysis of sampled data. This is edition 0.2, for PSPP version 0.2, last modified at Time-stamp: <2000-01-02 22:32:14 blp>.

1. Introduction  Description of the package.
2. Your rights and obligations  
3. Credits  Acknowledgement of authors.
4. Installing PSPP  How to compile and install PSPP.
5. Configuring PSPP  
6. Invoking PSPP  Starting and running PSPP.
7. The PSPP language  Basics of the PSPP command language.
8. Mathematical Expressions  Numeric and string expression syntax.
9. Data Input and Output  Reading data from user files.
10. System Files and Portable Files  Dealing with system & portable files.
11. Manipulating variables  Adjusting and examining variables.
12. Data transformations  Simple operations on data.
13. Selecting data for analysis  Select certain cases for analysis.
14. Conditional and Looping Constructs  Doing things many times or not at all.
15. Statistics  Basic statistical procedures.
16. Utilities  Other commands.
17. Not Implemented  What's not here yet
18. Data File Format  Format of PSPP system files.
19. Portable File Format  Format of PSPP portable files.
20. q2c Input Format  Format of syntax accepted by q2c.
21. Bugs  Known problems; submitting bug reports.
22. Function Index  Index of PSPP functions for expressions.
23. Concept Index  Index of concepts.
24. Command Index  Index of PSPP procedures.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Introduction

PSPP is a tool for statistical analysis of sampled data. It reads a syntax file and a data file, analyzes the data, and writes the results to a listing file or to standard output.

The language accepted by PSPP is similar to those accepted by SPSS statistical products. The details of PSPP's language are given later in this manual.

PSPP produces output in two forms: tables and charts. Both of these can be written in several formats; currently, ASCII, PostScript, and HTML are supported. In the future, more drivers, such as PCL and X Window System drivers, may be developed. For now, Ghostscript, available from the Free Software Foundation, may be used to convert PostScript chart output to other formats.

The current version of PSPP, 0.2, is woefully incomplete in terms of its statistical procedure support. PSPP is a work in progress. The author hopes to support fully support all features in the products that PSPP replaces, eventually. The author welcomes questions, comments, donations, and code submissions. See section Submitting Bug Reports, for instructions on contacting the author.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Your rights and obligations

Most of PSPP is distributed under the GNU General Public License. The General Public License says, in effect, that you may modify and distribute PSPP as you like, as long as you grant the same rights to others. It also states that you must provide source code when you distribute PSPP, or, if you obtained PSPP source code from an anonymous ftp site, give out the name of that site.

The General Public License is given in full in the source distribution as file `COPYING'. In Debian GNU/Linux, this file is also available as file `/usr/doc/copyright/GPL'.

To quote the GPL itself:

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Credits

I'm always embarrassed when I see an index an author has made of his own work. It's a shameless exhibition--to the trained eye. Never index your own book.

---Claire Minton, Cat's Cradle, Kurt Vonnegut, Jr.

Most of PSPP, as well as this manual (including the indices), was written by Ben Pfaff. See section 21.2 Contacting the Author, for instructions on contacting the author.

The PSPP source code incorporates julcal10 originally written by Michael A. Covington and translated into C by Jim Van Zandt. The original package can be found in directory `ftp://ftp.cdrom.com/pub/algorithms/c/julcal10'. The entire contents of that directory constitute the package. The files actually used in PSPP are julcal.c and julcal.h.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Installing PSPP

PSPP conforms to the GNU Coding Standards. PSPP is written in, and requires for proper operation, ANSI/ISO C. You might want to additionally note the following points:

Many UNIX variants should work out-of-the-box, as PSPP uses GNU autoconf to detect differences between environments. Please report any problems with compilation of PSPP under UNIX and UNIX-like operating systems--portability is a major concern of the author.

The pages below give specific instructions for installing PSPP on each type of system mentioned above.

4.1 UNIX installation  Installing on UNIX-like environments.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 UNIX installation

To install PSPP under a UNIX-like operating system, follow the steps below in order. Some of the text below was taken directly from various Free Software Foundation sources.

  1. cd to the directory containing the PSPP source.

  2. Type `./configure' to configure for your particular operating system and compiler. Running configure takes a while. While running, it displays some messages telling which features it is checking for.

    You can optionally supply some options to configure in order to give it hints about how to do its job. Type ./configure --help to see a list of options. One of the most useful options is `--with-checker', which enables the use of the Checker memory debugger under supported operating systems. Checker must already be installed to use this option. Do not use `--with-checker' if you are not debugging PSPP itself.

  3. (optional) Edit `Makefile', `config.h', and `pref.h'. These files are produced by configure. Note that most PSPP settings can be changed at runtime.

    `pref.h' is only generated by configure if it does not already exist. (It's copied from `prefh.orig'.)

  4. Type `make' to compile the package. If there are any errors during compilation, try to fix them. If modifications are necessary to compile correctly under your configuration, contact the author. See section Submitting Bug Reports, for details.

  5. Type `make check' to run self-tests on the compiled PSPP package.

  6. Become the superuser and type `make install' to install the PSPP binaries, by default in `/usr/local/bin/'. The directory `/usr/local/share/pspp/' is created and populated with files needed by PSPP at runtime. This step will also cause the PSPP documentation to be installed in `/usr/local/info/', but only if that directory already exists.

  7. (optional) Type `make clean' to delete the PSPP binaries from the source tree.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Configuring PSPP

PSPP has dozens of configuration possibilities and hundreds of settings. This is both a bane and a blessing. On one hand, it's possible to easily accommodate diverse ranges of setups. But, on the other, the multitude of possibilities can overwhelm the casual user. Fortunately, the configuration mechanisms are profusely described in the sections below....

5.1 Locating configuration files  How PSPP finds config files.
5.2 Configuration techniques  Many different methods of configuration....
5.3 Configuration files  How configuration files are read.
5.4 Environment variables  All about environment variables.
5.5 Output devices  Describing your terminal(s) and printer(s).
5.6 The PostScript driver class  Configuration of PostScript devices.
5.7 The ASCII driver class  Configuration of character-code devices.
5.8 The HTML driver class  Configuration for HTML output.
5.9 Miscellaneous configuration  Even more configuration variables.
5.10 Improving output quality  Hints for producing ever-more-lovely output.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Locating configuration files

PSPP uses the same method to find most of its configuration files:

  1. The base name of the file being sought is determined.

  2. The path to search is determined.

  3. Each directory in the search path, from left to right, is searched for a file with the name of the base name. The first occurrence is read as the configuration file.

The first two steps are elaborated below for the sake of our pedantic friends.

  1. A base name is a file name lacking an absolute directory reference. Some examples of base names are: `ps-encodings', `devices', `devps/DESC' (under UNIX), `devps\DESC' (under M$ environments).

    Determining the base name is a two-step process:

    1. If the appropriate environment variable is defined, the value of that variable is used (see section 5.4 Environment variables). For instance, when searching for the output driver initialization file, the variable examined is STAT_OUTPUT_INIT_FILE.

    2. Otherwise, the compiled-in default is used. For example, when searching for the output driver initialization file, the default base name is `devices'.

    Please note: If a user-specified base name does contain an absolute directory reference, as in a file name like `/home/pfaff/fonts/TR', no path is searched--the file name is used exactly as given--and the algorithm terminates.

  2. The path is the first of the following that is defined:

As a final note: Under DOS, directories given in paths are delimited by semicolons (`;'); under UNIX, directories are delimited by colons (`:'). This corresponds with the standard path delimiter under these OSes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Configuration techniques

There are many ways that PSPP can be configured. These are described in the list below. Values given by earlier items take precedence over those given by later items.

  1. Syntax commands that modify settings, such as SET.

  2. Command-line options. See section 6. Invoking PSPP.

  3. PSPP-specific environment variable contents. See section 5.4 Environment variables.

  4. General environment variable contents. See section 5.4 Environment variables.

  5. Configuration file contents. See section 5.3 Configuration files.

  6. Fallback defaults.

Some of the above may not apply to a particular setting. For instance, the current pager (such as `more', `most', or `less') cannot be determined by configuration file contents because there is no appropriate configuration file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 Configuration files

Most configuration files have a common form:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Environment variables

You may think the concept of environment variables is a fairly simple one. However, the author of PSPP has found a way to complicate even something so simple. Environment variables are further described in the sections below:

5.4.1 Values of environment variables  Values of variables are determined this way.
5.4.2 Environment substitutions  How environment substitutions are made.
5.4.3 Predefined environment variables  A few variables are automatically defined.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.1 Values of environment variables

Values for environment variables are obtained by the following means, which are arranged in order of decreasing precedence:

  1. Command-line options. See section 6. Invoking PSPP.

  2. The `environment' configuration file--more on this below.

  3. Actual environment variables (defined in the shell or other parent process).

The `environment' configuration file is located through application of the usual algorithm for configuration files (see section 5.1 Locating configuration files), except that its contents do not affect the search path used to find `environment' itself. Use of `environment' is discouraged on systems that allow an arbitrarily large environment; it is supported for use on systems like MS-DOS that limit environment size.

`environment' is composed of lines having the form `key=value', where key and the equals sign (`=') are required, and value is optional. If value is given, variable key is given that value; if value is absent, variable key is undefined (deleted). Variables may not be defined with a null value.

Environment substitutions are performed on each line in the file (see section 5.4.2 Environment substitutions).

See 5.3 Configuration files, for more details on formatting of the environment configuration file.

Please note: Support for `environment' is not yet implemented.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.2 Environment substitutions

Much of the power of environment variables lies in the way that they may be substituted into configuration files. Variable substitutions are described below.

The line is scanned from left to right. In this scan, all characters other than dollar signs (`$') are retained unmolested. Dollar signs, however, introduce an environment variable reference. References take three forms:

$var
Replaced by the value of environment variable var, determined as specified in 5.4.1 Values of environment variables. var must be one of the following:

${var}
Same as above, but var may contain any character (except `}').

$$
Replaced by a single dollar sign.

Undefined variables expand to a empty value.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.3 Predefined environment variables

There are two environment variables predefined for use in environment substitutions:

`VER'
Defined as the version number of PSPP, as a string, in a format something like `0.9.4'.

`ARCH'
Defined as the host architecture of PSPP, as a string, in standard cpu-manufacturer-OS format. For instance, Debian GNU/Linux 1.1 on an Intel machine defines this as `i586-unknown-linux'. This is somewhat dependent on the system used to compile PSPP.

Nothing prevents these values from being overridden, although it's a good idea not to do so.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 Output devices

Configuring output devices is the most complicated aspect of configuring PSPP. The output device configuration file is named `devices'. It is searched for using the usual algorithm for finding configuration files (see section 5.1 Locating configuration files). Each line in the file is read in the usual manner for configuration files (see section 5.3 Configuration files).

Lines in `devices' are divided into three categories, described briefly in the table below:

driver category definitions
Define a driver in terms of other drivers.

macro definitions
Define environment variables local to the the output driver configuration file.

device definitions
Describe the configuration of an output device.

The following sections further elaborate the contents of the `devices' file.

5.5.1 Driver categories  How to organize the driver namespace.
5.5.2 Macro definitions  Environment variables local to `devices'.
5.5.3 Driver definitions  Output device descriptions.
5.5.4 Dimensions  Lengths, widths, sizes, ....
5.5.5 Paper sizes  Letter, legal, A4, envelope, ....
5.5.6 How lines are divided into types  Details on `devices' parsing.
5.5.7 How lines are divided into tokens  Dividing `devices' lines into tokens.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.1 Driver categories

Drivers can be divided into categories. Drivers are specified by their names, or by the names of the categories that they are contained in. Only certain drivers are enabled each time PSPP is run; by default, these are the drivers in the category `default'. To enable a different set of drivers, use the `-o device' command-line option (see section 6. Invoking PSPP).

Categories are specified with a line of the form `category=driver1 driver2 driver3 ... drivern'. This line specifies that the category category is composed of drivers named driver1, driver2, and so on. There may be any number of drivers in the category, from zero on up.

Categories may also be specified on the command line (see section 6. Invoking PSPP).

This is all you need to know about categories. If you're still curious, read on.

First of all, the term `categories' is a bit of a misnomer. In fact, the internal representation is nothing like the hierarchy that the term seems to imply: a linear list is used to keep track of the enabled drivers.

When PSPP first begins reading `devices', this list contains the name of any drivers or categories specified on the command line, or the single item `default' if none were specified.

Each time a category definition is specified, the list is searched for an item with the value of category. If a matching item is found, it is deleted. If there was a match, the list of drivers (driver1 through drivern) is then appended to the list.

Each time a driver definition line is encountered, the list is searched. If the list contains an item with that driver's name, the driver is enabled and the item is deleted from the list. Otherwise, the driver is not enabled.

It is an error if the list is not empty when the end of `devices' is reached.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.2 Macro definitions

Macro definitions take the form `define macroname definition'. In such a macro definition, the environment variable macroname is defined to expand to the value definition. Before the definition is made, however, any macros used in definition are expanded.

Please note the following nuances of macro usage:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.3 Driver definitions

Driver definitions are the ultimate purpose of the `devices' configuration file. These are where the real action is. Driver definitions tell PSPP where it should send its output.

Each driver definition line is divided into four fields. These fields are delimited by colons (`:'). Each line is subjected to environment variable interpolation before it is processed further (see section 5.4.2 Environment substitutions). From left to right, the four fields are, in brief:

driver name
A unique identifier, used to determine whether to enable the driver.

class name
One of the predefined driver classes supported by PSPP. The currently supported driver classes include `postscript' and `ascii'.

device type(s)
Zero or more of the following keywords, delimited by spaces:

screen

Indicates that the device is a screen display. This may reduce the amount of buffering done by the driver, to make interactive use more convenient.

printer

Indicates that the device is a printer.

listing

Indicates that the device is a listing file.

These options are just hints to PSPP and do not cause the output to be directed to the screen, or to the printer, or to a listing file--those must be set elsewhere in the options. They are used primarily to decide which devices should be enabled at any given time. See section 16.10 SET, for more information.

options
An optional set of options to pass to the driver itself. The exact format for the options varies among drivers.

The driver is enabled if:

  1. Its driver name is specified on the command line, or

  2. It's in a category specified on the command line, or

  3. If no categories or driver names are specified on the command line, it is in category default.

For more information on driver names, see 5.5.1 Driver categories.

The class name must be one of those supported by PSPP. The classes supported depend on the options with which PSPP was compiled. See later sections in this chapter for descriptions of the available driver classes.

Options are dependent on the driver. See the driver descriptions for details.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.4 Dimensions

Quite often in configuration it is necessary to specify a length or a size. PSPP uses a common syntax for all such, calling them collectively by the name dimensions.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.5 Paper sizes

Output drivers usually deal with some sort of hardcopy media. This media is called paper by the drivers, though in reality it could be a transparency or film or thinly veiled sarcasm. To make it easier for you to deal with paper, PSPP allows you to have (of course!) a configuration file that gives symbolic names, like "letter" or "legal" or "a4", to paper sizes, rather than forcing you to use cryptic numbers like "8-1/2 x 11" or "210 by 297". Surprisingly enough, this configuration file is named `papersize'. See section 5.3 Configuration files.

When PSPP tries to connect a symbolic paper name to a paper size, it reads and parses each non-comment line in the file, in order. The first field on each line must be a symbolic paper name in double quotes. Paper names may not contain double quotes. Paper names are not case-sensitive: `legal' and `Legal' are equivalent.

If a match is found for the paper name, the rest of the line is parsed. If it is found to be a pair of dimensions (see section 5.5.4 Dimensions) separated by either `x' or `by', then those are taken to be the paper size, in order of width followed by length. There must be at least one space on each side of `x' or `by'.

Otherwise the line must be of the form `"paper-1"="paper-2"'. In this case the target of the search becomes paper name paper-2 and the search through the file continues.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.6 How lines are divided into types

The lines in `devices' are distinguished in the following manner:

  1. Leading whitespace is removed.

  2. If the resulting line begins with the exact string define, followed by one or more whitespace characters, the line is processed as a macro definition.

  3. Otherwise, the line is scanned for the first instance of a colon (`:') or an equals sign (`=').

  4. If a colon is encountered first, the line is processed as a driver definition.

  5. Otherwise, if an equals sign is encountered, the line is processed as a macro definition.

  6. Otherwise, the line is ill-formed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.7 How lines are divided into tokens

Each driver definition line is run through a simple tokenizer. This tokenizer recognizes two basic types of tokens.

The first type is an equals sign (`='). Equals signs are both delimiters between tokens and tokens in themselves.

The second type is an identifier or string token. Identifiers and strings are equivalent after tokenization, though they are written differently. An identifier is any string of characters other than whitespace or equals sign.

A string is introduced by a single- or double-quote character (`'' or `"') and, in general, continues until the next occurrence of that same character. The following standard C escapes can also be embedded within strings:

\'
A single-quote (`'').

\"
A double-quote (`"').

\?
A question mark (`?'). Included for hysterical raisins.

\\
A backslash (`\').

\a
Audio bell (ASCII 7).

\b
Backspace (ASCII 8).

\f
Formfeed (ASCII 12).

\n
Newline (ASCII 10)

\r
Carriage return (ASCII 13).

\t
Tab (ASCII 9).

\v
Vertical tab (ASCII 11).

\ooo
Each `o' must be an octal digit. The character is the one having the octal value specified. Any number of octal digits is read and interpreted; only the lower 8 bits are used.

\xhh
Each `h' must be a hex digit. The character is the one having the hexadecimal value specified. Any number of hex digits is read and interpreted; only the lower 8 bits are used.

Tokens, outside of quoted strings, are delimited by whitespace or equals signs.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6 The PostScript driver class

The postscript driver class is used to produce output that is acceptable to PostScript printers and to PC-based PostScript interpreters such as Ghostscript. Continuing a long tradition, PSPP's PostScript driver is configurable to the point of absurdity.

There are actually two PostScript drivers. The first one, `postscript', produces ordinary DSC-compliant PostScript output. The second one `epsf', produces an Encapsulated PostScript file. The two drivers are otherwise identical in configuration and in operation.

The PostScript driver is described in further detail below.

5.6.1 PostScript output options  Output file options.
5.6.2 PostScript page options  Paper, margins, scaling & rotation, more!
5.6.3 PostScript file options  Configuration files.
5.6.4 PostScript font options  Default fonts, font options.
5.6.5 PostScript line options  Line widths, options.
5.6.6 The PostScript prologue  Details on the PostScript prologue.
5.6.7 PostScript encodings  Details on PostScript font encodings.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.1 PostScript output options

These options deal with the form of the output and the output file itself:

output-file=filename

File to which output should be sent. This can be an ordinary filename (i.e., "pspp.ps"), a pipe filename (i.e., "|lpr"), or stdout ("-"). Default: "pspp.ps".

color=boolean

Most of the time black-and-white PostScript devices are smart enough to map colors to shades themselves. However, you can cause the PSPP output driver to do an ugly simulation of this in its own driver by turning color off. Default: on.

This is a boolean setting, as are many settings in the PostScript driver. Valid positive boolean values are `on', `true', `yes', and nonzero integers. Negative boolean values are `off', `false', `no', and zero.

data=data-type

One of clean7bit, clean8bit, or binary. This controls what characters will be written to the output file. PostScript produced with clean7bit can be transmitted over 7-bit transmission channels that use ASCII control characters for line control. clean8bit is similar but allows characters above 127 to be written to the output file. binary allows any character in the output file. Default: clean7bit.

line-ends=line-end-type

One of cr, lf, or crlf. This controls what is used for newline in the output file. Default: cr.

optimize-line-size=level

Either 0 or 1. If level is 1, then short line segments will be collected and merged into longer ones. This reduces output file size but requires more time and memory. A level of 0 has the advantage of being better for interactive environments. 1 is the default unless the screen flag is set; in that case, the default is 0.

optimize-text-size=level

One of 0, 1, or 2, each higher level representing correspondingly more aggressive space savings for text in the output file and requiring correspondingly more time and memory. Unfortunately the levels presently are all the same. 1 is the default unless the screen flag is set; in that case, the default is 0.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.2 PostScript page options

These options affect page setup:

headers=boolean

Controls whether the standard headers showing the time and date and title and subtitle are printed at the top of each page. Default: on.

paper-size=paper-size

Paper size, either as a symbolic name (i.e., letter or a4) or specific measurements (i.e., 8-1/2x11 or "210 x 297". See section Paper sizes. Default: letter.

orientation=orientation

Either portrait or landscape. Default: portrait.

left-margin=dimension
right-margin=dimension
top-margin=dimension
bottom-margin=dimension

Sets the margins around the page. The headers, if enabled, are not included in the margins; they are in addition to the margins. For a description of dimensions, see 5.5.4 Dimensions. Default: 0.5in.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.3 PostScript file options

Oh, my. You don't really want to know about the way that the PostScript driver deals with files, do you? Well I suppose you're entitled, but I warn you right now: it's not pretty. Here goes....

First let's look at the options that are available:

font-dir=font-directory

Sets the font directory. Default: devps.

prologue-file=prologue-file-name

Sets the name of the PostScript prologue file. You can write your own prologue, though I have no idea why you'd want to: see 5.6.6 The PostScript prologue. Default: ps-prologue.

device-file=device-file-name

Sets the name of the Groff-format device description file. The PostScript driver reads this in order to know about the scaling of fonts and so on. The format of such files is described in groff_font(5), included with Groff. Default: DESC.

encoding-file=encoding-file-name

Sets the name of the encoding file. This file contains a list of all font encodings that will be needed so that the driver can put all of them at the top of the prologue. See section 5.6.7 PostScript encodings. Default: ps-encodings.

If the specified encoding file cannot be found, this error will be silently ignored, since most people do not need any encodings besides the ones that can be found using auto-encodings, described below.

auto-encode=boolean

When enabled, the font encodings needed by the default proportional- and fixed-pitch fonts will automatically be dumped to the PostScript output. Otherwise, it is assumed that the user has an encoding file and knows how to use it (see section 5.6.7 PostScript encodings). There is probably no good reason to turn off this convenient feature. Default: on.

Next I suppose it's time to describe the search algorithm. When the PostScript driver needs a file, whether that file be a font, a PostScript prologue, or what you will, it searches in this manner:

  1. Constructs a path by taking the first of the following that is defined:

    1. Environment variable STAT_GROFF_FONT_PATH. See section 5.4 Environment variables.

    2. Environment variable GROFF_FONT_PATH.

    3. The compiled-in fallback default.

  2. Constructs a base name from concatenating, in order, the font directory, a path separator (`/' or `\'), and the file to be found. A typical base name would be something like devps/ps-encodings.

  3. Searches for the base name in the path constructed above. If the file is found, the algorithm terminates.

  4. Searches for the base name in the standard configuration path. See 5.1 Locating configuration files, for more details. If the file is found, the algorithm terminates.

  5. At this point we remove the font directory and path separator from the base name. Now the base name is simply the file to be found, i.e., ps-encodings.

  6. Searches for the base name in the path constructed in the first step. If the file is found, the algorithm terminates.

  7. Searches for the base name in the standard configuration path. If the file is found, the algorithm terminates.

  8. The algorithm terminates unsuccessfully.

So, as you see, there are several ways to configure the PostScript drivers. Careful selection of techniques can make the configuration very flexible indeed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.4 PostScript font options

The list of available font options is short and sweet:

prop-font=font-name

Sets the default proportional font. The name should be that of a PostScript font. Default: "Helvetica".

fixed-font=font-name

Sets the default fixed-pitch font. The name should be that of a PostScript font. Default: "Courier".

font-size=font-size

Sets the size of the default fonts, in thousandths of a point. Default: 10000.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.5 PostScript line options

Most tables contain lines, or rules, between cells. Some features of the way that lines are drawn in PostScript tables are user-definable:

line-style=style

Sets the style used for lines used to divide tables into sections. style must be either thick, in which case thick lines are used, or double, in which case double lines are used. Default: thick.

line-gutter=dimension

Sets the line gutter, which is the amount of whitespace on either side of lines that border text or graphics objects. See section 5.5.4 Dimensions. Default: 0.5pt.

line-spacing=dimension

Sets the line spacing, which is the amount of whitespace that separates lines that are side by side, as in a double line. Default: 0.5pt.

line-width=dimension

Sets the width of a typical line used in tables. Default: 0.5pt.

line-width-thick=dimension

Sets the width of a thick line used in tables. Not used if line-style is set to thick. Default: 1.5pt.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.6 The PostScript prologue

Most PostScript files that are generated mechanically by programs consist of two parts: a prologue and a body. The prologue is generally a collection of boilerplate. Only the body differs greatly between two outputs from the same program. This is also the strategy used in the PSPP PostScript driver. In general, the prologue supplied with PSPP will be more than sufficient. In this case, you will not need to read the rest of this section. However, hackers might want to know more. Read on, if you fall into this category.

The prologue is dumped into the output stream essentially unmodified. However, two actions are performed on its lines. First, certain lines may be omitted as specified in the prologue file itself. Second, variables are substituted.

The following lines are omitted:

  1. All lines that contain three bangs in a row (!!!).

  2. Lines that contain !eps, if the PostScript driver is producing ordinary PostScript output. Otherwise an EPS file is being produced, and the line is included in the output, although everything following !eps is deleted.

  3. Lines that contain !ps, if the PostScript driver is producing EPS output. Otherwise, ordinary PostScript is being produced, and the line is included in the output, although everything following !ps is deleted.

The following are the variables that are substituted. Only the variables listed are substituted; environment variables are not. See section 5.4.2 Environment substitutions.

bounding-box

The page bounding box, in points, as four space-separated numbers. For U.S. letter size paper, this is `0 0 612 792'.

creator

PSPP version as a string: `GNU PSPP 0.1b', for example.

date

Date the file was created. Example: `Tue May 21 13:46:22 1991'.

data

Value of the data PostScript driver option, as one of the strings `Clean7Bit', `Clean8Bit', or `Binary'.

orientation

Page orientation, as one of the strings Portrait or Landscape.

user

Under multiuser OSes, the user's login name, taken either from the environment variable LOGNAME or, if that fails, the result of the C library function getlogin(). Defaults to `nobody'.

host

System hostname as reported by gethostname(). Defaults to `nowhere'.

prop-font

Name of the default proportional font, prefixed by the word `font' and a space. Example: `font Times-Roman'.

fixed-font

Name of the default fixed-pitch font, prefixed by the word `font' and a space.

scale-factor

The page scaling factor as a floating-point number. Example: 1.0. Note that this is also passed as an argument to the BP macro.

paper-length
paper-width

The paper length and paper width, respectively, in thousandths of a point. Note that these are also passed as arguments to the BP macro.

left-margin
top-margin

The left margin and top margin, respectively, in thousandths of a point. Note that these are also passed as arguments to the BP macro.

title

Document title as a string. This is not the title specified in the PSPP syntax file. A typical title is the word `PSPP' followed by the syntax file name in parentheses. Example: `PSPP (<stdin>)'.

source-file

PSPP syntax file name. Example: `mary96/first.stat'.

Any other questions about the PostScript prologue can best be answered by examining the default prologue or the PSPP source.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.7 PostScript encodings

PostScript fonts often contain many more than 256 characters, in order to accommodate foreign language characters and special symbols. PostScript uses encodings to map these onto single-byte symbol sets. Each font can have many different encodings applied to it.

PSPP's PostScript driver needs to know which encoding to apply to each font. It can determine this from the information encapsulated in the Groff font description that it reads. However, there is an additional problem--for efficiency, the PostScript driver needs to have a complete list of all encodings that will be used in the entire session when it opens the output file. For this reason, it can't use the information built into the fonts because it doesn't know which fonts will be used.

As a stopgap solution, there are two mechanisms for specifying which encodings will be used. The first mechanism is automatic and it is the only one that most PSPP users will ever need. The second mechanism is manual, but it is more flexible. Either mechanism or both may be used at one time.

The first mechanism is activated by the `auto-encode' driver option (see section 5.6.3 PostScript file options). When enabled, `auto-encode' causes the PostScript driver to include the encodings used by the default proportional and fixed-pitch fonts (see section 5.6.4 PostScript font options). Many PSPP output files will only need these encodings.

The second mechanism is the file specified by the `encoding-file' option (see section 5.6.3 PostScript file options). If it exists, this file must consist of lines in PSPP configuration-file format (see section 5.3 Configuration files). Each line that is not a comment should name a PostScript encoding to include in the output.

It is not an error if an encoding is included more than once, by either mechanism. It will appear only once in the output. It is also not an error if an encoding is included in the output but never used. It is an error if an encoding is used but not included by one of these mechanisms. In this case, the built-in PostScript encoding `ISOLatin1Encoding' is substituted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7 The ASCII driver class

The ASCII driver class produces output that can be displayed on a terminal or output to printers. All of its options are highly configurable. The ASCII driver has class name `ascii'.

The ASCII driver is described in further detail below.

5.7.1 ASCII output options  Output file options.
5.7.2 ASCII page options  Page size, margins, more.
5.7.3 ASCII font options  Box character, bold & italics.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7.1 ASCII output options

output-file=filename

File to which output should be sent. This can be an ordinary filename (i.e., "pspp.ps"), a pipe filename (i.e., "|lpr"), or stdout ("-"). Default: "pspp.list".

char-set=char-set-type

One of `ascii' or `latin1'. This has no effect on output at the present time. Default: ascii.

form-feed-string=form-feed-value

The string written to the output to cause a formfeed. See also paginate, described below, for a related setting. Default: "\f".

newline-string=newline-value

The string written to the output to cause a newline (carriage return plus linefeed). The default, which can be specified explicitly with newline-string=default, is to use the system-dependent newline sequence by opening the output file in text mode. This is usually the right choice.

However, newline-string can be set to any string. When this is done, the output file is opened in binary mode.

paginate=boolean

If set, a formfeed (as set in form-feed-string, described above) will be written to the device after every page. Default: on.

tab-width=tab-width-value

The distance between tab stops for this device. If set to 0, tabs will not be used in the output. Default: 8.

init=initialization-string.

String written to the device before anything else, at the beginning of the output. Default: "" (the empty string).

done=finalization-string.

String written to the device after everything else, at the end of the output. Default: "" (the empty string).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7.2 ASCII page options

These options affect page setup:

headers=boolean

If enabled, two lines of header information giving title and subtitle, page number, date and time, and PSPP version are printed at the top of every page. These two lines are in addition to any top margin requested. Default: on.

length=line-count

Physical length of a page, in lines. Headers and margins are subtracted from this value. Default: 66.

width=character-count

Physical width of a page, in characters. Margins are subtracted from this value. Default: 130.

lpi=lines-per-inch

Number of lines per vertical inch. Not currently used. Default: 6.

cpi=characters-per-inch

Number of characters per horizontal inch. Not currently used. Default: 10.

left-margin=left-margin-width

Width of the left margin, in characters. PSPP subtracts this value from the page width. Default: 0.

right-margin=right-margin-width

Width of the right margin, in characters. PSPP subtracts this value from the page width. Default: 0.

top-margin=top-margin-lines

Length of the top margin, in lines. PSPP subtracts this value from the page length. Default: 2.

bottom-margin=bottom-margin-lines

Length of the bottom margin, in lines. PSPP subtracts this value from the page length. Default: 2.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7.3 ASCII font options

These are the ASCII font options:

box[line-type]=box-chars

The characters used for lines in tables produced by the ASCII driver can be changed using this option. line-type is used to indicate which type of line to change; box-chars is the character or string of characters to use for this type of line.

line-type must be a 4-digit number in base 4. The digits are in the order `right', `bottom', `left', `top'. The four possibilities for each digit are:

0
No line.

1
Single line.

2
Double line.

3
Special device-defined line, if one is available; otherwise, a double line.

Examples:

box[0101]="|"

Sets `|' as the character to use for a single-width line with bottom and top components.

box[2222]="#"

Sets `#' as the character to use for the intersection of four double-width lines, one each from the top, bottom, left and right.

box[1100]="\xda"

Sets `"\xda"', which under MS-DOG is a box character suitable for the top-left corner of a box, as the character for the intersection of two single-width lines, one each from the right and bottom.

Defaults:

italic-on=italic-on-string

Character sequence written to turn on italics or underline printing. If this is set to overstrike, then the driver will simulate underlining by overstriking with underscore characters (`_') in the manner described by overstrike-style and carriage-return-style. Default: overstrike.

italic-off=italic-off-string

Character sequence to turn off italics or underline printing. Default: "" (the empty string).

bold-on=bold-on-string

Character sequence written to turn on bold or emphasized printing. If set to overstrike, then the driver will simulated bold printing by overstriking characters in the manner described by overstrike-style and carriage-return-style. Default: overstrike.

bold-off=bold-off-string

Character sequence to turn off bold or emphasized printing. Default: "" (the empty string).

bold-italic-on=bold-italic-on-string

Character sequence written to turn on bold-italic printing. If set to overstrike, then the driver will simulate bold-italics by overstriking twice, once with the character, a second time with an underscore (`_') character, in the manner described by overstrike-style and carriage-return-style. Default: overstrike.

bold-italic-off=bold-italic-off-string

Character sequence to turn off bold-italic printing. Default: "" (the empty string).

overstrike-style=overstrike-option

Either single or line:

single is recommended for use with ttys and programs that understand overstriking in text files, such as the pager less. single will also work with printer devices but results in rapid back-and-forth motions of the printhead that can cause the printer to physically overheat!

line is recommended for use with printer devices. Most programs that understand overstriking in text files will not properly deal with line mode.

Default: single.

carriage-return-style=carriage-return-type

Either bs or cr. This option applies only when one or more of the font commands is set to overstrike and, at the same time, overstrike-style is set to line.

Although cr is preferred as being more compact, bs is more general since some devices do not interpret carriage returns in the desired manner. Default: bs.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8 The HTML driver class

The html driver class is used to produce output for viewing in tables-capable web browsers such as Emacs' w3-mode. Its configuration is very simple. Currently, the output has a very plain format. In the future, further work may be done on improving the output appearance.

There are few options for use with the html driver class:

output-file=filename

File to which output should be sent. This can be an ordinary filename (i.e., "pspp.ps"), a pipe filename (i.e., "|lpr"), or stdout ("-"). Default: "pspp.html".

prologue-file=prologue-file-name

Sets the name of the PostScript prologue file. You can write your own prologue if you want to customize colors or other settings: see 5.8.1 The HTML prologue. Default: html-prologue.

5.8.1 The HTML prologue  Format of the HTML prologue file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.1 The HTML prologue

HTML files that are generated by PSPP consist of two parts: a prologue and a body. The prologue is a collection of boilerplate. Only the body differs greatly between two outputs. You can tune the colors and other attributes of the output by editing the prologue. The prologue is dumped into the output stream essentially unmodified. However, two actions are performed on its lines. First, certain lines may be omitted as specified in the prologue file itself. Second, variables are substituted.

The following lines are omitted:

  1. All lines that contain three bangs in a row (!!!).

  2. Lines that contain !title, if no title is set for the output. If a title is set, then the characters !title are removed before the line is output.

  3. Lines that contain !subtitle, if no subtitle is set for the output. If a subtitle is set, then the characters !subtitle are removed before the line is output.

The following are the variables that are substituted. Only the variables listed are substituted; environment variables are not. See section 5.4.2 Environment substitutions.

generator

PSPP version as a string: `GNU PSPP 0.1b', for example.

date

Date the file was created. Example: `Tue May 21 13:46:22 1991'.

user

Under multiuser OSes, the user's login name, taken either from the environment variable LOGNAME or, if that fails, the result of the C library function getlogin(). Defaults to `nobody'.

host

System hostname as reported by gethostname(). Defaults to `nowhere'.

title

Document title as a string. This is the title specified in the PSPP syntax file.

subtitle

Document subtitle as a string.

source-file

PSPP syntax file name. Example: `mary96/first.stat'.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9 Miscellaneous configuration

The following environment variables can be used to further configure PSPP:

HOME

Used to determine the user's home directory. No default value.

STAT_INCLUDE_PATH

Path used to find include files in PSPP syntax files. Defaults vary across operating systems:

UNIX

  • `.'

  • `~/.pspp/include'

  • `/usr/local/lib/pspp/include'

  • `/usr/lib/pspp/include'

  • `/usr/local/share/pspp/include'

  • `/usr/share/pspp/include'

MS-DOS

  • `.'

  • `C:\PSPP\INCLUDE'

  • `$PATH'

Other OSes
No default path.

STAT_PAGER
PAGER

When PSPP invokes an external pager, it uses the first of these that is defined. There is a default pager only if the person who compiled PSPP defined one.

TERM

The terminal type termcap or ncurses will use, if such support was compiled into PSPP.

STAT_OUTPUT_INIT_FILE

The basename used to search for the driver definition file. See section 5.5 Output devices. See section 5.1 Locating configuration files. Default: devices.

STAT_OUTPUT_PAPERSIZE_FILE

The basename used to search for the papersize file. See section 5.5.5 Paper sizes. See section 5.1 Locating configuration files. Default: papersize.

STAT_OUTPUT_INIT_PATH

The path used to search for the driver definition file and the papersize file. See section 5.1 Locating configuration files. Default: the standard configuration path.

TMPDIR

The sort procedure stores its temporary files in this directory. Default: (UNIX) `/tmp', (MS-DOS) `\', (other OSes) empty string.

TEMP
TMP

Under MS-DOS only, these variables are consulted after TMPDIR, in this order.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.10 Improving output quality

When its drivers are set up properly, PSPP can produce output that looks very good indeed. The PostScript driver, suitably configured, can produce presentation-quality output. Here are a few guidelines for producing better-looking output, regardless of output driver. Your mileage may vary, of course, and everyone has different esthetic preferences.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Invoking PSPP

 
pspp [ -B dir | --config-dir=dir ] [ -o device | --device=device ]
       [ -d var[=value] | --define=var[=value] ] [-u var | --undef=var ]
       [ -f file | --out-file=file ] [ -p | --pipe ] [ -I- | --no-include ]
       [ -I dir | --include=dir ] [ -i | --interactive ] 
       [ -n | --edit | --dry-run | --just-print | --recon ] 
       [ -r | --no-statrc ] [ -h | --help ] [ -l | --list ] 
       [ -c command | --command command ] [ -s | --safer ]
       [ --testing-mode ] [ -V | --version ] [ -v | --verbose ] 
       [ key=value ] file....

6.1 Non-option Arguments  Specifying syntax files and output devices.
6.2 Configuration Options  Change the configuration for the current run.
6.3 Input and output options  Controlling input and output files.
6.4 Language control options  Language variants.
6.5 Informational options  Helpful information about PSPP.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1 Non-option Arguments

Syntax files and output device substitutions can be specified on PSPP's command line:

file

A file by itself on the command line will be executed as a syntax file. PSPP terminates after the syntax file runs, unless the -i or --interactive option is given (see section 6.4 Language control options).

file1 file2

When two or more filenames are given on the command line, the first syntax file is executed, then PSPP's dictionary is cleared, then the second syntax file is executed.

file1 + file2

If syntax files' names are delimited by a plus sign (`+'), then the dictionary is not cleared between their executions, as if they were concatenated together into a single file.

key=value

Defines an output device macro key to expand to value, overriding any macro having the same key defined in the device configuration file. See section 5.5.2 Macro definitions.

There is one other way to specify a syntax file, if your operating system supports it. If you have a syntax file `foobar.stat', put the notation

 
#! /usr/local/bin/pspp

at the top, and mark the file as executable with chmod +x foobar.stat. (If PSPP is not installed in `/usr/local/bin', then insert its actual installation directory into the syntax file instead.) Now you should be able to invoke the syntax file just by typing its name. You can include any options on the command line as usual. PSPP entirely ignores any lines beginning with `#!'.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 Configuration Options

Configuration options are used to change PSPP's configuration for the current run. The configuration options are:

-B dir
--config-dir=dir

Sets the configuration directory to dir. See section 5.1 Locating configuration files.

-o device
--device=device

Selects the output device with name device. If this option is given more than once, then all devices mentioned are selected. This option disables all devices besides those mentioned on the command line.

-d var[=value]
--define=var[=value]

Defines an `environment variable' named var having the optional value value specified. See section 5.4.1 Values of environment variables.

-u var
--undef=var

Undefines the `environment variable' named var. See section 5.4.1 Values of environment variables.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3 Input and output options

Input and output options affect how PSPP reads input and writes output. These are the input and output options:

-f file
--out-file=file

This overrides the output file name for devices designated as listing devices. If a file named file already exists, it is overwritten.

-p
--pipe

Allows PSPP to be used as a filter by causing the syntax file to be read from stdin and output to be written to stdout. Conflicts with the -f file and --file=file options.

-I-
--no-include

Clears all directories from the include path. This includes all directories put in the include path by default. See section 5.9 Miscellaneous configuration.

-I dir
--include=dir

Appends directory dir to the path that is searched for include files in PSPP syntax files.

-c command
--command=command

Execute literal command command. The command is executed before startup syntax files, if any.

--testing-mode

Invoke heuristics to assist with testing PSPP. For use by make check and similar scripts.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4 Language control options

Language control options control how PSPP syntax files are parsed and interpreted. The available language control options are:

-i
--interactive

When a syntax file is specified on the command line, PSPP normally terminates after processing it. Giving this option will cause PSPP to bring up a command prompt after processing the syntax file.

In addition, this forces syntax files to be interpreted in interactive mode, rather than the default batch mode. See section 5.5.7 How lines are divided into tokens, for information on the differences between batch mode and interactive mode command interpretation.

-n
--edit
--dry-run
--just-print
--recon

Only the syntax of any syntax file specified or of commands entered at the command line is checked. Transformations are not performed and procedures are not executed. Not yet implemented.

-r
--no-statrc

Prevents the execution of the PSPP startup syntax file. Not yet implemented, as startup syntax files aren't, either.

-s
--safer

Disables certain unsafe operations. This includes the ERASE and HOST commands, as well as use of pipes as input and output files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5 Informational options

Informational options cause information about PSPP to be written to the terminal. Here are the available options:

-h
--help

Prints a message describing PSPP command-line syntax and the available device driver classes, then terminates.

-l
--list

Lists the available device driver classes, then terminates.

-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 terminates.

-v
--verbose

Increments PSPP's verbosity level. Higher verbosity levels cause PSPP to display greater amounts of information about what it is doing. Often useful for debugging PSPP's configuration.

This option can be given multiple times to set the verbosity level to that value. The default verbosity level is 0, in which no informational messages will be displayed.

Higher verbosity levels cause messages to be displayed when the corresponding events take place.

1

Driver and subsystem initializations.

2

Completion of driver initializations. Beginning of driver closings.

3

Completion of driver closings.

4

Files searched for; success of searches.

5

Individual directories included in file searches.

Each verbosity level also includes messages from lower verbosity levels.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. The PSPP language

Please note: PSPP is not even close to completion. Only a few actual statistical procedures are implemented. PSPP is a work in progress.

This chapter discusses elements common to many PSPP commands. Later chapters will describe individual commands in detail.

7.1 Tokens  Characters combine to form tokens.
7.2 Forming commands of tokens  Tokens combine to form commands.
7.3 Types of Commands  Commands come in several flavors.
7.4 Order of Commands  Commands combine to form syntax files.
7.5 Handling missing observations  
7.6 Variables  The unit of data storage.
7.7 Files Used by PSPP  Files used by PSPP.
7.8 Backus-Naur Form  How command syntax is described.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 Tokens

PSPP divides most syntax file lines into series of short chunks called tokens, lexical elements, or lexemes. These 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. The process of dividing input into tokens is tokenization, or lexical analysis. Each type of token is described below.

Tokens must be separated from each other by delimiters. Delimiters include whitespace (spaces, tabs, carriage returns, line feeds, vertical tabs), punctuation (commas, forward slashes, etc.), and operators (plus, minus, times, divide, etc.) Note that while whitespace only separates tokens, other delimiters are tokens in themselves.

Identifiers
Identifiers are names that specify variable names, commands, or command details.

Caution: It is legal to end a variable name with a period, but don't do it! The variable name will be misinterpreted when it is the final token on a line: FOO. will be divided into two separate tokens, `FOO' and `.', the terminal dot. See section Forming commands of tokens.

Numbers
Numbers may be specified as integers or reals. Integers are internally converted into reals. Scientific notation is not supported. Here are some examples of valid numbers:

 
1234  3.14159265359  .707106781185  8945.

Caution: The last example will be interpreted as two tokens, `8945' and `.', if it is the last token on a line.

Strings
Strings are literal sequences of characters enclosed in pairs of single quotes (`'') or double quotes (`"').

Hexstrings
Hexstrings are string variants that use hex digits to specify characters.

Punctuation
Punctuation separates tokens; punctuators are delimiters. These are the punctuation characters:

 
,  /  =  (  )

Operators
Operators describe mathematical operations. Some operators are delimiters:

 
(  )  +  -  *  /  **

Many of the above operators are also punctuators. Punctuators are distinguished from operators by context.

The other operators are all reserved keywords. None of these are delimiters:

 
AND  EQ  GE  GT  LE  LT  NE  OR

Terminal Dot
A period (`.') at the end of a line (except for whitespace) is one type of a terminal dot, although not every terminal dot is a period at the end of a line. See section Forming commands of tokens. A period is a terminal dot only when it is at the end of a line; otherwise it is part of a floating-point number. (A period outside a number in the middle of a line is an error.)

Please note: The character used for the terminal dot can be changed with the SET command. This is strongly discouraged, and throughout all the remainder of this manual it will be assumed that the default setting is in effect.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 Forming commands of tokens

Most PSPP commands share a common structure, diagrammed below:

 
cmd... [sbc[=][spec [[,]spec]...]] [[/[=][spec [[,]spec]...]]...].

In the above, rather daunting, expression, pairs of square brackets (`[ ]') indicate optional elements, and names such as cmd indicate parts of the syntax that vary from command to command. Ellipses (`...') indicate that the preceding part may be repeated an arbitrary number of times. Let's pick apart what it says above:

PSPP ignores empty commands when they are generated by the above rules. Note that, as a consequence of these rules, each command must begin on a new line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 Types of Commands

Commands in PSPP are divided roughly into six categories:

Utility commands
Set or display various global options that affect PSPP operations. May appear anywhere in a syntax file. See section Utility commands.

File definition commands
Give instructions for reading data from text files or from special binary "system files". Most of these commands discard any previous data or variables in order to replace it with the new data and variables. At least one must appear before the first command in any of the categories below. See section 9. Data Input and Output.

Input program commands
Though rarely used, these provide powerful tools for reading data files in arbitrary textual or binary formats. See section 9.7 INPUT PROGRAM.

Transformations
Perform operations on data and write data to output files. Transformations are not carried out until a procedure is executed.

Restricted transformations
Same as transformations for most purposes. See section 7.4 Order of Commands, for a detailed description of the differences.

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 file (the data) to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.4 Order of Commands

PSPP does not place many restrictions on ordering of commands. The main restriction is that variables must be defined with one of the file-definition commands before they are otherwise referred to.

Of course, there are specific rules, for those who are interested. PSPP possesses five internal states, called initial, INPUT PROGRAM, FILE TYPE, transformation, and procedure states. (Please note the distinction between the INPUT PROGRAM and FILE TYPE commands and the INPUT PROGRAM and FILE TYPE states.)

PSPP starts up in the initial state. Each successful completion of a command may cause a state transition. Each type of command has its own rules for state transitions:

Utility commands

DATA LIST

INPUT PROGRAM

FILE TYPE

Other file definition commands

Transformations

Restricted transformations

Procedures


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.5 Handling missing observations

PSPP includes special support for unknown numeric data values. Missing observations are assigned a special value, called the system-missing value. This "value" actually indicates the absence of value; it means that the actual value is unknown. Procedures automatically exclude from analyses those observations or cases that have missing values. Whether single observations or entire cases are excluded depends on the procedure.

The system-missing value exists only for numeric variables. String variables always have a defined value, even if it is only a string of spaces.

Variables, whether numeric or string, can have designated user-missing values. Every user-missing value is an actual value for that variable. However, most of the time user-missing values are treated in the same way as the system-missing value. String variables that are wider than a certain width, usually 8 characters (depending on computer architecture), cannot have user-missing values.

For more information on missing values, see the following sections: 7.6 Variables, 11.6 MISSING VALUES, 8. Mathematical Expressions. See also the documentation on individual procedures for information on how they handle missing values.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6 Variables

Variables are the basic unit of data storage in PSPP. All the variables in a file taken together, apart from any associated data, are said to form a dictionary. Each case contain a value for each variable. Some details of variables are described in the sections below.

7.6.1 Attributes of Variables  Attributes of variables.
7.6.2 Variables Automatically Defined by PSPP  Variables automatically defined by PSPP.
7.6.3 Lists of variable names  
7.6.4 Input and Output Formats  Input and output formats.
7.6.5 Scratch Variables  Variables deleted by procedures.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.1 Attributes of Variables

Each variable has a number of attributes, including:

Name
This is an identifier. Each variable must have a different name. See section 7.1 Tokens.

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 can be used in many procedures where long string variables (those with widths greater than 8) are not allowed.

Please note: Certain systems may consider strings longer than 8 characters to be short strings. Eight characters represents a minimum figure for the maximum length of a short string.

Position
Variables in the dictionary are arranged in a specific order. The DISPLAY command can be used to show this order: see 11.2 DISPLAY.

Orientation
Dexter or sinister. See section 11.5 LEAVE.

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 7.5 Handling missing observations.

Variable label
A string that describes the variable. See section 11.13 VARIABLE LABELS.

Value label
Optionally, these associate each possible value of the variable with a string. See section 11.11 VALUE LABELS.

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 11.9 PRINT FORMATS.

Write format
Similar to print format, but used by certain commands that are designed to write to binary files. See section 11.15 WRITE FORMATS.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.2 Variables Automatically Defined by PSPP

There are seven system variables. These are not like ordinary variables, as they are not stored in each case. They can only be used in expressions. These system variables, whose values and output formats cannot be modified, are described below.

$CASENUM
Case number of the case at the moment. This changes as cases are shuffled around.

$DATE
Date the PSPP process was started, in format A9, following the pattern DD MMM YY.

$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 file was read, in format F20.

$WIDTH
Page width, in characters, in format F3.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.3 Lists of variable names

There are several ways to specify a set of variables:

  1. (Most commonly.) List the variable names one after another, optionally separating them by commas.

  2. (This method cannot be used on commands that define the dictionary, such as DATA LIST.) The syntax is the names of two existed variables, separated by the reserved keyword TO. The meaning is to include every variable in the dictionary between and including the variables specified. For instance, if the dictionary contains six variables with the names ID, X1, X2, GOAL, MET, and NEXTGOAL, in that order, then X2 TO MET would include variables X2, GOAL, and MET.

  3. (This method can be used only on commands that define the dictionary, such as DATA LIST.) It is used to define sequences of variables that end in consecutive integers. The syntax is two identifiers that end in numbers. This method is best illustrated with examples:

    Note that after a set of variables has been defined on DATA LIST or another command with this method, the same set can be referenced on later commands using the same syntax.

  4. The above methods can be combined, either one after another or delimited by commas. For instance, the combined syntax A Q5 TO Q8 X TO Z is legal as long as each part A, Q5 TO Q8, X TO Z is individually legal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.4 Input and Output Formats

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

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

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

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

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

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

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

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

COMMAw.d: 1 <= iw,ow <= 40
Equivalent to F format, except that groups of three digits are comma-separated on output. If the number is too large to express in the field width, then first commas are eliminated, then if there is still not enough space the number is expressed in scientific notation given that w >= 6. Commas are allowed and ignored when this is used as an input format.

DOTw.d: 1 <= iw,ow <= 40
Equivalent to COMMA format except that the roles of comma and decimal point are interchanged. However: If SET /DECIMAL=DOT is in effect, then COMMA uses `,' for a decimal point and DOT uses `.' for a decimal point.

DOLLARw.d: 1 <= iw <= 40; 2 <= ow <= 40
Equivalent to COMMA format, except that the number is prefixed by a dollar sign (`$') if there is room. On input the value is allowed to be prefixed by a dollar sign, which is ignored.

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

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

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

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

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

Zw.d => F: 1 <= iw,ow <= 40
Zoned decimal input. If you need to use this then you know how.

IBw.d => F: 1 <= iw,ow <= 8
Integer binary format. The field is interpreted as a fixed-point positive or negative binary number in two's-complement notation. The location of the decimal point is implied. Endianness is the same as the host machine.

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

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

The default output format follows the rules for IB format.

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

The default output format follows the rules for IB format.

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

The default output format follows the rules for IB format.

RBw => F: 2 <= iw,ow <= 8

Binary C architecture-dependent "double" format. For a standard IEEE754 implementation w should be 8.

The default output format follows the rules for IB format.

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

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

RBHEXw => F: 4 <= iw,ow <= 16

RB format encoded as textual hex digits pairs. w must be even.

The default output format is F8.2.

CCAw.d: 1 <= ow <= 40
CCBw.d: 1 <= ow <= 40
CCCw.d: 1 <= ow <= 40
CCDw.d: 1 <= ow <= 40
CCEw.d: 1 <= ow <= 40

User-defined custom currency formats. May not be used as an input format. See section 16.10 SET, for more details.

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

leader
All formats accept an optional whitespace leader.

day
An integer between 1 and 31 representing the day of month.

day-count
An integer representing a number of days.

date-delimiter
One or more characters of whitespace or the following characters: - / . ,

month
A month name in one of the following forms:

year
An integer year number between 1582 and 19999, or between 1 and 199. Years between 1 and 199 will have 1900 added.

julian
A single number with a year number in the first 2, 3, or 4 digits (as above) and the day number within the year in the last 3 digits.

quarter
An integer between 1 and 4 representing a quarter.

q-delimiter
The letter `Q' or `q'.

week
An integer between 1 and 53 representing a week within a year.

wk-delimiter
The letters `wk' in any case.

time-delimiter
At least one characters of whitespace or `:' or `.'.

hour
An integer greater than 0 representing an hour.

minute
An integer between 0 and 59 representing a minute within an hour.

opt-second
Optionally, a time-delimiter followed by a real number representing a number of seconds.

hour24
An integer between 0 and 23 representing an hour within a day.

weekday
At least the first two characters of an English day word.

spaces
Any amount or no amount of whitespace.

sign
An optional positive or negative sign.

trailer
All formats accept an optional whitespace trailer.

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

DATEw: 9 <= iw,ow <= 40
Date format. Input format: leader + day + date-delimiter + month + date-delimiter + year + trailer. Output format: DD-MMM-YY for w < 11, DD-MMM-YYYY otherwise.

EDATEw: 8 <= iw,ow <= 40
European date format. Input format same as DATE. Output format: DD.MM.YY for w < 10, DD.MM.YYYY otherwise.

SDATEw: 8 <= iw,ow <= 40
Standard date format. Input format: leader + year + date-delimiter + month + date-delimiter + day + trailer. Output format: YY/MM/DD for w < 10, YYYY/MM/DD otherwise.

ADATEw: 8 <= iw,ow <= 40
American date format. Input format: leader + month + date-delimiter + day + date-delimiter + year + trailer. Output format: MM/DD/YY for w < 10, MM/DD/YYYY otherwise.

JDATEw: 5 <= iw,ow <= 40
Julian date format. Input format: leader + julian + trailer. Output format: YYDDD for w < 7, YYYYDDD otherwise.

QYRw: 4 <= iw <= 40, 6 <= ow <= 40
Quarter/year format. Input format: leader + quarter + q-delimiter + year + trailer. Output format: `Q Q YY', where the first `Q' is one of the digits 1, 2, 3, 4, if w < 8, Q Q YYYY otherwise.

MOYRw: 6 <= iw,ow <= 40
Month/year format. Input format: leader + month + date-delimiter + year + trailer. Output format: `MMM YY' for w < 8, `MMM YYYY' otherwise.

WKYRw: 6 <= iw <= 40, 8 <= ow <= 40
Week/year format. Input format: leader + week + wk-delimiter + year + trailer. Output format: `WW WK YY' for w < 10, `WW WK YYYY' otherwise.

DATETIMEw.d: 17 <= iw,ow <= 40
Date and time format. Input format: leader + day + date-delimiter + month + date-delimiter + yaer + time-delimiter + hour24 + time-delimiter + minute + opt-second. Output format: `DD-MMM-YYYY HH:MM'. If w > 19 then seconds `:SS' is added. If w > 22 and d > 0 then fractional seconds `.SS' are added.

TIMEw.d: 5 <= iw,ow <= 40
Time format. Input format: leader + sign + spaces + hour + time-delimiter + minute + opt-second. Output format: `HH:MM'. Seconds and fractional seconds are available with w of at least 8 and 10, respectively.

DTIMEw.d: 1 <= iw <= 40, 8 <= ow <= 40
Time format with day count. Input format: leader + sign + spaces + day-count + time-delimiter + hour + time-delimiter + minute + opt-second. Output format: `DD HH:MM'. Seconds and fractional seconds are available with w of at least 8 and 10, respectively.

WKDAYw: 2 <= iw,ow <= 40
A weekday as a number between 1 and 7, where 1 is Sunday. Input format: leader + weekday + trailer. Output format: as many characters, in all capital letters, of the English name of the weekday as will fit in the field width.

MONTHw: 3 <= iw,ow <= 40
A month as a number between 1 and 12, where 1 is January. Input format: leader + month + trailer. Output format: as many character, in all capital letters, of the English name of the month as will fit in the field width.

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

Aw: 1 <= iw <= 255, 1 <= ow <= 254
The entire field is treated as a string value.

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

The default output w is half the input w.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.5 Scratch Variables

Most of the time, variables don't retain their values between cases. Instead, either they're being read from a data file or the active file, in which case they assume the value read, or, if created with COMPUTE or another transformation, they're initialized to the system-missing value or to blanks, depending on type.

However, sometimes it's useful to have a variable that keeps its value between cases. You can do this with LEAVE (see section 11.5 LEAVE), or you can use a scratch variable. Scratch variables are variables whose names begin with an octothorpe (`#').

Scratch variables have the same properties as variables left with LEAVE: they retain their values between cases, and for the first case they are initialized to 0 or blanks. They have the additional property that they are deleted before the execution of any procedure. For this reason, scratch variables can't be used for analysis. To obtain the same effect, use COMPUTE (see section 12.3 COMPUTE) to copy the scratch variable's value into an ordinary variable, then analysis that variable.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7 Files Used by PSPP

PSPP makes use of many files each time it runs. Some of these it reads, some it writes, some it creates. Here is a table listing the most important of these files:

command file
syntax file
These names (synonyms) refer to the file that contains instructions to PSPP that tell it what to do. The syntax file's name is specified on the PSPP command line. Syntax files can also be pulled in with the INCLUDE command.

data file
Data files contain raw data in ASCII format suitable for being read in by the DATA LIST command. Data can be embedded in the syntax file with BEGIN DATA and END DATA commands: this makes the syntax file a data file too.

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.

active file
The active file is the "file" on which all PSPP procedures are performed. The active file contains variable definitions and cases. The active file is not necessarily a disk file: it is stored in memory if there is room.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8 Backus-Naur Form

The syntax of some parts of the PSPP language is presented in this manual using the formalism known as Backus-Naur Form, or BNF. The following table describes BNF:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8. Mathematical Expressions

Some PSPP commands use expressions, which share a common syntax among all 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 arguments as input and produces or returns exactly one result as output. Both strings and numeric values can be used as arguments and are produced as results, but each operator accepts only specific combinations of numeric and string values as arguments. With few exceptions, operator arguments may be full-fledged expressions in themselves.

8.1 Boolean values  
8.2 Missing Values in Expressions  Using missing values in expressions.
8.3 Grouping Operators  ( )
8.4 Arithmetic Operators  + - * / **
8.5 Logical Operators  AND NOT OR
8.6 Relational Operators  EQ GE GT LE LT NE
8.7 Functions  More-sophisticated operators.
8.8 Operator Precedence  Operator precedence.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Boolean values

There is a third type for arguments and results, the Boolean type, which is used to represent true/false conditions. Booleans have only three possible values: 0 (false), 1 (true), and system-missing. System-missing is neither true or false.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 Missing Values in Expressions

String missing values are not treated specially in expressions. Most numeric operators return system-missing when given system-missing arguments. Exceptions are listed under particular operator descriptions.

User-missing values for numeric variables are always transformed into the system-missing value, except inside the arguments to the VALUE, SYSMIS, and MISSING functions.

The missing-value functions can be used to precisely control how missing values are treated in expressions. See section 8.7.4 Missing-Value Functions, for more details.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.3 Grouping Operators

Parentheses (`()') are the grouping operators. Surround an expression with parentheses to force early evaluation.

Parentheses also surround the arguments to functions, but in that situation they act as punctuators, not as operators.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4 Arithmetic Operators

The arithmetic operators take numeric arguments and produce numeric results.

a + b
Adds a and b, returning the sum.

a - b
Subtracts b from a, returning the difference.

a * b
Multiplies a and b, returning the product.

a / b
Divides a by b, returning the quotient. If b is zero, the result is system-missing.

a ** b
Returns 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5 Logical Operators

The logical operators take logical arguments and produce logical results, meaning "true or false". PSPP logical operators are not true Boolean operators because they may also result in a system-missing value.

a AND b
a & b
True if both a and b are true. However, if one argument is false and the other is missing, the result is false, not missing. If both arguments are missing, the result is missing.

a OR b
a | b
True if at least one of a and b is true. If one argument is true and the other is missing, the result is true, not missing. If both arguments are missing, the result is missing.

NOT a
~ a
True if a is false.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6 Relational Operators

The relational operators take numeric or string arguments and produce Boolean results.

Note that, with numeric arguments, PSPP does not make exact relational tests. Instead, two numbers are considered to be equal even if they differ by a small amount. This amount, epsilon, is dependent on the PSPP configuration and determined at compile time. (The default value is 0.000000001, or 10**(-9).) Use of epsilon allows for round-off errors. Use of epsilon is also idiotic, but the author is not a numeric analyst.

Strings cannot be compared to numbers. When strings of different lengths are compared, the shorter string is right-padded with spaces to match the length of the longer string.

The results of string comparisons, other than tests for equality or inequality, are dependent on the character set in use. String comparisons are case-sensitive.

a EQ b
a = b
True if a is equal to b.

a LE b
a <= b
True if a is less than or equal to b.

a LT b
a < b
True if a is less than b.

a GE b
a >= b
True if a is greater than or equal to b.

a GT b
a > b
True if a is greater than b.

a NE b
a ~= b
a <> b
True is a is not equal to b.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.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: EXP(10) refers to the constant value e raised to the 10th power, but EXP by itself refers to the value of variable EXP.

The sections below describe each function in detail.

8.7.1 Advanced Mathematical Functions  EXP LG10 LN SQRT
8.7.2 Miscellaneous Mathematical Functions  ABS MOD MOD10 RND TRUNC
8.7.3 Trigonometric Functions  ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
8.7.4 Missing-Value Functions  MISSING NMISS NVALID SYSMIS VALUE
8.7.5 Pseudo-Random Number Generation Functions  NORMAL UNIFORM
8.7.6 Set-Membership Functions  ANY RANGE
8.7.7 Statistical Functions  CFVAR MAX MEAN MIN SD SUM VARIANCE
8.7.8 String Functions  CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER RINDEX RPAD RTRIM STRING SUBSTR UPCASE
8.7.9 Time & Date Functions  CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
8.7.10 Miscellaneous Functions  LAG YRMODA
8.7.11 Functions Not Implemented  CDF.xxx CDFNORM IDF.xxx NCDF.xxx PROBIT RV.xxx


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.1 Advanced Mathematical Functions

Advanced mathematical functions take numeric arguments and produce numeric results.

Function: EXP (exponent)
Returns e (approximately 2.71828) raised to power exponent.

Function: LG10 (number)
Takes the base-10 logarithm of number. If number is not positive, the result is system-missing.

Function: LN (number)
Takes the base-`e' logarithm of number. If number is not positive, the result is system-missing.

Function: SQRT (number)
Takes the square root of number. If number is negative, the result is system-missing.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.2 Miscellaneous Mathematical Functions

Miscellaneous mathematical functions take numeric arguments and produce numeric results.

Function: ABS (number)
Results in the absolute value of number.

Function: MOD (numerator, denominator)
Returns the remainder (modulus) of numerator divided by denominator. If denominator is 0, the result is system-missing. However, if numerator is 0 and denominator is system-missing, the result is 0.

Function: MOD10 (number)
Returns the remainder when number is divided by 10. If number is negative, MOD10(number) is negative or zero.

Function: RND (number)
Takes the absolute value of number and rounds it to an integer. Then, if number was negative originally, negates the result.

Function: TRUNC (number)
Discards the fractional part of number; that is, rounds number towards zero.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.3 Trigonometric Functions

Trigonometric functions take numeric arguments and produce numeric results.

Function: ACOS (number)
Function: ARCOS (number)
Takes the arccosine, in radians, of number. Results in system-missing if number is not between -1 and 1. Portability: none.

Function: ARSIN (number)
Takes the arcsine, in radians, of number. Results in system-missing if number is not between -1 and 1 inclusive.

Function: ARTAN (number)
Takes the arctangent, in radians, of number.

Function: ASIN (number)
Takes the arcsine, in radians, of number. Results in system-missing if number is not between -1 and 1 inclusive. Portability: none.

Function: ATAN (number)
Takes the arctangent, in radians, of number.

Please note: Use of the AR* group of inverse trigonometric functions is recommended over the A* group because they are more portable.

Function: COS (radians)
Takes the cosine of radians.

Function: SIN (angle)
Takes the sine of radians.

Function: TAN (angle)
Takes the tangent of radians. Results in system-missing at values of angle that are too close to odd multiples of pi/2. Portability: none.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.4 Missing-Value Functions

Missing-value functions take various types as arguments, returning various types of results.

Function: MISSING (variable or expression)
num may be a single variable name or an expression. If it is a variable name, results in 1 if the variable has a user-missing or system-missing value for the current case, 0 otherwise. If it is an expression, results in 1 if the expression has the system-missing value, 0 otherwise.

Please note: If the argument is a string expression other than a variable name, MISSING is guaranteed to return 0, because strings do not have a system-missing value. Also, when using a numeric expression argument, remember that user-missing values are converted to the system-missing value in most contexts. Thus, the expressions MISSING(VAR1 op VAR2) and MISSING(VAR1) OR MISSING(VAR2) are often equivalent, depending on the specific operator op used.

Function: NMISS (expr [, expr]...)
Each argument must be a numeric expression. Returns the number of user- or system-missing values in the list. As a special extension, the syntax var1 TO var2 may be used to refer to a range of variables; see 7.6.3 Lists of variable names, for more details.

Function: NVALID (expr [, expr]...)
Each argument must be a numeric expression. Returns the number of values in the list that are not user- or system-missing. As a special extension, the syntax var1 TO var2 may be used to refer to a range of variables; see 7.6.3 Lists of variable names, for more details.

Function: SYSMIS (variable or expression)
When given the name of a numeric variable, returns 1 if the value of that variable is system-missing. Otherwise, if the value is not missing or if it is user-missing, returns 0. If given the name of a string variable, always returns 1. If given an expression other than a single variable name, results in 1 if the value is system- or user-missing, 0 otherwise.

Function: VALUE (variable)
Prevents the user-missing values of variable from being transformed into system-missing values: If variable is not system- or user-missing, results in the value of variable. If variable is user-missing, results in the value of variable anyway. If variable is system-missing, results in system-missing.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.5 Pseudo-Random Number Generation Functions

Pseudo-random number generation functions take numeric arguments and produce numeric results.

The system's C library random generator is used as a basis for generating random numbers, since random number generation is a system-dependent task. However, Knuth's Algorithm B is used to shuffle the resultant values, which is enough to make even a stream of consecutive integers random enough for most applications.

(If you're worried about the quality of the random number generator, well, you're using a statistical processing package--analyze it!)

Function: NORMAL (number)
Results in a random number. Results from NORMAL are normally distributed with a mean of 0 and a standard deviation of number.

Function: UNIFORM (number)
Results in a random number between 0 and number. Results from UNIFORM are evenly distributed across its entire range. There may be a maximum on the largest random number ever generated--this is often 2**31-1 (2,147,483,647), but it may be orders of magnitude higher or lower.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.6 Set-Membership Functions

Set membership functions determine whether a value is a member of a set. They take a set of numeric arguments or a set of string arguments, and produce Boolean results.

String comparisons are performed according to the rules given in 8.6 Relational Operators.

Function: ANY (value, set [, set]...)
Results in true if value is equal to any of the set values. Otherwise, results in false. If value is system-missing, returns system-missing. System-missing values in set do not cause ANY to return system-missing.

Function: RANGE (value, low, high [, low, high]...)
Results in true if value is in any of the intervals bounded by low and high inclusive. Otherwise, results in false. Each low must be less than or equal to its corresponding high value. low and high must be given in pairs. If value is system-missing, returns system-missing. System-missing values in set do not cause RANGE to return system-missing.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.7 Statistical Functions

Statistical functions compute descriptive statistics on a list of values. Some statistics can be computed on numeric or string values; other can only be computed on numeric values. They result in the same type as their arguments.

With statistical functions it is possible to specify a minimum number of non-missing arguments for the function to be evaluated. To do so, append a dot and the number to the function name. For instance, to specify a minimum of three valid arguments to the MEAN function, use the name MEAN.3.

Function: CFVAR (number, number[, ...])
Results in the coefficient of variation of the values of number. This function requires at least two valid arguments to give a non-missing result. (The coefficient of variation is the standard deviation divided by the mean.)

Function: MAX (value, value[, ...])
Results in the value of the greatest value. The values may be numeric or string. Although at least two arguments must be given, only one need be valid for MAX to give a non-missing result.

Function: MEAN (number, number[, ...])
Results in the mean of the values of number. Although at least two arguments must be given, only one need be valid for MEAN to give a non-missing result.

Function: MIN (number, number[, ...])
Results in the value of the least value. The values may be numeric or string. Although at least two arguments must be given, only one need be valid for MAX to give a non-missing result.

Function: SD (number, number[, ...])
Results in the standard deviation of the values of number. This function requires at least two valid arguments to give a non-missing result.

Function: SUM (number, number[, ...])
Results in the sum of the values of number. Although at least two arguments must be given, only one need by valid for SUM to give a non-missing result.

Function: VAR (number, number[, ...])
Results in the variance of the values of number. This function requires at least two valid arguments to give a non-missing result.

Function: VARIANCE (number, number[, ...])
Results in the variance of the values of number. This function requires at least two valid arguments to give a non-missing result. (Use VAR in preference to VARIANCE for reasons of portability.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.8 String Functions

String functions take various arguments and return various results.

Function: CONCAT (string, string[, ...])
Returns a string consisting of each string in sequence. CONCAT("abc", "def", "ghi") has a value of "abcdefghi". The resultant string is truncated to a maximum of 255 characters.

Function: INDEX (haystack, needle)
Returns a positive integer indicating the position of the first occurrence needle in haystack. Returns 0 if haystack does not contain needle. Returns system-missing if needle is an empty string.

Function: INDEX (haystack, needle, divisor)
Divides needle into parts, each with length divisor. Searches haystack for the first occurrence of each part, and returns the smallest value. Returns 0 if haystack does not contain any part in needle. It is an error if divisor cannot be evenly divided into the length of needle. Returns system-missing if needle is an empty string.

Function: LENGTH (string)
Returns the number of characters in string.

Function: LOWER (string)
Returns a string identical to string except that all uppercase letters are changed to lowercase letters. The definitions of "uppercase" and "lowercase" are system-dependent.

Function: LPAD (string, length)
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with spaces on the left side to length length. Returns an empty string if length is system-missing, negative, or greater than 255.

Function: LPAD (string, length, padding)
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with padding on the left side to length length. Returns an empty string if length is system-missing, negative, or greater than 255, or if padding does not contain exactly one character.

Function: LTRIM (string)
Returns string, after removing leading spaces. Other whitespace, such as tabs, carriage returns, line feeds, and vertical tabs, is not removed.

Function: LTRIM (string, padding)
Returns string, after removing leading padding characters. If padding does not contain exactly one character, returns an empty string.

Function: NUMBER (string)
Returns the number produced when string is interpreted according to format Fx.0, where x is the number of characters in string. If string does not form a proper number, system-missing is returned without an error message. Portability: none.

Function: NUMBER (string, format)
Returns the number produced when string is interpreted according to format specifier format. Only the number of characters in string specified by format are examined. For example, NUMBER("123", F3.0) and NUMBER("1234", F3.0) both have value 123. If string does not form a proper number, system-missing is returned without an error message.

Function: RINDEX (string, format)
Returns a positive integer indicating the position of the last occurrence of needle in haystack. Returns 0 if haystack does not contain needle. Returns system-missing if needle is an empty string.

Function: RINDEX (haystack, needle, divisor)
Divides needle into parts, each with length divisor. Searches haystack for the last occurrence of each part, and returns the largest value. Returns 0 if haystack does not contain any part in needle. It is an error if divisor cannot be evenly divided into the length of needle. Returns system-missing if needle is an empty string.

Function: RPAD (string, length)
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with spaces on the right to length length. Returns an empty string if length is system-missing, negative, or greater than 255.

Function: RPAD (string, length, padding)
If string is at least length characters in length, returns string unchanged. Otherwise, returns string padded with padding on the right to length length. Returns an empty string if length is system-missing, negative, or greater than 255, or if padding does not contain exactly one character.

Function: RTRIM (string)
Returns string, after removing trailing spaces. Other types of whitespace are not removed.

Function: RTRIM (string, padding)
Returns string, after removing trailing padding characters. If padding does not contain exactly one character, returns an empty string.

Function: STRING (number, format)
Returns a string corresponding to number in the format given by format specifier format. For example, STRING(123.56, F5.1) has the value "123.6".

Function: SUBSTR (string, start)
Returns a string consisting of the value of string from position start onward. Returns an empty string if start is system-missing or has a value less than 1 or greater than the number of characters in string.

Function: SUBSTR (string, start, count)
Returns a string consisting of the first count characters from string beginning at position start. Returns an empty string if start or count is system-missing, if start is less than 1 or greater than the number of characters in string, or if count is less than 1. Returns a string shorter than count characters if start + count - 1 is greater than the number of characters in string. Examples: SUBSTR("abcdefg", 3, 2) has value "cd"; SUBSTR("Ben Pfaff", 5, 10) has the value "Pfaff".

Function: UPCASE (string)
Returns string, changing lowercase letters to uppercase letters.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9 Time & Date Functions

The legal range of dates for use in PSPP is 15 Oct 1582 through 31 Dec 19999.

Please note: Most time & date extraction functions will accept invalid arguments:

However, sensible results are not guaranteed for these invalid values. The given equivalents for these functions are definitely not guaranteed for invalid values.

Please note also: The time & date construction functions do produce reasonable and useful results for out-of-range values; these are not considered invalid.

8.7.9.1 How times & dates are defined and represented  
8.7.9.2 Functions that Produce Times  TIME.{DAYS HMS}
8.7.9.3 Functions that Examine Times  CTIME.{DAYS HOURS MINUTES SECONDS}
8.7.9.4 Functions that Produce Dates  DATE.{DMY MDY MOYR QYR WKYR YRDAY}
8.7.9.5 Functions that Examine Dates  XDATE.{DATE HOUR JDAY MDAY MINUTE MONTH QUARTER SECOND TDAY TIME WEEK WKDAY YEAR}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9.1 How times & dates are defined and represented

Times and dates are handled by PSPP as single numbers. A time is an interval. PSPP measures times in seconds. Thus, the following intervals correspond with the numeric values given:

 
          10 minutes                        600
          1 hour                          3,600
          1 day, 3 hours, 10 seconds     97,210
          40 days                     3,456,000
          10010 d, 14 min, 24 s     864,864,864

A date, on the other hand, is a particular instant in the past or the future. PSPP represents a date as a number of seconds after the midnight that separated 8 Oct 1582 and 9 Oct 1582. (Please note that 15 Oct 1582 immediately followed 9 Oct 1582.) Thus, the midnights before the dates given below correspond with the numeric PSPP dates given:

 
              15 Oct 1582                86,400
               4 Jul 1776         6,113,318,400
               1 Jan 1900        10,010,390,400
               1 Oct 1978        12,495,427,200
              24 Aug 1995        13,028,601,600

Please note:

(Adding two dates does not produce a useful result.)

Since times and dates are merely numbers, the ordinary addition and subtraction operators are employed for these purposes.

Please note: Many dates and times have extremely large values--just look at the values above. Thus, it is not a good idea to take powers of these values; also, the accuracy of some procedures may be affected. If necessary, convert times or dates in seconds to some other unit, like days or years, before performing analysis.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9.2 Functions that Produce Times

These functions take numeric arguments and produce numeric results in PSPP time format.

Function: TIME.DAYS (ndays)
Results in a time value corresponding to ndays days. (TIME.DAYS(x) is equivalent to x * 60 * 60 * 24.)

Function: TIME.HMS (nhours, nmins, nsecs)
Results in a time value corresponding to nhours hours, nmins minutes, and nsecs seconds. (TIME.HMS(h, m, s) is equivalent to h*60*60 + m*60 + s.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9.3 Functions that Examine Times

These functions take numeric arguments in PSPP time format and give numeric results.

Function: CTIME.DAYS (time)
Results in the number of days and fractional days in time. (CTIME.DAYS(x) is equivalent to x/60/60/24.)

Function: CTIME.HOURS (time)
Results in the number of hours and fractional hours in time. (CTIME.HOURS(x) is equivalent to x/60/60.)

Function: CTIME.MINUTES (time)
Results in the number of minutes and fractional minutes in time. (CTIME.MINUTES(x) is equivalent to x/60.)

Function: CTIME.SECONDS (time)
Results in the number of seconds and fractional seconds in time. (CTIME.SECONDS does nothing; CTIME.SECONDS(x) is equivalent to x.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9.4 Functions that Produce Dates

These functions take numeric arguments and give numeric results in the PSPP date format. Arguments taken by these functions are:

day
Refers to a day of the month between 1 and 31.

month
Refers to a month of the year between 1 and 12.

quarter
Refers to a quarter of the year between 1 and 4. The quarters of the year begin on the first days of months 1, 4, 7, and 10.

week
Refers to a week of the year between 1 and 53.

yday
Refers to a day of the year between 1 and 366.

year
Refers to a year between 1582 and 19999.

If these functions' arguments are out-of-range, they are correctly normalized before conversion to date format. Non-integers are rounded toward zero.

Function: DATE.DMY (day, month, year)
Function: DATE.MDY (month, day, year)
Results in a date value corresponding to the midnight before day day of month month of year year.

Function: DATE.MOYR (month, year)
Results in a date value corresponding to the midnight before the first day of month month of year year.

Function: DATE.QYR (quarter, year)
Results in a date value corresponding to the midnight before the first day of quarter quarter of year year.

Function: DATE.WKYR (week, year)
Results in a date value corresponding to the midnight before the first day of week week of year year.

Function: DATE.YRDAY (year, yday)
Results in a date value corresponding to the midnight before day yday of year year.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.9.5 Functions that Examine Dates

These functions take numeric arguments in PSPP date or time format and give numeric results. These names are used for arguments:

date
A numeric value in PSPP date format.

time
A numeric value in PSPP time format.

time-or-date
A numeric value in PSPP time or date format.

Function: XDATE.DATE (time-or-date)
For a time, results in the time corresponding to the number of whole days date-or-time includes. For a date, results in the date corresponding to the latest midnight at or before date-or-time; that is, gives the date that date-or-time is in. (XDATE.DATE(x) is equivalent to TRUNC(x/86400)*86400.) Applying this function to a time is a Portability: none feature.

Function: XDATE.HOUR (time-or-date)
For a time, results in the number of whole hours beyond the number of whole days represented by date-or-time. For a date, results in the hour (as an integer between 0 and 23) corresponding to date-or-time. (XDATE.HOUR(x) is equivalent to MOD(TRUNC(x/3600),24)) Applying this function to a time is a Portability: none feature.

Function: XDATE.JDAY(date)
Results in the day of the year (as an integer between 1 and 366) corresponding to date.

Function: XDATE.MDAY(date)
Results in the day of the month (as an integer between 1 and 31) corresponding to date.

Function: XDATE.MINUTE(time-or-date)
Results in the number of minutes (as an integer between 0 and 59) after the last hour in time-or-date. (XDATE.MINUTE(x) is equivalent to MOD(TRUNC(x/60),60)) Applying this function to a time is a Portability: none feature.

Function: XDATE.MONTH(date)
Results in the month of the year (as an integer between 1 and 12) corresponding to date.

Function: XDATE.QUARTER(date)
Results in the quarter of the year (as an integer between 1 and 4) corresponding to date.

Function: XDATE.SECOND(time-or-date)
Results in the number of whole seconds after the last whole minute (as an integer between 0 and 59) in time-or-date. (XDATE.SECOND(x) is equivalent to MOD(x, 60).) Applying this function to a time is a Portability: none feature.

Function: XDATE.TDAY(time)
Results in the number of whole days (as an integer) in time. (XDATE.TDAY(x) is equivalent to TRUNC(x/86400).)

Function: XDATE.TIME(date)
Results in the time of day at the instant corresponding to date, in PSPP time format. This is the number of seconds since midnight on the day corresponding to date. (XDATE.TIME(x) is equivalent to TRUNC(x/86400)*86400.)

Function: XDATE.WEEK(date)
Results in the week of the year (as an integer between 1 and 53) corresponding to date.

Function: XDATE.WKDAY(date)
Results in the day of week (as an integer between 1 and 7) corresponding to date. The days of the week are:

1
Sunday
2
Monday
3
Tuesday
4
Wednesday
5
Thursday
6
Friday
7
Saturday

Function: XDATE.YEAR (date)
Returns the year (as an integer between 1582 and 19999) corresponding to date.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.10 Miscellaneous Functions

Miscellaneous functions take various arguments and produce various results.

Function: LAG (variable)
variable must be a numeric or string variable name. LAG results in the value of that variable for the case before the current one. In case-selection procedures, LAG results in the value of the variable for the last case selected. Results in system-missing (for numeric variables) or blanks (for string variables) for the first case or before any cases are selected.

Function: LAG (variable, ncases)
variable must be a numeric or string variable name. ncases must be a small positive constant integer, although there is no explicit limit. (Use of a large value for ncases will increase memory consumption, since PSPP must keep ncases cases in memory.) LAG (variable, ncases results in the value of variable that is ncases before the case currently being processed. See LAG (variable) above for more details.

Function: YRMODA (year, month, day)
year is a year between 0 and 199 or 1582 and 19999. month is a month between 1 and 12. day is a day between 1 and 31. If month or day is out-of-range, it changes the next higher unit. For instance, a day of 0 refers to the last day of the previous month, and a month of 13 refers to the first month of the next year. year must be in range. If year is between 0 and 199, 1900 is added. year, month, and day must all be integers.

YRMODA results in the number of days between 15 Oct 1582 and the date specified, plus one. The date passed to YRMODA must be on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.11 Functions Not Implemented

These functions are not yet implemented and thus not yet documented, since it's a hassle.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.8 Operator Precedence

The following table describes operator precedence. Smaller-numbered levels in the table have higher precedence. Within a level, operations are performed from left to right, except for level 2 (exponentiation), where operations are performed from right to left. If an operator appears in the table in two places (-), the first occurrence is unary, the second is binary.

  1. ( )
  2. **
  3. -
  4. * /
  5. + -
  6. EQ GE GT LE LT NE
  7. AND NOT OR


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9. Data Input and Output

Data is the focus of the PSPP language. This chapter examines the PSPP commands for defining variables and reading and writing data.

Please note: Data is not actually read until a procedure is executed. These commands tell PSPP how to read data, but they do not cause PSPP to read data.

9.1 BEGIN DATA  Embed data within a syntax file.
9.2 CLEAR TRANSFORMATIONS  Clear pending transformations.
9.3 DATA LIST  Fundamental data reading command.
9.4 END CASE  Output the current case.
9.5 END FILE  Terminate the current input program.
9.6 FILE HANDLE  Support for fixed-length records.
9.7 INPUT PROGRAM  Support for complex input programs.
9.8 LIST  List cases in the active file.
9.9 MATRIX DATA  Read matrices in text format.
9.10 NEW FILE  Clear the active file and dictionary.
9.11 PRINT  Display values in print formats.
9.12 PRINT EJECT  Eject the current page then print.
9.13 PRINT SPACE  Print blank lines.
9.14 REREAD  Take another look at the previous input line.
9.15 REPEATING DATA  Multiple cases on a single line.
9.16 WRITE  Display values in write formats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1 BEGIN DATA

 
BEGIN DATA.
...
END DATA.

BEGIN DATA and END DATA can be used to embed raw ASCII data in a PSPP syntax file. DATA LIST or another input procedure must be used before BEGIN DATA (see section 9.3 DATA LIST). BEGIN DATA and END DATA must be used together. The END DATA command must appear by itself on a single line, with no leading whitespace and exactly one space between the words END and DATA, followed immediately by the terminal dot, like this:

 
END DATA.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2 CLEAR TRANSFORMATIONS

 
CLEAR TRANSFORMATIONS.

The CLEAR TRANSFORMATIONS command clears out all pending transformations. It does not cancel the current input program. It is valid only when PSPP is interactive, not in syntax files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3 DATA LIST

Used to read text or binary data, DATA LIST is the most fundamental data-reading command. Even the more sophisticated input methods use DATA LIST commands as a building block. Understanding DATA LIST is important to understanding how to use PSPP to read your data files.

There are two major variants of DATA LIST, which are fixed format and free format. In addition, free format has a minor variant, list format, which is discussed in terms of its differences from vanilla free format.

Each form of DATA LIST is described in detail below.

9.3.1 DATA LIST FIXED  Fixed columnar locations for data.
9.3.2 DATA LIST FREE  Any spacing you like.
9.3.3 DATA LIST LIST  Each case must be on a single line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.1 DATA LIST FIXED

 
DATA LIST [FIXED]
        {TABLE,NOTABLE}
        FILE='filename'
        RECORDS=record_count
        END=end_var
        /[line_no] var_spec...

where each var_spec takes one of the forms
        var_list start-end [type_spec]
        var_list (fortran_spec)

DATA LIST FIXED is used to read data files that have values at fixed positions on each line of single-line or multiline records. The keyword FIXED is optional.

The FILE subcommand must be used if input is to be taken from an external file. It may be used to specify a filename as a string or a file handle (see section 9.6 FILE HANDLE). 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 9.1 BEGIN DATA).

The optional RECORDS subcommand, which takes a single integer as an argument, is used to specify the number of lines per record. If RECORDS is not specified, then the number of lines per record is calculated from the list of variable specifications later in the DATA LIST command.

The END subcommand is only useful in conjunction with the INPUT PROGRAM input procedure, and for that reason it is not discussed here (see section 9.7 INPUT PROGRAM).

DATA LIST can optionally output a table describing how the data file will be read. The TABLE subcommand enables this output, and NOTABLE disables it. The default is to output the table.

The list of variables to be read from the data list must come last in the DATA LIST command. 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 specified using DATA LIST's TO convention (see section 7.6.3 Lists of variable names). There are two ways to specify the location of the variable on the line: SPSS style and FORTRAN style.

With SPSS 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 7.6.4 Input and Output Formats). (This default can be changed; see 16.10 SET for more information.)

When using SPSS 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 SPSS style, the input and output width of each variable is computed from the field width. The field width must be evenly divisible into the number of variables specified.

FORTRAN style is an altogether different approach to specifying field locations. With this approach, a list of variable input format specifications, separated by commas, are placed after the variable names inside parentheses. Each format specifier advances as many characters into the input line as it uses.

In addition to the standard format specifiers (see section 7.6.4 Input and Output Formats), 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 SPSS styles may be freely intermixed. SPSS style leaves the active column immediately after the ending column specified. Record motion using NEWREC in FORTRAN style also applies to later FORTRAN and SPSS specifiers.

Examples  Examples of DATA LIST FIXED.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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:

    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.

  2.  
    DAT LIS FIL="survey.dat"
            /ID 1-5 NAME 7-36 (A) SURNAME 38-67 (A) MINITIAL 69 (A)
            /Q01 TO Q50 7-56
            /.
    

    Defines the following variables:

    Cases are separated by a blank record.

    Data is read from file `survey.dat' in the current directory.

    This example shows keywords abbreviated to their first 3 letters.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.2 DATA LIST FREE

 
DATA LIST FREE
        [{NOTABLE,TABLE}]
        FILE='filename'
        END=end_var
        /var_spec...

where each var_spec takes one of the forms
        var_list [(type_spec)]
        var_list *

In free format, the input data is structured as a series of comma- or whitespace-delimited fields (end of line is one form of whitespace; it is not treated specially). Field contents may be surrounded by matched pairs of apostrophes (`'') or quotes (`"'), or they may be unenclosed. For any type of field leading white space (up to the apostrophe or quote, if any) is not included in the field.

Multiple consecutive delimiters are equivalent to a single delimiter. To specify an empty field, write an empty set of single or double quotes; for instance, `""'.

The NOTABLE and TABLE subcommands are as in DATA LIST FIXED above. NOTABLE is the default.

The FILE and END subcommands are as in DATA LIST FIXED above.

The variables to be parsed are given as a single list of variable names. This list must be introduced by a single slash (`/'). The set of variable names may contain format specifications in parentheses (see section 7.6.4 Input and Output Formats). Format specifications apply to all variables back to the previous parenthesized format specification.

In addition, an asterisk may be used to indicate that all variables preceding it are to have input/output format `F8.0'.

Specified field widths are ignored on input, although all normal limits on field width apply, but they are honored on output.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.3 DATA LIST LIST

 
DATA LIST LIST
        [{NOTABLE,TABLE}]
        FILE='filename'
        END=end_var
        /var_spec...

where each var_spec takes one of the forms
        var_list [(type_spec)]
        var_list *

Syntactically and semantically, DATA LIST LIST is equivalent to DATA LIST FREE, with one exception: each input line is expected to correspond to exactly one input record. If more or fewer fields are found on an input line than expected, an appropriate diagnostic is issued.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4 END CASE

 
END CASE.

END CASE is used within INPUT PROGRAM to output the current case. See section 9.7 INPUT PROGRAM.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5 END FILE

 
END FILE.

END FILE is used within INPUT PROGRAM to terminate the current input program. See section 9.7 INPUT PROGRAM.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6 FILE HANDLE

 
FILE HANDLE handle_name
        /NAME='filename'
        /RECFORM={VARIABLE,FIXED,SPANNED}
        /LRECL=rec_len
        /MODE={CHARACTER,IMAGE,BINARY,MULTIPUNCH,360}

Use the FILE HANDLE command to define the attributes of a file that does not use conventional variable-length records terminated by newline characters.

Specify the file handle name as an identifier. Any given identifier may only appear once in a PSPP run. File handles may not be reassigned to a different file. The file handle name must immediately follow the FILE HANDLE command name.

The NAME subcommand specifies the name of the file associated with the handle. It is the only required subcommand.

The RECFORM subcommand specifies how the file is laid out. VARIABLE specifies variable-length lines terminated with newlines, and it is the default. FIXED specifies fixed-length records. SPANNED is not supported.

LRECL specifies the length of fixed-length records. It is required if /RECFORM FIXED is specified.

MODE specifies a file mode. CHARACTER, the default, causes the data file to be opened in ANSI C text mode. BINARY causes the data file to be opened in ANSI C binary mode. The other possibilities are not supported.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7 INPUT PROGRAM

 
INPUT PROGRAM.
... input commands ...
END INPUT PROGRAM.

The INPUT PROGRAM...END INPUT PROGRAM construct is used to specify a complex input program. By placing data input commands within INPUT PROGRAM, PSPP programs can take advantage of more complex file structures than available by using DATA LIST by itself.

The first sort of extended input program is to simply put multiple DATA LIST commands within the INPUT PROGRAM. This will cause all of the data files to be read in parallel. Input will stop when end of file is reached on any of the data files.

Transformations, such as conditional and looping constructs, can also be included within an INPUT PROGRAM. These can be used to combine input from several data files in more complex ways. However, input will still stop when end of file is reached on any of the data files.

To prevent INPUT PROGRAM from terminating at the first end of file, use the END subcommand on DATA LIST. This subcommand takes a variable name, which should be a numeric scratch variable (see section 7.6.5 Scratch Variables). (It need not be a scratch variable but otherwise the results can be surprising.) The value of this variable is set to 0 when reading the data file, or 1 when end of file is encountered.

Some additional commands are useful in conjunction with INPUT PROGRAM. END CASE is the first one. Normally each loop through the INPUT PROGRAM structure produces one case. But with END CASE you can control 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 other command. 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. The END FILE command, when executed, stops the flow of input data and passes out of the INPUT PROGRAM structure.

All this is very confusing. A few examples should help to clarify.

 
INPUT PROGRAM.
        DATA LIST NOTABLE FILE='a.data'/X 1-10.
        DATA LIST NOTABLE FILE='b.data'/Y 1-10.
END INPUT PROGRAM.
LIST.

The example above reads variable X from file `a.data' and variable Y from file `b.data'. If one file is shorter than the other then the extra data in the longer file is ignored.

 
INPUT PROGRAM.
        NUMERIC #A #B.
        
        DO IF NOT #A.
                DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
        END IF.
        DO IF NOT #B.
                DATA LIST NOTABLE END=#B FILE='b.data'/Y 1-10.
        END IF.
        DO IF #A AND #B.
                END FILE.
        END IF.
        END CASE.
END INPUT PROGRAM.
LIST.

This example reads variable X from `a.data' and variable Y from `b.data'. If one file is shorter than the other then the missing field is set to the system-missing value alongside the present value for the remaining length of the longer file.

 
INPUT PROGRAM.
        NUMERIC #A #B.

        DO IF #A.
                DATA LIST NOTABLE END=#B FILE='b.data'/X 1-10.
                DO IF #B.
                        END FILE.
                ELSE.
                        END CASE.
                END IF.
        ELSE.
                DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
                DO IF NOT #A.
                        END CASE.
                END IF.
        END IF.
END INPUT PROGRAM.
LIST.

The above example reads data from file `a.data', then from `b.data', and concatenates them into a single active file.

 
INPUT PROGRAM.
        NUMERIC #EOF.

        LOOP IF NOT #EOF.
                DATA LIST NOTABLE END=#EOF FILE='a.data'/X 1-10.
                DO IF NOT #EOF.
                        END CASE.
                END IF.
        END LOOP.

        COMPUTE #EOF = 0.
        LOOP IF NOT #EOF.
                DATA LIST NOTABLE END=#EOF FILE='b.data'/X 1-10.
                DO IF NOT #EOF.
                        END CASE.
                END IF.
        END LOOP.

        END FILE.
END INPUT PROGRAM.
LIST.

The above example does the same thing as the previous example, in a different way.

 
INPUT PROGRAM.
        LOOP #I=1 TO 50.
                COMPUTE X=UNIFORM(10).
                END CASE.
        END LOOP.
        END FILE.
END INPUT PROGRAM.
LIST/FORMAT=NUMBERED.

The above example causes an active file to be created consisting of 50 random variates between 0 and 10.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.8 LIST

 
LIST
        /VARIABLES=var_list
        /CASES=FROM start_index TO end_index BY incr_index
        /FORMAT={UNNUMBERED,NUMBERED} {WRAP,SINGLE} 
                {NOWEIGHT,WEIGHT}

The LIST procedure prints the values of specified variables to the listing file.

The VARIABLES subcommand specifies the variables whose values are to be printed. Keyword VARIABLES is optional. If VARIABLES subcommand is not specified then all variables in the active file are printed.

The CASES subcommand can be used to specify a subset of cases to be printed. Specify FROM and the case number of the first case to print, TO and the case number of the last case to print, and BY and the number of cases to advance between printing cases, or any subset of those settings. If CASES is not specified then all cases are printed.

The FORMAT subcommand can be used to change the output format. NUMBERED will print case numbers along with each case; UNNUMBERED, the default, causes the case numbers to be omitted. The WRAP and SINGLE settings are currently not used. WEIGHT will cause case weights to be printed along with variable values; NOWEIGHT, the default, causes case weights to be omitted from the output.

Case numbers start from 1. They are counted after all transformations have been considered.

LIST will attempt to fit all the values on a single line. If necessary, variable names will be display vertically in order to fit. If values cannot fit on a single line, then a multi-line format will be used.

LIST is a procedure. It causes the data to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.9 MATRIX DATA

 
MATRIX DATA
        /VARIABLES=var_list
        /FILE='filename'
        /FORMAT={LIST,FREE} {LOWER,UPPER,FULL} {DIAGONAL,NODIAGONAL}
        /SPLIT={new_var,var_list}
        /FACTORS=var_list
        /CELLS=n_cells
        /N=n
        /CONTENTS={N_VECTOR,N_SCALAR,N_MATRIX,MEAN,STDDEV,COUNT,MSE,
                   DFE,MAT,COV,CORR,PROX}

The MATRIX DATA command reads square matrices in one of several textual formats. MATRIX DATA clears the dictionary and replaces it and reads a data file.

Use VARIABLES to specify the variables that form the rows and columns of the matrices. You may not specify a variable named VARNAME_. You should specify VARIABLES first.

Specify the file to read on FILE, either as a file name string or a file handle (see section 9.6 FILE HANDLE). If FILE is not specified then matrix data must immediately follow MATRIX DATA with a BEGIN DATA...END DATA construct (see section 9.1 BEGIN DATA).

The FORMAT subcommand specifies how the matrices are formatted. LIST, the default, indicates that there is one line per row of matrix data; FREE allows single matrix rows to be broken across multiple lines. This is analogous to the difference between DATA LIST FREE and DATA LIST LIST (see section 9.3 DATA LIST). LOWER, the default, indicates that the lower triangle of the matrix is given; UPPER indicates the upper triangle; and FULL indicates that the entire matrix is given. DIAGONAL, the default, indicates that the diagonal is part of the data; NODIAGONAL indicates that it is omitted. DIAGONAL/NODIAGONAL have no effect when FULL is specified.

The SPLIT subcommand is used to specify SPLIT FILE variables for the input matrices (see section 13.6 SPLIT FILE). Specify either a single variable not specified on VARIABLES, or one or more variables that are specified on VARIABLES. In the former case, the SPLIT values are not present in the data and ROWTYPE_ may not be specified on VARIABLES. In the latter case, the SPLIT values are present in the data.

Specify a list of factor variables on FACTORS. Factor variables must also be listed on VARIABLES. Factor variables are used when there are some variables where, for each possible combination of their values, statistics on the matrix variables are included in the data.

If FACTORS is specified and ROWTYPE_ is not specified on VARIABLES, the CELLS subcommand is required. Specify the number of factor variable combinations that are given. For instance, if factor variable A has 2 values and factor variable B has 3 values, specify 6.

The N subcommand specifies a population number of observations. When N is specified, one N record is output for each SPLIT FILE.

Use CONTENTS to specify what sort of information the matrices include. Each possible option is described in more detail below. When ROWTYPE_ is specified on VARIABLES, CONTENTS is optional; otherwise, if CONTENTS is not specified then /CONTENTS=CORR is assumed.

N
N_VECTOR
Number of observations as a vector, one value for each variable.
N_SCALAR
Number of observations as a single value.
N_MATRIX
Matrix of counts.
MEAN
Vector of means.
STDDEV
Vector of standard deviations.
COUNT
Vector of counts.
MSE
Vector of mean squared errors.
DFE
Vector of degrees of freedom.
MAT
Generic matrix.
COV
Covariance matrix.
CORR
Correlation matrix.
PROX
Proximities matrix.

The exact semantics of the matrices read by MATRIX DATA are complex. Right now MATRIX DATA isn't too useful due to a lack of procedures accepting or producing related data, so these semantics aren't documented. Later, they'll be described here in detail.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.10 NEW FILE

 
NEW FILE.

The NEW FILE command clears the current active file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.11 PRINT

 
PRINT 
        OUTFILE='filename'
        RECORDS=n_lines
        {NOTABLE,TABLE}
        /[line_no] arg...

arg takes one of the following forms:
        'string' [start-end]
        var_list start-end [type_spec]
        var_list (fortran_spec)
        var_list *

The PRINT transformation writes variable data to an output file. PRINT is executed when a procedure causes the data to be read. In order to execute the PRINT transformation without invoking a procedure, use the EXECUTE command (see section 16.6 EXECUTE).

All PRINT subcommands are optional.

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 9.6 FILE HANDLE). If OUTFILE is not present then output will be sent to PSPP's output listing file.

The RECORDS subcommand specifies the number of lines to be output. The number of lines may optionally be surrounded by parentheses.

TABLE will cause the PRINT command to output a table to the listing file that describes what it will print to the output file. NOTABLE, the default, suppresses this output table.

Introduce the strings and variables to be printed with a slash (`/'). Optionally, the slash may be followed by a number indicating which output line will be specified. In the absence of this line number, the next line number will be specified. Multiple lines may be specified using multiple slashes with the intended output for a line following its respective slash.

Literal strings may be printed. Specify the string itself. Optionally the string may be followed by a column number or range of column numbers, specifying the location on the line for the string to be printed. Otherwise, the string will be printed at the current position on the line.

Variables to be printed can be specified in the same ways as available for DATA LIST FIXED (see section 9.3.1 DATA LIST FIXED). In addition, a variable list may be followed by an asterisk (`*'), which indicates that the variables should be printed in their dictionary print formats, separated by spaces. A variable list followed by a slash or the end of command will be interpreted the same way.

If a FORTRAN type specification is used to move backwards on the current line, then text is written at that point on the line, the line will be truncated to that length, although additional text being added will again extend the line to that length.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.12 PRINT EJECT

 
PRINT EJECT 
        OUTFILE='filename'
        RECORDS=n_lines
        {NOTABLE,TABLE}
        /[line_no] arg...

arg takes one of the following forms:
        'string' [start-end]
        var_list start-end [type_spec]
        var_list (fortran_spec)
        var_list *

PRINT EJECT is used to write data to an output file. Before the data is written, the current page in the listing file is ejected.

See section 9.11 PRINT, for more information on syntax and usage.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.13 PRINT SPACE

 
PRINT SPACE OUTFILE='filename' n_lines.

The PRINT SPACE prints one or more blank lines to an output file.

The OUTFILE subcommand is optional. It may be used to direct output to a file specified by file name as a string or file handle (see section 9.6 FILE HANDLE). If OUTFILE is not specified then output will be directed to the listing file.

n_lines is also optional. If present, it is an expression (see section 8. Mathematical Expressions) specifying the number of blank lines to be printed. The expression must evaluate to a nonnegative value.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.14 REREAD

 
REREAD FILE=handle COLUMN=column.

The REREAD transformation allows the previous input line in a data file already processed by DATA LIST or another input command to be re-read for further processing.

The FILE subcommand, which is optional, is used to specify the file to have its line re-read. The file must be specified in the form of a file handle (see section 9.6 FILE HANDLE). If FILE is not specified then the last file specified on DATA LIST will be assumed (last file specified lexically, not in terms of flow-of-control).

By default, the line re-read is re-read in its entirety. With the COLUMN subcommand, a prefix of the line can be exempted from re-reading. Specify an expression (see section 8. Mathematical Expressions) evaluating to the first column that should be included in the re-read line. Columns are numbered from 1 at the left margin.

Multiple REREAD commands will not back up in the data file. Instead, they will re-read the same line multiple times.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.15 REPEATING DATA

 
REPEATING DATA
        /STARTS=start-end
        /OCCURS=n_occurs
        /FILE='filename'
        /LENGTH=length
        /CONTINUED[=cont_start-cont_end]
        /ID=id_start-id_end=id_var
        /{TABLE,NOTABLE}
        /DATA=var_spec...

where each var_spec takes one of the forms
        var_list start-end [type_spec]
        var_list (fortran_spec)

The REPEATING DATA command is used to parse groups of data repeating in a uniform format, possibly with several groups on a single line. Each group of data corresponds with one case. REPEATING DATA may only be used within an INPUT PROGRAM structure. When used with DATA LIST, it can be used to parse groups of cases that share a subset of variables but differ in their other data.

The STARTS subcommand is required. Specify a range of columns, using literal numbers or numeric variable names. This range specifies the columns on the first line that are used to contain groups of data. The ending column is optional. If it is not specified, then the record width of the input file is used. For the inline file (see section 9.1 BEGIN DATA) this is 80 columns; for a file with fixed record widths it is the record width; for other files it is 1024 characters by default.

The OCCURS subcommand is required. It must be a number or the name of a numeric variable. Its value is the number of groups present in the current record.

The DATA subcommand is required. It must be the last subcommand specified. It is used to specify the data present within each repeating group. Column numbers are specified relative to the beginning of a group at column 1. Data is specified in the same way as with DATA LIST FIXED (see section 9.3.1 DATA LIST FIXED).

All other subcommands are optional.

FILE specifies the file to read, either a file name as a string or a file handle (see section 9.6 FILE HANDLE). If FILE is not present then the default is the last file handle used on DATA LIST (lexically, not in terms of flow of control).

By default REPEATING DATA will output a table describing how it will parse the input data. Specifying NOTABLE will disable this behavior; specifying TABLE will explicitly enable it.

The LENGTH subcommand specifies the length in characters of each group. If it is not present then length is inferred from the DATA subcommand. LENGTH can be a number or a variable name.

Normally all the data groups are expected to be present on a single line. Use the CONTINUED command to indicate that data can be continued onto additional lines. If data on continuation lines starts at the left margin and continues through the entire field width, no column specifications are necessary on CONTINUED. Otherwise, specify the possible range of columns in the same way as on STARTS.

When data groups are continued from line to line, it's easily possible for cases to get out of sync if hand editing is not done carefully. 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.16 WRITE

 
WRITE 
        OUTFILE='filename'
        RECORDS=n_lines
        {NOTABLE,TABLE}
        /[line_no] arg...

arg takes one of the following forms:
        'string' [start-end]
        var_list start-end [type_spec]
        var_list (fortran_spec)
        var_list *

WRITE is used to write text or binary data to an output file.

See section 9.11 PRINT, for more information on syntax and usage. The main difference between PRINT and WRITE is that whereas by default PRINT uses variables' print formats, WRITE uses write formats.

The sole additional difference is that if WRITE is used to send output to a binary file, carriage control characters will not be output. See section 9.6 FILE HANDLE, for information on how to declare a file as binary.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10. System Files and Portable Files

The commands in this chapter read, write, and examine system files and portable files.

10.1 APPLY DICTIONARY  Apply system file dictionary to active file.
10.2 EXPORT  Write to a portable file.
10.3 GET  Read from a system file.
10.4 IMPORT  Read from a portable file.
10.5 MATCH FILES  Merge system files.
10.6 SAVE  Write to a system file.
10.7 SYSFILE INFO  Display system file dictionary.
10.8 XSAVE  Write to a system file, as a transform.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.1 APPLY DICTIONARY

 
APPLY DICTIONARY FROM='filename'.

The APPLY DICTIONARY command applies the variable labels, value labels, and missing values from variables in a system file to corresponding variables in the active file. In some cases it also updates the weighting variable.

Specify a system file with a file name string or as a file handle (see section 9.6 FILE HANDLE). The dictionary in the system file will be read, but it will not replace the active file dictionary. The system file's data will not be read.

Only variables with names that exist in both the active file and the system file are considered. Variables with the same name but different types (numeric, string) will cause an error message. Otherwise, the system file variables' attributes will replace those in their matching active file variables, as described below.

If a system file variable has a variable label, then it will replace the active file variable's variable label. If the system file variable does not have a variable label, then the active file variable's variable label, if any, will be retained.

If the active file variable is numeric or short string, then value labels and missing values, if any, will be copied to the active file variable. If the system file variable does not have value labels or missing values, then those in the active file variable, if any, will not be disturbed.

Finally, weighting of the active file is updated (see section 13.8 WEIGHT). If the active file has a weighting variable, and the system file does not, or if the weighting variable in the system file does not exist in the active file, then the active file weighting variable, if any, is retained. Otherwise, the weighting variable in the system file becomes the active file weighting variable.

APPLY DICTIONARY takes effect immediately. It does not read the active file. The system file is not modified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.2 EXPORT

 
EXPORT
        /OUTFILE='filename'
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...

The EXPORT procedure writes the active file dictionary and data to a specified portable file.

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 9.6 FILE HANDLE).

DROP, KEEP, and RENAME follow the same format as the SAVE procedure (see section 10.6 SAVE).

EXPORT is a procedure. It causes the active file to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.3 GET

 
GET
        /FILE='filename'
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...

The GET transformation clears the current dictionary and active file and replaces them with the dictionary and data from a specified system file.

The FILE subcommand is the only required subcommand. Specify the system file to be read as a string file name or a file handle (see section 9.6 FILE HANDLE).

By default, all the variables in a system 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 system 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 performed in left-to-right order. They each may be present any number of times.

Please note that DROP, KEEP, and RENAME do not cause the system file on disk to be modified. Only the active file read from the system file is changed.

GET does not cause the data to be read, only the dictionary. The data is read later, when a procedure is executed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4 IMPORT

 
IMPORT
        /FILE='filename'
        /TYPE={COMM,TAPE}
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...

The IMPORT transformation clears the active file dictionary and data and replaces them with a dictionary and data from a portable file on disk.

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 9.6 FILE HANDLE).

The TYPE subcommand is currently not used.

DROP, KEEP, and RENAME follow the syntax used by GET (see section 10.3 GET).

IMPORT does not cause the data to be read, only the dictionary. The data is read later, when a procedure is executed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.5 MATCH FILES

 
MATCH FILES
        /BY var_list
        /{FILE,TABLE}={*,'filename'}
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...
        /IN=var_name
        /FIRST=var_name
        /LAST=var_name
        /MAP

The MATCH FILES command merges one or more system files, optionally including the active file. Records with the same values for BY variables are combined into a single record. Records with different values are output in order. Thus, multiple sorted system files are combined into a single sorted system file based on the value of the BY variables.

The BY subcommand specifies a list of variables that are used to match records from each of the system files. Variables specified must exist in all the files specified on FILE and TABLE. BY should usually be specified. If TABLE is used then BY is required.

Specify FILE with a system file as a file name string or file handle (see section 9.6 FILE HANDLE). An asterisk (`*') may also be specified to indicate the current active file. The files specified on FILE are merged together based on the BY variables, or combined case-by-case if BY is not specified. Normally at least two FILE subcommands should be specified.

Specify TABLE with a system file in order to use it as a table lookup file. Records in table lookup files are not used up after they've been used once. This means that data in table lookup files can correspond to any number of records in FILE files. Table lookup files correspond to lookup tables in traditional relational database systems. It is incorrect to have records with duplicate BY values in table lookup files.

Any number of FILE and TABLE subcommands may be specified. Each instance of FILE or TABLE can be followed by DROP, KEEP, and/or RENAME subcommands. These take the same form as the corresponding subcommands of GET (see section 10.3 GET), and perform the same functions.

Variables belonging to files that are not present for the current case are set to the system-missing value for numeric variables or spaces for string variables.

IN, FIRST, LAST, and MAP are currently not used.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.6 SAVE

 
SAVE
        /OUTFILE='filename'
        /{COMPRESSED,UNCOMPRESSED}
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...

The SAVE procedure causes the dictionary and data in the active file to be written to a system file.

The FILE subcommand is the only required subcommand. Specify the system file to be written as a string file name or a file handle (see section 9.6 FILE HANDLE).

The COMPRESS and UNCOMPRESS subcommand determine whether the saved system file is compressed. By default, system files are compressed. This default can be changed with the SET command (see section 16.10 SET).

By default, all the variables in the active file dictionary are written to the system file. The DROP subcommand can be used to specify a list of variables not to be written. In contrast, KEEP specifies variables to be written, with all variables not specified not written.

Normally variables are saved to a system file under the same names they have in the active file. Use the RENAME command 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.

Please note that DROP, KEEP, and RENAME do not cause the active file to be modified. Only the system file written to disk is changed.

SAVE causes the data to be read. It is a procedure.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.7 SYSFILE INFO

 
SYSFILE INFO FILE='filename'.

The SYSFILE INFO command reads the dictionary in a system file and displays the information in its dictionary.

Specify a file name or file handle. SYSFILE INFO will read that file as a system file and display information on its dictionary.

The file does not replace the current active file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.8 XSAVE

 
XSAVE
        /FILE='filename'
        /{COMPRESSED,UNCOMPRESSED}
        /DROP=var_list
        /KEEP=var_list
        /RENAME=(src_names=target_names)...

The XSAVE transformation writes the active file dictionary and data to a system file stored on disk.

XSAVE is a transformation, not a procedure. It is executed when the data is read by a procedure or procedure-like command. In all other respects, XSAVE is identical to SAVE. See section 10.6 SAVE, for more information on syntax and usage.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11. Manipulating variables

The variables in the active file dictionary are important. There are several utility functions for examining and adjusting them.

11.1 ADD VALUE LABELS  Add value labels to variables.
11.2 DISPLAY  Display variable names & descriptions.
11.3 DISPLAY VECTORS  Display a list of vectors.
11.4 FORMATS  Set print and write formats.
11.5 LEAVE  Don't clear variables between cases.
11.6 MISSING VALUES  Set missing values for variables.
11.7 MODIFY VARS  Rename, reorder, and drop variables.
11.8 NUMERIC  Create new numeric variables.
11.9 PRINT FORMATS  Set variable print formats.
11.10 RENAME VARIABLES  Rename variables.
11.11 VALUE LABELS  Set value labels for variables.
11.12 STRING  Create new string variables.
11.13 VARIABLE LABELS  Set variable labels for variables.
11.14 VECTOR  Declare an array of variables.
11.15 WRITE FORMATS  Set variable write formats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.1 ADD VALUE LABELS

 
ADD VALUE LABELS
        /var_list value 'label' [value 'label']...

ADD VALUE LABELS has the same syntax and purpose as VALUE LABELS (see above), but it does not clear away value labels from the variables before adding the ones specified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.2 DISPLAY

 
DISPLAY {NAMES,INDEX,LABELS,VARIABLES,DICTIONARY,SCRATCH}
        [SORTED] [var_list]

DISPLAY displays requested information on variables. Variables can optionally be sorted alphabetically. The entire dictionary or just specified variables can be described.

One of the following keywords can be present:

NAMES
The variables' names are displayed.

INDEX
The variables' names are displayed along with a value describing their position within the active file 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
Varible names are displayed, for scratch variables only (see section 7.6.5 Scratch Variables).

If SORTED is specified, then the variables are displayed in ascending order based on their names; otherwise, they are displayed in the order that they occur in the active file dictionary.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.3 DISPLAY VECTORS

 
DISPLAY VECTORS.

The DISPLAY VECTORS command causes a list of the currently declared vectors to be displayed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 FORMATS

 
FORMATS var_list (fmt_spec).

The FORMATS command set the print and write formats for the specified variables to the specified format specification. See section 7.6.4 Input and Output Formats.

Specify a list of variables followed by a format specification in parentheses. The print and write formats of the specified variables will be changed.

Additional lists of variables and formats may be included if they are delimited by a slash (`/').

The FORMATS command takes effect immediately. It is not affected by conditional and looping structures such as DO IF or LOOP.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.5 LEAVE

 
LEAVE var_list.

The LEAVE command prevents the specified variables from being reinitialized whenever a new case is processed.

Normally, when a data file is processed, every variable in the active file is initialized to the system-missing value or spaces at the beginning of processing for each case. When a variable has been specified on LEAVE, this is not the case. Instead, that variable is initialized to 0 (not system-missing) or spaces for the first case. After that, it retains its value between cases.

This becomes useful for counters. For instance, in the example below the variable SUM maintains a running total of the values in the ITEM variable.

 
DATA LIST /ITEM 1-3.
COMPUTE SUM=SUM+ITEM.
PRINT /ITEM SUM.
LEAVE SUM
BEGIN DATA.
123
404
555
999
END DATA.

Partial output from this example:

 
123   123.00
404   527.00
555  1082.00
999  2081.00

It is best to use the LEAVE command immediately before invoking a procedure command, because it is reset by certain transformations--for instance, COMPUTE and IF. LEAVE is also reset by all procedure invocations.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.6 MISSING VALUES

 
MISSING VALUES var_list (missing_values).

missing_values takes one of the following forms:
        num1
        num1, num2
        num1, num2, num3
        num1 THRU num2
        num1 THRU num2, num3
        string1
        string1, string2
        string1, string2, string3
As part of a range, LO or LOWEST may take the place of num1;
HI or HIGHEST may take the place of num2.

The MISSING VALUES command sets user-missing values for numeric and short string variables. Long string variables may not have missing values.

Specify a list of variables, followed by a list of their user-missing values in parentheses. Up to three discrete values may be given, or, for numeric variables only, a range of values optionally accompanied by a single discrete value. Ranges may be open-ended on one end, indicated through the use of the keyword LO or LOWEST or HI or HIGHEST.

The MISSING VALUES command takes effect immediately. It is not affected by conditional and looping constructs such as DO IF or LOOP.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.7 MODIFY VARS

 
MODIFY VARS
        /REORDER={FORWARD,BACKWARD} {POSITIONAL,ALPHA} (var_list)...
        /RENAME=(old_names=new_names)...
        /{DROP,KEEP}=var_list
        /MAP    

The MODIFY VARS commands allows variables in the active file to be reordered, renamed, or deleted from the active file.

At least one subcommand must be specified, and no subcommand may be specified more than once. DROP and KEEP may not both be specified.

The REORDER subcommand changes the order of variables in the active file. Specify one or more lists of variable names in parentheses. By default, each list of variables is rearranged into the specified order. To put the variables into the reverse of the specified order, put keyword BACKWARD before the parentheses. To put them into alphabetical order in the dictionary, specify keyword ALPHA before the parentheses. BACKWARD and ALPHA may also be combined.

To rename variables in the active file, specify RENAME, an equals sign (`='), and lists of the old variable names and new variable names separated by another equals sign within parentheses. There must be the same number of old and new variable names. Each old variable is renamed to the corresponding new variable name. Multiple parenthesized groups of variables may be specified.

The DROP subcommand deletes a specified list of variables from the active file.

The KEEP subcommand keeps the specified list of variables in the active file. Any unlisted variables are delete from the active file.

MAP is currently ignored.

MODIFY VARS takes effect immediately. It does not cause the data to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.8 NUMERIC

 
NUMERIC /var_list [(fmt_spec)].

The NUMERIC command explicitly declares new numeric variables, optionally setting their output formats.

Specify a slash (`/'), followed by the names of the new numeric variables. If you wish to set their output formats, follow their names by an output format specification in parentheses (see section 7.6.4 Input and Output Formats). If no output format specification is given then the variables will default to F8.2.

Variables created with NUMERIC will be initialized to the system-missing value.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.9 PRINT FORMATS

 
PRINT FORMATS var_list (fmt_spec).

The PRINT FORMATS command sets the print formats for the specified variables to the specified format specification.

Syntax is identical to that of FORMATS (see section 11.4 FORMATS), but the PRINT FORMATS command sets only print formats, not write formats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.10 RENAME VARIABLES

 
RENAME VARIABLES (old_names=new_names)... .

The RENAME VARIABLES command allows the names of variables in the active file to be changed.

To rename variables, specify lists of the old variable names and new variable names, separated by an equals sign (`='), within parentheses. There must be the same number of old and new variable names. Each old variable is renamed to the corresponding new variable name. Multiple parenthesized groups of variables may be specified.

RENAME VARIABLES takes effect immediately. It does not cause the data to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.11 VALUE LABELS

 
VALUE LABELS
        /var_list value 'label' [value 'label']...

The VALUE LABELS command allows values of numeric and short string variables to be associated with labels. In this way, a short value can stand for a long value.

In order to set up value labels for a set of variables, specify the variable names after a slash (`/'), followed by a list of values and their associated labels, separated by spaces.

Before the VALUE LABELS command is executed, any existing value labels are cleared from the variables specified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.12 STRING

 
STRING /var_list (fmt_spec).

The STRING command creates new string variables for use in transformations.

Specify a slash (`/'), followed by the names of the string variables to create and the desired output format specification in parentheses (see section 7.6.4 Input and Output Formats). Variable widths are implicitly derived from the specified output formats.

Created variables are initialized to spaces.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.13 VARIABLE LABELS

 
VARIABLE LABELS
        /var_list 'var_label'.

The VARIABLE LABELS command is used to associate an explanatory name with a group of variables. This name (a variable label) is displayed by statistical procedures.

To assign a variable label to a group of variables, specify a slash (`/'), followed by the list of variable names and the variable label as a string.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.14 VECTOR

 
Two possible syntaxes:
        VECTOR vec_name=var_list.
        VECTOR vec_name_list(count).

The VECTOR command 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 that belong in the vector.

To make a vector and create variables at the same time, specify one or more vector names followed by a count in parentheses. This will cause variables named vec1 through veccount to be created as numeric variables. Variable names including numeric suffixes may not exceed 8 characters in length, and none of the variables may exist prior to the VECTOR command.

All the variables in a vector must be the same type.

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 7.6.5 Scratch Variables).

Variables within a vector may be references in expressions using vector(index) syntax.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.15 WRITE FORMATS

 
WRITE FORMATS var_list (fmt_spec).

The WRITE FORMATS command sets the write formats for the specified variables to the specified format specification.

Syntax is identical to that of FORMATS (see section 11.4 FORMATS), but the WRITE FORMATS command sets only write formats, not print formats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. Data transformations

The PSPP procedures examined in this chapter manipulate data and prepare the active file for later analyses. They do not produce output, as a rule.

12.1 AGGREGATE  Summarize multiple cases into a single case.
12.2 AUTORECODE  Automatic recoding of variables.
12.3 COMPUTE  Assigning a variable a calculated value.
12.4 COUNT  Counting variables with particular values.
12.5 FLIP  Exchange variables with cases.
12.6 IF  Conditionally assigning a calculated value.
12.7 RECODE  Mapping values from one set to another.
12.8 SORT CASES  Sort the active file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.1 AGGREGATE

 
AGGREGATE
        /BREAK=var_list
        /PRESORTED
        /OUTFILE={*,'filename'}
        /DOCUMENT
        /MISSING=COLUMNWISE
        /dest_vars=agr_func(src_vars, args...)...

The AGGREGATE command summarizes groups of cases into single cases. Cases are divided into groups that have the same values for one or more variables called break variables. Several functions are available for summarizing case contents.

BREAK is the only required subcommand (in addition, at least one aggregation variable must be specified). Specify a list of variable names. The values of these variables are used to divide the active file into groups to be summarized.

By default, the active file is sorted based on the break variables before aggregation takes place. If the active file is already sorted, specify PRESORTED to save time.

The OUTFILE subcommand specifies a system file by file name string or file handle (see section 9.6 FILE HANDLE). The aggregated cases are sent to this file. If OUTFILE is not specified, or if `*' is specified, then the aggregated cases replace the active file.

Normally the aggregate file does not receive the documents from the active file, even if the aggregate file replaces the active file. Specify DOCUMENT to have the documents from the active file copied to the aggregate file.

At least one aggregation variable must be specified. Specify a list of aggregation variables, an equals sign (`='), an aggregation function name (see the list below), and a list of source variables in parentheses. In addition, some aggregation functions expect additional arguments in the parentheses following the source variable names.

There must be exactly as many source variables as aggregation variables. Each aggregation variable receives the results of applying the specified aggregation function to the corresponding source variable. Most aggregation functions may be applied to numeric and short and long string variables. Others are restricted to numeric values; these are marked as such in this list below.

Any number of sets of aggregation variables may be specified.

The available aggregation functions are as follows:

SUM(var_name)
Sum. Limited to numeric values.
MEAN(var_name)
Arithmetic mean. Limited to numeric values.
SD(var_name)
Standard deviation of the mean. Limited to numeric values.
MAX(var_name)
Maximum value.
MIN(var_name)
Minimum value.
FGT(var_name, value)
PGT(var_name, value)
Fraction between 0 and 1, or percentage between 0 and 100, respectively, of values greater than the specified constant.
FLT(var_name, value)
PLT(var_name, value)
Fraction or percentage, respectively, of values less than the specified constant.
FIN(var_name, low, high)
PIN(var_name, low, high)
Fraction or percentage, respectively, of values within the specified inclusive range of constants.
FOUT(var_name, low, high)
POUT(var_name, low, high)
Fraction or percentage, respectively, of values strictly outside the specified range of constants.
N(var_name)
Number of non-missing values.
N
Number of cases aggregated to form this group. Don't supply a source variable for this aggregation function.
NU(var_name)
Number of non-missing values. Each case is considered to have a weight of 1, regardless of the current weighting variable (see section 13.8 WEIGHT).
NU
Number of cases aggregated to form this group. Each case is considered to have a weight of 1, regardless of the current weighting variable.
NMISS(var_name)
Number of missing values.
NUMISS(var_name)
Number of missing values. Each case is considered to have a weight of 1, regardless of the current weighting variable.
FIRST(var_name)
First value in this group.
LAST(var_name)
Last value in this group.

When string values are compared by aggregation functions, they are done in terms of internal character codes. On most modern computers, this is a form of ASCII.

In addition, there is a parallel set of aggregation functions having the same names as those above, but with a dot after the last character (for instance, `SUM.'). These functions are the same as the above, except that they cause user-missing values, which are normally excluded from calculations, to be included.

Normally, only a single case (2 for SD and SD.) need be non-missing in each group in order for the aggregate variable to be non-missing. If /MISSING=COLUMNWISE is specified, the behavior reverses: that is, a single missing value is enough to make the aggregate variable become a missing value.

AGGREGATE ignores the current SPLIT FILE settings and causes them to be canceled (see section 13.6 SPLIT FILE).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2 AUTORECODE

 
AUTORECODE VARIABLES=src_vars INTO dest_vars
        /DESCENDING
        /PRINT

The AUTORECODE procedure considers the n values that a variable takes on and maps them onto values 1...n on a new numeric variable.

Subcommand VARIABLES is the only required subcommand and must come first. Specify VARIABLES, an equals sign (`='), a list of source variables, INTO, and a list of target variables. There must the same number of source and target variables. The target variables must not already exist.

By default, increasing values of a source variable (for a string, this is based on character code comparisons) are recoded to increasing values of its target variable. To cause increasing values of a source variable to be recoded to decreasing values of its target variable (n down to 1), specify DESCENDING.

PRINT is currently ignored.

AUTORECODE is a procedure. It causes the data to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.3 COMPUTE

 
COMPUTE var_name = expression.

COMPUTE creates a variable with the name specified (if necessary), then evaluates the given expression for every case and assigns the result to the variable. See section 8. Mathematical Expressions.

Numeric variables created or computed by COMPUTE are assigned an output width of 8 character with two decimal places (F8.2). String variables created or computed by COMPUTE have the same width as the existing variable or constant.

COMPUTE is a transformation. It does not cause the active file to be read.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.4 COUNT

 
COUNT var_name = var... (value...).

Each value takes one of the following forms:
        number
        string
        num1 THRU num2
        MISSING
        SYSMIS
In addition, num1 and num2 can be LO or LOWEST, or HI or HIGHEST,
respectively.

COUNT creates or replaces a numeric target variable that counts the occurrence of a criterion value or set of values over one or more test variables for each case.

The target variable values are always nonnegative integers. They are never missing. The target variable is assigned an F8.2 output format. See section 7.6.4 Input and Output Formats. Any variables, including long and short string variables, may be test variables.

User-missing values of test variables are treated just like any other values. They are not treated as system-missing values. User-missing values that are criterion values or inside ranges of criterion values are counted as any other values. However (for numeric variables), keyword MISSING may be used to refer to all system- and user-missing values.

COUNT target variables are assigned values in the order specified. In the command COUNT A=A B(1) /B=A B(2)., the following actions occur:

Despite this ordering, all COUNT criterion variables must exist before the procedure is executed--they may not be created as target variables earlier in the command! Break such a command into two separate commands.

The examples below may help to clarify.

  1. Assuming Q0, Q2, ..., Q9 are numeric variables, the following commands:

    1. Count the number of times the value 1 occurs through these variables for each case and assigns the count to variable QCOUNT.

    2. Print out the total number of times the value 1 occurs throughout all cases using DESCRIPTIVES. See section 15.1 DESCRIPTIVES, for details.

     
    COUNT QCOUNT=Q0 TO Q9(1).
    DESCRIPTIVES QCOUNT /STATISTICS=SUM.
    

  2. Given these same variables, the following commands:

    1. Count the number of valid values of these variables for each case and assigns the count to variable QVALID.

    2. Multiplies each value of QVALID by 10 to obtain a percentage of valid values, using COMPUTE. See section 12.3 COMPUTE, for details.

    3. Print out the percentage of valid values across all cases, using DESCRIPTIVES. See section 15.1 DESCRIPTIVES, for details.

     
    COUNT QVALID=Q0 TO Q9 (LO THRU HI).
    COMPUTE QVALID=QVALID*10.
    DESCRIPTIVES QVALID /STATISTICS=MEAN.
    


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.5 FLIP

 
FLIP /VARIABLES=var_list /NEWNAMES=var_name.

The FLIP command transposes rows and columns in the active file. It causes cases to be swapped with variables, and vice versa.

There are no required subcommands. The VARIABLES subcommand specifies variables that will be transformed into cases. Variables not specified are discarded. By default, 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. 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, which stores the names of the variables in the dictionary before the transposition. If the active file is subsequently transposed using FLIP, this variable can be used to recreate the original variable names.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.6 IF

 
Two possible syntaxes: 
        IF test_expr target_var=target_expr.
        IF test_expr target_vec(target_index)=target_expr.

The IF transformation conditionally assigns the value of a target expression to a target variable, based on the truth of a test expression.

Specify a boolean-valued expression (see section 8. Mathematical Expressions) to be tested following the IF keyword. This expression is calculated for each case. If the value is true, then the value of target_expr is computed and assigned to target_var. If the value is false or missing, nothing is done. Numeric and short and long string variables may be used. The type of target_expr must match the type of target_var.

For numeric variables only, target_var need not exist before the IF transformation is executed. In this case, target_var is assigned the system-missing value if the IF condition is not true. String variables must be declared before they can be used as targets for IF.

In addition to ordinary variables, the target variable may be an element of a vector. In this case, the vector index must be specified in parentheses following the vector name.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.7 RECODE

 
RECODE var_list (src_value...=dest_value)... [INTO var_list].

src_value may take the following forms:
        number
        string
        num1 THRU num2
        MISSING
        SYSMIS
        ELSE
Open-ended ranges may be specified using LO or LOWEST for num1
or HI or HIGHEST for num2.

dest_value may take the following forms:
        num
        string
        SYSMIS
        COPY

The RECODE command is used to translate data from one range of values to another, using flexible user-specified mappings. Data may be remapped in-place or copied to new variables. Numeric, short string, and long string data can be recoded.

Specify the list of source variables, followed by one or more mapping specifications each enclosed in parentheses. If the data is to be copied to new variables, specify INTO, then the list of target variables. String target variables must already have been declared using STRING or another transformation, but numeric target variables can be created on the fly. There must be exactly as many target variables as source variables. Each source variable is remapped into its corresponding target variable.

When INTO is not used, the input and output variables must be of the same type. Otherwise, string values can be recoded into numeric values, and vice versa. When this is done and there is no mapping for a particular value, either a value consisting of all spaces or the system-missing value is assigned, depending on variable type.

Mappings are considered from left to right. The first src_value that matches the value of the source variable causes the target variable to receive the value indicated by the dest_value. Literal number, string, and range src_value's should be self-explanatory. MISSING as a src_value matches any user- or system-missing value. SYSMIS matches the system missing value only. ELSE is a catch-all that matches anything. It should be the last src_value specified.

Numeric and string dest_value's should also be self-explanatory. COPY causes the input values to be copied to the output. This is only value if the source and target variables are of the same type. SYSMIS indicates the system-missing value.

If the source variables are strings and the target variables are numeric, then there is one additional mapping available: (CONVERT), which must be the last specified mapping. CONVERT causes a number specified as a string to be converted to a numeric value. If the string cannot be parsed as a number, then the system-missing value is assigned.

Multiple recodings can be specified on the same RECODE command. Introduce additional recodings with a slash (`/') in order to separate them from the previous recodings.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.8 SORT CASES

 
SORT CASES BY var_list.

SORT CASES sorts the active file by the values of one or more variables.

Specify BY and a list of variables to sort by. By default, variables are sorted in ascending order. To override sort order, specify (D) or (DOWN) after a list of variables to get descending order, or (A) or (UP) for ascending order. These apply to the entire list of variables preceding them.

SORT CASES is a procedure. It causes the data to be read.

SORT CASES will attempt to sort the entire active file in main memory. If main memory is exhausted then it will use a merge sort algorithm that involves writing and reading numerous temporary files. Environment variables determine the temporary files' location. The first of SPSSTMPDIR, SPSSXTMPDIR, or TMPDIR that is set determines the location. Otherwise, if the compiler environment defined P_tmpdir, that is used. Otherwise, under Unix-like OSes /tmp is used; under MS-DOS, the first of TEMP, TMP, or root on the current drive is used; under other OSes, the current directory.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13. Selecting data for analysis

This chapter documents PSPP commands that temporarily or permanently select data records from the active file for analysis.

13.1 FILTER  Exclude cases based on a variable.
13.2 N OF CASES  Limit the size of the active file.
13.3 PROCESS IF  Temporarily excluding cases.
13.4 SAMPLE  Select a specified proportion of cases.
13.5 SELECT IF  Permanently delete selected cases.
13.6 SPLIT FILE  Do multiple analyses with one command.
13.7 TEMPORARY  Make transformations' effects temporary.
13.8 WEIGHT  Weight cases by a variable.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.1 FILTER

 
FILTER BY var_name.
FILTER OFF.

The FILTER command allows a boolean-valued variable to be used to select cases from the data stream for processing.

In order 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.

Use FILTER OFF to turn off case filtering.

Filtering takes place immediately before cases pass to a procedure for analysis. Only one filter variable may be active at once. Normally, case filtering continues until it is explicitly turned off with FILTER OFF. However, if FILTER is placed after TEMPORARY, then filtering stops after execution of the next procedure or procedure-like command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.2 N OF CASES

 
N [OF CASES] num_of_cases [ESTIMATED].

Sometimes you may want to disregard cases of your input. The N command can be used to do this. N 100 tells PSPP to disregard all cases after the first 100.

If the value specified for N is greater than the number of cases read in, the value is ignored.

N does not discard cases or cause them not to be read in. It just causes cases beyond the last one specified to be ignored by data analysis commands.

A later N command can increase or decrease the number of cases selected. (To select all the cases without knowing how many there are, specify a very high number: 100000 or whatever you think is large enough.)

Transformation procedures performed after N is executed do cause cases to be discarded.

The SAMPLE, PROCESS IF, and SELECT IF commands have precedence over N---the same results are obtained by both of the following fragments, given the same random number seeds:

 
...set up, read in data...
N 100.
SAMPLE .5.
...analyze data...

...set up, read in data...  
SAMPLE .5.
N 100.
...analyze data...

Both fragments above first randomly sample approximately half of the cases, then select the first 100 of those sampled.

N with the ESTIMATED keyword can be used to give 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.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.3 PROCESS IF

 
PROCESS IF expression.

The PROCESS IF command is used to temporarily eliminate cases from the data stream. Its effects are active only through the execution of the next procedure or procedure-like command.

Specify a boolean expression (see section 8. Mathematical Expressions). If the value of the expression is true for a particular case, the case will be analyzed. If the expression has a false or missing value, then the case will be deleted from the data stream for this procedure only.

Regardless of its placement relative to other commands, PROCESS IF always takes effect immediately before data passes to the procedure. Only one PROCESS IF command may be in effect at any given time.

The effects of PROCESS IF are similar not identical to the effects of executing TEMPORARY then SELECT IF (see section 13.5 SELECT IF).

Use of PROCESS IF is deprecated. It is included for compatibility with old command files. New syntax files should use SELECT IF or FILTER instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.4 SAMPLE

 
SAMPLE num1 [FROM num2].

SAMPLE is used to randomly sample a proportion of the cases in the active file. SAMPLE is temporary, affecting only the next procedure, unless that is a data transformation, such as SELECT IF or RECODE.

The proportion to sample can be expressed as a single number between 0 and 1. If k is the number specified, and N is the number of currently-selected cases in the active file, then after SAMPLE k., there will be k*N, plus or minus one, cases 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 file, exactly m cases will be selected.

  2. If N is greater than the number of currently-selected cases in the active file, an equivalent proportion of cases will be selected.

  3. If N is less than the number of currently-selected cases in the active, exactly m cases will be selected from the first N cases in the active file.

SAMPLE, SELECT IF, and PROCESS IF are performed in the order specified by the syntax file.

SAMPLE is ignored before SORT CASES.

SAMPLE is always performed before N OF CASES, regardless of ordering in the syntax file. See section 13.2 N OF CASES.

The same values for SAMPLE may result in different samples. To obtain the same sample, use the SET command to set the random number seed to the same value before each SAMPLE. By default, the random number seed is based on the system time.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.5 SELECT IF

 
SELECT IF expression.

The SELECT IF command is used to select particular cases for analysis based on the value of a boolean expression. Cases not selected are permanently eliminated, unless TEMPORARY is in effect (see section 13.7 TEMPORARY).

Specify a boolean expression (see section 8. Mathematical Expressions). If the value of the expression is true for a particular case, the case will be analyzed. If the expression has a false or missing value, then the case will be deleted from the data stream.

Always place SELECT IF commands as early in the command file as possible. Cases that are deleted early can be processed more efficiently in time and space.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.6 SPLIT FILE

 
Two possible syntaxes:
        SPLIT FILE BY var_list.
        SPLIT FILE OFF.

The SPLIT FILE command allows multiple sets of data present in one data file to be analyzed separately using single statistical procedure commands.

Specify a list of variable names in order to analyze multiple sets of data separately. Groups of cases having the same values for these variables are analyzed by statistical procedure commands as one group. An independent analysis is carried out for each group of cases, and the variable values for the group are printed along with the analysis.

Specify OFF in order to disable SPLIT FILE and resume analysis of the entire active file as a single group of data.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.7 TEMPORARY

 
TEMPORARY.

The TEMPORARY command is used to make the effects of transformations following its execution temporary. These transformations will affect only the execution of the next procedure or procedure-like command. Their effects will not be saved to the active file.

The only specification 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.

An example may help to clarify:

 
DATA LIST /X 1-2.
BEGIN DATA.
 2
 4
10
15
20
24
END DATA.
COMPUTE X=X/2.
TEMPORARY.
COMPUTE X=X+3.
DESCRIPTIVES X.
DESCRIPTIVES X.

The data read by the first DESCRIPTIVES command are 4, 5, 8, 10.5, 13, 15. The data read by the first DESCRIPTIVES command are 1, 2, 5, 7.5, 10, 12.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.8 WEIGHT

 
WEIGHT BY var_name.
WEIGHT OFF.

WEIGHT can be used to assign cases varying weights in order to change the frequency distribution of the active file. Execution of WEIGHT is delayed until data have been read in.

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 7.6.5 Scratch Variables).

When OFF is specified, subsequent statistical procedures will weight all cases equally.

Weighting values do not need to be integers. However, negative and system- and user-missing values for the weighting variable are interpreted as weighting factors of 0.

WEIGHT does not cause cases in the active file to be replicated in memory.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14. Conditional and Looping Constructs

This chapter documents PSPP commands used for conditional execution, looping, and flow of control.

14.1 BREAK  Exit a loop.
14.2 DO IF  Conditionally execute a block of code.
14.3 DO REPEAT  Textually repeat a code block.
14.4 LOOP  Repeat a block of code.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.1 BREAK

 
BREAK.

BREAK terminates execution of the innermost currently executing LOOP construct.

BREAK is allowed only inside a LOOP construct. See section 14.4 LOOP, for more details.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.2 DO IF

 
DO IF condition.
        ...
[ELSE IF condition.
        ...
]...
[ELSE.
        ...]
END IF.

The DO IF command allows one of several sets of transformations to be executed, depending on user-specified conditions.

Specify a boolean expression. If the condition is true, then the block of code following DO IF is executed. If the condition is missing, then none of the code blocks is executed. If the condition is false, then the boolean expressions on the first ELSE IF, if present, is tested in turn, with the same rules applied. If all expressions evaluate to false, then the ELSE code block is executed, if it is present.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.3 DO REPEAT

 
DO REPEAT repvar_name=expansion....
        ...
END REPEAT [PRINT].

expansion takes one of the following forms:
        var_list
        num_or_range...
        'string'...

num_or_range takes one of the following forms:
        number
        num1 TO num2

The DO REPEAT command causes a block of code to be repeated a number of times with different variables, numbers, or strings textually substituted into the block with each repetition.

Specify a repeat variable name followed by an equals sign (`=') and the list of replacements. Replacements can be a list of variables (which may be existing variables or new variables or a combination thereof), of numbers, or of strings. When new variable names are specified, DO REPEAT creates them as numeric variables. When numbers are specified, runs of integers may be indicated with TO notation, for instance `1 TO 5' and `1 2 3 4 5' would be equivalent. There is no equivalent notation for string values.

Multiple repeat variables can be specified. When this is done, each variable must have the same number of replacements.

The code within DO REPEAT is repeated as many times as there are replacements for each variable. The first time, the first value for each repeat variable is substituted; the second time, the second value for each repeat variable is substituted; and so on.

Repeat variable substitutions work like macros. They take place anywhere in a line that the repeat variable name occurs as a token, including command and subcommand names. For this reason it is not a good idea to select words commonly used in command and subcommand names as repeat variable identifiers.

If PRINT is specified on END REPEAT, the commands after substitutions are made are printed to the listing file, prefixed by a plus sign (`+').


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.4 LOOP

 
LOOP [index_var=start TO end [BY incr]] [IF condition].
        ...
END LOOP [IF condition].

The LOOP command allows a group of commands to be iterated. A number of termination options are offered.

Specify index_var in order 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 section 8. Mathematical Expressions.)

During the first iteration, index_var is set to the value of start. During each successive iteration, index_var is increased by the value of incr. If end > start, then the loop terminates when index_var > end; otherwise it terminates when index_var < end. If incr is not specified then it defaults to +1 or -1 as appropriate.

If end > start and incr < 0, or if end < start and incr > 0, then the loop is never executed. index_var is nevertheless set to the value of start.

Modifying index_var within the loop is allowed, but it has no effect on the value of index_var in the next iteration.

Specify a boolean expression for the condition on the LOOP command 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 clause is always evaluated first.

Specify a boolean expression for the condition on the END LOOP to cause the loop to terminate if the condition is not true after the enclosed code block is executed. The condition is evaluated at the end of the loop, not at the beginning.

If the index clause and both condition clauses are not present, then the loop is executed MXLOOPS (see section 16.10 SET) times or until BREAK (see section 14.1 BREAK) is executed.

The BREAK command provides another way to terminate execution of a LOOP construct.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15. Statistics

This chapter documents the statistical procedures that PSPP supports so far.

15.1 DESCRIPTIVES  Descriptive statistics.
15.2 FREQUENCIES  Frequency tables.
15.3 CROSSTABS  Crosstabulation tables.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 file and outputs descriptive statistics requested by the user. In addition, it can optionally compute Z-scores.

The VARIABLES subcommand, which is required, specifies the list of variables to be analyzed. Keyword VARIABLES is optional.

All other subcommands are optional:

The MISSING subcommand determines the handling of missing variables. If INCLUDE is set, then user-missing values are included in the calculations. If NOINCLUDE is set, which is the default, user-missing values are excluded. If VARIABLE is set, then missing values are excluded on a variable by variable basis; if LISTWISE is set, then the entire case is excluded whenever any value in that case has a system-missing or, if INCLUDE is set, user-missing value.

The FORMAT subcommand affects the output format. Currently the LABELS/NOLABELS and NOINDEX/INDEX settings is not used. When SERIAL is set, both valid and missing number of cases are listed in the output; when NOSERIAL is set, only valid cases are listed.

The SAVE subcommand causes DESCRIPTIVES to calculate Z scores for all the specified variables. The Z scores are saved to new variables. Variable names are generated by trying first the original variable name with Z prepended and truncated to a maximum of 8 characters, then the names ZSC000 through ZSC999, STDZ00 through STDZ09, ZZZZ00 through ZZZZ09, ZQZQ00 through ZQZQ09, in that sequence. In addition, Z score variable names can be specified explicitly on VARIABLES in the variable list by enclosing them in parentheses after each variable.

The STATISTICS subcommand specifies the statistics to be displayed:

ALL
All of the statistics below.
MEAN
Arithmetic mean.
SEMEAN
Standard error of the mean.
STDDEV
Standard deviation.
VARIANCE
Variance.
KURTOSIS
Kurtosis and standard error of the kurtosis.
SKEWNESS
Skewness and standard error of the skewness.
RANGE
Range.
MINIMUM
Minimum value.
MAXIMUM
Maximum value.
SUM
Sum.
DEFAULT
Mean, standard deviation of the mean, minimum, maximum.
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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15.2 FREQUENCIES

 
FREQUENCIES
        /VARIABLES=var_list
        /FORMAT={TABLE,NOTABLE,LIMIT(limit)}
                {STANDARD,CONDENSE,ONEPAGE[(onepage_limit)]}
                {LABELS,NOLABELS}
                {AVALUE,DVALUE,AFREQ,DFREQ}
                {SINGLE,DOUBLE}
                {OLDPAGE,NEWPAGE}
        /MISSING={EXCLUDE,INCLUDE}
        /STATISTICS={DEFAULT,MEAN,SEMEAN,MEDIAN,MODE,STDDEV,VARIANCE,
                     KURTOSIS,SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,
                     SESKEWNESS,SEKURTOSIS,ALL,NONE}
        /NTILES=ntiles
        /PERCENTILES=percent...

(These options are not currently implemented.)
        /BARCHART=...
        /HISTOGRAM=...
        /HBAR=...
        /GROUPED=...

(Integer mode.)
        /VARIABLES=var_list (low,high)...

FREQUENCIES causes the data to be read and frequency tables to be built and output for specified variables. FREQUENCIES can also calculate and display descriptive statistics (including median and mode) and percentiles.

In the future, FREQUENCIES will also support graphical output in the form of bar charts and histograms. In addition, it will be able to support percentiles for grouped data. (As a historical note, these options were supported in a version of PSPP written years ago, but the code has not survived.)

The VARIABLES subcommand is the only required subcommand. Specify the variables to be analyzed. In most cases, this is all that is required. This is known as general mode.

Occasionally, one may want to invoke a special mode called integer mode. Normally, in general mode, PSPP will automatically determine 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 a range of data values in parentheses, separated by a comma. 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.

The FORMAT subcommand controls the output format. It has several possible settings:

The MISSING subcommand controls the handling of user-missing values. When EXCLUDE, the default, is set, user-missing values are not included in frequency tables or statistics. When INCLUDE is set, user-missing are included. System-missing values are never included in statistics, but are listed in frequency tables.

The available STATISTICS are the same as available in DESCRIPTIVES (see section 15.1 DESCRIPTIVES), with the addition of MEDIAN, the data's median value, and MODE, the mode. (If there are multiple modes, the smallest value is reported.) By default, the mean, standard deviation of the mean, minimum, and maximum are reported for each variable.

NTILES causes the specified quartiles to be reported. For instance, /NTILES=4 would cause quartiles to be reported. In addition, particular percentiles can be requested with the PERCENTILES subcommand.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15.3 CROSSTABS

 
CROSSTABS
        /TABLES=var_list BY var_list [BY var_list]...
        /MISSING={TABLE,INCLUDE,REPORT}
        /WRITE={NONE,CELLS,ALL}
        /FORMAT={TABLES,NOTABLES}
                {LABELS,NOLABELS,NOVALLABS}
                {PIVOT,NOPIVOT}
                {AVALUE,DVALUE}
                {NOINDEX,INDEX}
                {BOX,NOBOX}
        /CELLS={COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
                ASRESIDUAL,ALL,NONE}
        /STATISTICS={CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
                     KAPPA,ETA,CORR,ALL,NONE}
        
(Integer mode.)
        /VARIABLES=var_list (low,high)...

CROSSTABS reads the active file and builds and displays crosstabulation tables requested by the user. It can calculate several statistics for each cell in the crosstabulation tables. In addition, a number of statistics can be calculated for each table itself.

The TABLES subcommand is used to specify the tables to be reported. Any number of dimensions is permitted, and any number of variables per dimension is allowed. The TABLES subcommand may be repeated as many times as needed. This is the only required subcommand in general mode.

Occasionally, one may want to invoke a special mode called integer mode. Normally, in general mode, PSPP will automatically determine 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.

The MISSING subcommand determines the handling of user-missing values. When set to TABLE, the default, missing values are dropped on a table by table basis. When set to INCLUDE, user-missing values are included in tables and statistics. When set to REPORT, which is allowed only in integer mode, user-missing values are included in tables but marked with an `M' (for "missing") and excluded from statistical calculations.

Currently the WRITE subcommand is not used.

The FORMAT subcommand controls the characteristics of the crosstabulation tables to be displayed. It has a number of possible settings:

The CELLS subcommand controls the contents of each cell in the displayed crosstabulation table. The possible settings are:

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.

`/CELLS' without any settings specified requests COUNT, ROW, COLUMN, and TOTAL. If CELLS is not specified at all then only COUNT will be selected.

The STATISTICS subcommand selects statistics for computation:

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.

Please note: Currently the implementation of CROSSTABS has the followings bugs:

Fix for any of these deficiencies would be welcomed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16. 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.

16.1 COMMENT  Document your syntax file.
16.2 DOCUMENT  Document the active file.
16.3 DISPLAY DOCUMENTS  Display active file documents.
16.4 DISPLAY FILE LABEL  Display the active file label.
16.5 DROP DOCUMENTS  Remove documents from the active file.
16.6 EXECUTE  Execute pending transformations.
16.7 FILE LABEL  Set the active file's label.
16.8 INCLUDE  Include a file within the current one.
16.9 QUIT  Terminate the PSPP session.
16.10 SET  Adjust PSPP runtime parameters.
16.11 SUBTITLE  Provide a document subtitle.
10.7 SYSFILE INFO  Display the dictionary in a system file.
16.12 TITLE  Provide a document title.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.1 COMMENT

 
Two possibles syntaxes:
        COMMENT comment text ... .
        *comment text ... .

The COMMENT command is ignored. It is used to provide information to the author and other readers of the PSPP syntax file.

A COMMENT command can extend over any number of lines. Don't forget to terminate it with a dot or a blank line!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.2 DOCUMENT

 
DOCUMENT documentary_text.

The DOCUMENT command adds one or more lines of descriptive commentary to the active file. Documents added in this way are saved to system files. They can be viewed using SYSFILE INFO or DISPLAY DOCUMENTS. They can be removed from the active file with DROP DOCUMENTS.

Specify the documentary text following the DOCUMENT keyword. You can extend the documentary text over as many lines as necessary. Lines are truncated at 80 characters width. Don't forget to terminate the DOCUMENT command with a dot or a blank line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.3 DISPLAY DOCUMENTS

 
DISPLAY DOCUMENTS.

DISPLAY DOCUMENTS displays the documents in the active file. Each document is preceded by a line giving the time and date that it was added. See section 16.2 DOCUMENT.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.4 DISPLAY FILE LABEL

 
DISPLAY FILE LABEL.

DISPLAY FILE LABEL displays the file label contained in the active file, if any. See section 16.7 FILE LABEL.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.5 DROP DOCUMENTS

 
DROP DOCUMENTS.

The DROP DOCUMENTS command removes all documents from the active file. New documents can be added with the DOCUMENT utility (see section 16.2 DOCUMENT).

DROP DOCUMENTS only changes the active file. It does not modify any system files stored on disk.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.6 EXECUTE

 
EXECUTE.

The EXECUTE utility causes the active file to be read and all pending transformations to be executed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.7 FILE LABEL

 
FILE LABEL file_label.

Use the FILE LABEL command to provide a title for the active file. This title will be saved into system files and portable files that are created during this PSPP run.

It is not necessary to include quotes around file_label. If they are included then they become part of the file label.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.8 INCLUDE

 
Two possible syntaxes:
        INCLUDE 'filename'.
        @filename.

The INCLUDE command causes the PSPP command processor to read an additional command file as if it were included bodily in the current command file.

INCLUDE files may be nested to any depth, up to the limit of available memory.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.9 QUIT

 
Two possible syntaxes:
        QUIT.
        EXIT.

The QUIT command terminates the current PSPP session and returns control to the operating system.

This command is not valid within a command file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.10 SET

 
SET

(data input)
        /BLANKS={SYSMIS,'.',number}
        /DECIMAL={DOT,COMMA}
        /FORMAT=fmt_spec

(program input)
        /ENDCMD='.'
        /NULLINE={ON,OFF}

(interaction)
        /CPROMPT='cprompt_string'
        /DPROMPT='dprompt_string'
        /ERRORBREAK={OFF,ON}
        /MXERRS=max_errs
        /MXWARNS=max_warnings
        /PROMPT='prompt'
        /VIEWLENGTH={MINIMUM,MEDIAN,MAXIMUM,n_lines}
        /VIEWWIDTH=n_characters

(program execution)
        /MEXPAND={ON,OFF}
        /MITERATE=max_iterations
        /MNEST=max_nest
        /MPRINT={ON,OFF}
        /MXLOOPS=max_loops
        /SEED={RANDOM,seed_value}
        /UNDEFINED={WARN,NOWARN}

(data output)
        /CC{A,B,C,D,E}={'npre,pre,suf,nsuf','npre.pre.suf.nsuf'}
        /DECIMAL={DOT,COMMA}
        /FORMAT=fmt_spec

(output routing)
        /ECHO={ON,OFF}
        /ERRORS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
        /INCLUDE={ON,OFF}
        /MESSAGES={ON,OFF,TERMINAL,LISTING,BOTH,NONE}
        /PRINTBACK={ON,OFF}
        /RESULTS={ON,OFF,TERMINAL,LISTING,BOTH,NONE}

(output activation)
        /LISTING={ON,OFF}
        /PRINTER={ON,OFF}
        /SCREEN={ON,OFF}

(output driver options)
        /HEADERS={NO,YES,BLANK}
        /LENGTH={NONE,length_in_lines}
        /LISTING=filename
        /MORE={ON,OFF}
        /PAGER={OFF,"pager_name"}
        /WIDTH={NARROW,WIDTH,n_characters}

(logging)
        /JOURNAL={ON,OFF} [filename]
        /LOG={ON,OFF} [filename]

(system files)
        /COMPRESSION={ON,OFF}
        /SCOMPRESSION={ON,OFF}

(security)
        /SAFER=ON

(obsolete settings accepted for compatibility, but ignored)
        /AUTOMENU={ON,OFF}
        /BEEP={ON,OFF}
        /BLOCK='c'
        /BOXSTRING={'xxx','xxxxxxxxxxx'}
        /CASE={UPPER,UPLOW}
        /COLOR=...
        /CPI=cpi_value
        /DISK={ON,OFF}
        /EJECT={ON,OFF}
        /HELPWINDOWS={ON,OFF}
        /HIGHRES={ON,OFF}
        /HISTOGRAM='c'
        /LOWRES={AUTO,ON,OFF}
        /LPI=lpi_value
        /MENUS={STANDARD,EXTENDED}
        /MXMEMORY=max_memory
        /PTRANSLATE={ON,OFF}
        /RCOLORS=...
        /RUNREVIEW={AUTO,MANUAL}
        /SCRIPTTAB='c'
        /TB1={'xxx','xxxxxxxxxxx'}
        /TBFONTS='string'
        /WORKDEV=drive_letter
        /WORKSPACE=workspace_size
        /XSORT={YES,NO}

The SET command allows the user to adjust several parameters relating to PSPP's execution. Since there are many subcommands to this command, its subcommands will be examined in groups.

As a general comment, ON and YES are considered synonymous, and so 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 whitespace. An argument of SYSMIS or '.' will cause the system-missing value to be assigned to null items. This is the default. Any real value may be assigned.

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 7.6.4 Input and Output Formats.

Program input subcommands affect the way that programs are parsed when they are typed interactively or run from a script. They are

ENDCMD
This is a single character indicating the end of a command. The default is `.'. Don't change this.

NULLINE
Whether a blank line is interpreted as ending the current command. The default is ON.

Interaction subcommands affect the way that PSPP interacts with an online user. The interaction subcommands are

CPROMPT
The command continuation prompt. The default is ` > '.

DPROMPT
Prompt used when expecting data input within BEGIN DATA (see section 9.1 BEGIN DATA). The default is `data> '.

ERRORBREAK
Whether an error causes PSPP to stop processing the current command file after finishing the current command. The default is OFF.

MXERRS
The maximum number of errors before PSPP halts processing of the current command file. The default is 50.

MXWARNS
The maximum number of warnings + errors before PSPP halts processing the current command file. The default is 100.

PROMPT
The command prompt. The default is `PSPP> '.

VIEWLENGTH
The length of the screen in lines. MINIMUM means 25 lines, MEDIAN and MAXIMUM mean 43 lines. Otherwise specify the number of lines. Normally PSPP should auto-detect your screen size so this shouldn't have to be used.

VIEWWIDTH
The width of the screen in characters. Normally 80 or 132.

Program execution subcommands control the way that PSPP commands execute. The program execution subcommands are

MEXPAND
MITERATE
MNEST
MPRINT
Currently not used.

MXLOOPS
The maximum number of iterations for an uncontrolled loop.

SEED
The initial pseudo-random number seed. Set to a real number or to RANDOM, which will obtain an initial seed from the current time of day.

UNDEFINED
Currently not used.

Data output subcommands affect the format of output data. These subcommands are

CCA
CCB
CCC
CCD
CCE
Set up custom currency formats. The argument is a string which must contain exactly three commas or exactly three periods. If commas, then the grouping character for the currency format is `,', and the decimal point character is `.'; if periods, then the situation is reversed.

The commas or periods divide the string into four fields, which are, in order, the negative prefix, prefix, suffix, and negative suffix. When a value is formatted using the custom currency format, the prefix precedes the value formatted and the suffix follows it. In addition, if the value is negative, the negative prefix precedes the prefix and the negative suffix follows the suffix.

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 7.6.4 Input and Output Formats.

Output routing subcommands affect where the output of transformations and procedures is sent. These subcommands are

ECHO

If turned on, commands are written to the listing file as they are read from command files. The default is OFF.

ERRORS
INCLUDE
MESSAGES
PRINTBACK
RESULTS
Currently not used.

Output activation subcommands affect whether output devices of particular types are enabled. These subcommands are

LISTING
Enable or disable listing devices.

PRINTER
Enable or disable printer devices.

SCREEN
Enable or disable screen devices.

Output driver option subcommands affect output drivers' settings. These subcommands are

HEADERS
LENGTH
LISTING
MORE
PAGER
WIDTH
Currently not used.

Logging subcommands affect logging of commands executed to external files. These subcommands are

JOURNAL
LOG
Not currently used.

System file subcommands affect the default format of system files produced by PSPP. These subcommands are

COMPRESSION
Not currently used.

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
When set, this setting cannot ever be reset, for obvious security reasons. Setting this option disables the following operations:

Be aware that this setting does not guarantee safety (commands can still overwrite files, for instance) but it is an improvement.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.11 SUBTITLE

 
Two possible syntaxes:
        SUBTITLE 'subtitle_string'.
        SUBTITLE subtitle_string.

The SUBTITLE command is used to provide a subtitle to a particular PSPP run. This subtitle appears at the top of each output page below the title, if titles 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.12 TITLE

 
Two possible syntaxes:
        TITLE 'title_string'.
        TITLE title_string.

The TITLE command is used to provide a title to a particular PSPP run. This title appears at the top of each output page, if titles 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17. Not Implemented

This chapter lists parts of the PSPP language that are not yet implemented.

The following transformations and utilities are not yet implemented, but they will be supported in a later release.

The following transformations and utilities are not implemented. There are no plans to support them in future releases. Contributions to implement them will still be accepted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18. Data File Format

PSPP necessarily uses the same format for system files as do the products with which it is compatible. This chapter is a description of that format.

There are three data types used in system files: 32-bit integers, 64-bit floating points, and 1-byte characters. In this document these will simply be referred to as int32, flt64, and char, the names that are used in the PSPP source code. Every field of type int32 or flt64 is aligned on a 32-bit boundary.

The endianness of data in PSPP system files is not specified. System files output on a computer of a particular endianness will have the endianness of that computer. However, PSPP can read files of either endianness, regardless of its host computer's endianness. PSPP translates endianness for both integer and floating point numbers.

Floating point formats are also not specified. PSPP does not translate between floating point formats. This is unlikely to be a problem as all modern computer architectures use IEEE 754 format for floating point representation.

The PSPP system-missing value is represented by the largest possible negative number in the floating point format; in C, this is most likely -DBL_MAX. There are two other important values used in missing values: HIGHEST and LOWEST. These are represented by the largest possible positive number (probably DBL_MAX) and the second-largest negative number. The latter must be determined in a system-dependent manner; in IEEE 754 format it is represented by value 0xffeffffffffffffe.

System files are divided into records. Each record begins with an int32 giving a numeric record type. Individual record types are described below:

18.1 File Header Record  
18.2 Variable Record  
18.3 Value Label Record  
18.4 Value Label Variable Record  
18.5 Document Record  
18.6 Machine int32 Info Record  
18.7 Machine flt64 Info Record  
18.8 Miscellaneous Informational Records  
18.9 Dictionary Termination Record  
18.10 Data Record  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.1 File Header Record

The file header is always the first record in the file.

 
struct sysfile_header
  {
    char                rec_type[4];
    char                prod_name[60];
    int32               layout_code;
    int32               case_size;
    int32               compressed;
    int32               weight_index;
    int32               ncases;
    flt64               bias;
    char                creation_date[9];
    char                creation_time[8];
    char                file_label[64];
    char                padding[3];
  };

char rec_type[4];
Record type code. Always set to `$FL2'. This is the only record for which the record type is not of type int32.

char prod_name[60];
Product identification string. This always begins with the characters `@(#) SPSS DATA FILE'. PSPP uses the remaining characters to give its version and the operating system name; for example, `GNU pspp 0.1.4 - sparc-sun-solaris2.5.2'. The string is truncated if it would be longer than 60 characters; otherwise it is padded on the right with spaces.

int32 layout_code;
Always set to 2. PSPP reads this value in order to determine the file's endianness.

int32 case_size;
Number of data elements per case. This is the number of variables, except that long string variables add extra data elements (one for every 8 characters after the first 8).

int32 compressed;
Set to 1 if the data in the file is compressed, 0 otherwise.

int32 weight_index;
If one of the variables in the data set is used as a weighting variable, set to the index of that variable. Otherwise, set to 0.

int32 ncases;
Set to the number of cases in the file if it is known, or -1 otherwise.

In the general case it is not possible to determine the number of cases that will be output to a system file at the time that the header is written. The way that this is dealt with is by writing the entire system file, including the header, then seeking back to the beginning of the file and writing just the ncases field. For `files' in which this is not valid, the seek operation fails. In this case, ncases remains -1.

flt64 bias;
Compression bias. Always set to 100. The significance of this value is that only numbers between (1 - bias) and (251 - bias) can be compressed.

char creation_date[9];
Set to the date of creation of the system file, in `dd mmm yy' format, with the month as standard English abbreviations, using an initial capital letter and following with lowercase. If the date is not available then this field is arbitrarily set to `01 Jan 70'.

char creation_time[8];
Set to the time of creation of the system file, in `hh:mm:ss' format and using 24-hour time. If the time is not available then this field is arbitrarily set to `00:00:00'.

char file_label[64];
Set the the file label declared by the user, if any. Padded on the right with spaces.

char padding[3];
Ignored padding bytes to make the structure a multiple of 32 bits in length. Set to zeros.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.2 Variable Record

Immediately following the header must come the variable records. There must be one variable record for every variable and every 8 characters in a long string beyond the first 8; i.e., there must be exactly as many variable records as the value specified for case_size in the file header record.

 
struct sysfile_variable
  {
    int32               rec_type;
    int32               type;
    int32               has_var_label;
    int32               n_missing_values;
    int32               print;
    int32               write;
    char                name[8];

    /* The following two fields are present 
       only if has_var_label is 1. */
    int32               label_len;
    char                label[/* variable length */];

    /* The following field is present only
       if n_missing_values is not 0. */
    flt64               missing_values[/* variable length*/];
  };

int32 rec_type;
Record type code. Always set to 2.

int32 type;
Variable type code. Set to 0 for a numeric variable. For a short string variable or the first part of a long string variable, this is set to the width of the string. For the second and subsequent parts of a long string variable, set to -1, and the remaining fields in the structure are ignored.

int32 has_var_label;
If this variable has a variable label, set to 1; otherwise, set to 0.

int32 n_missing_values;
If the variable has no missing values, set to 0. If the variable has one, two, or three discrete missing values, set to 1, 2, or 3, respectively. If the variable has a range for missing variables, set to -2; if the variable has a range for missing variables plus a single discrete value, set to -3.

int32 print;
Print format for this variable. See below.

int32 write;
Write format for this variable. See below.

char name[8];
Variable name. The variable name must begin with a capital letter or the at-sign (`@'). Subsequent characters may also be octothorpes (`#'), dollar signs (`$'), underscores (`_'), or full stops (`.'). The variable name is padded on the right with spaces.

int32 label_len;
This field is present only if has_var_label is set to 1. It is set to the length, in characters, of the variable label, which must be a number between 0 and 120.

char label[/* variable length */];
This field is present only if has_var_label is set to 1. It has length label_len, rounded up to the nearest multiple of 32 bits. The first label_len characters are the variable's variable label.

flt64 missing_values[/* variable length */];
This field is present only if n_missing_values is not 0. It has the same number of elements as the absolute value of n_missing_values. For discrete missing values, each element represents one missing value. When a range is present, the first element denotes the minimum value in the range, and the second element denotes the maximum value in the range. When a range plus a value are present, the third element denotes the additional discrete missing value. HIGHEST and LOWEST are indicated as described in the chapter introduction.

The print and write members of sysfile_variable are output formats coded into int32 types. The LSB (least-significant byte) of the int32 represents the number of decimal places, and the next two bytes in order of increasing significance represent field width and format type, respectively. The MSB (most-significant byte) is not used and should be set to zero.

Format types are defined as follows:

0
Not used.
1
A
2
AHEX
3
COMMA
4
DOLLAR
5
F
6
IB
7
PIBHEX
8
P
9
PIB
10
PK
11
RB
12
RBHEX
13
Not used.
14
Not used.
15
Z
16
N
17
E
18
Not used.
19
Not used.
20
DATE
21
TIME
22
DATETIME
23
ADATE
24
JDATE
25
DTIME
26
WKDAY
27
MONTH
28
MOYR
29
QYR
30
WKYR
31
PCT
32
DOT
33
CCA
34
CCB
35
CCC
36
CCD
37
CCE
38
EDATE
39
SDATE


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.3 Value Label Record

Value label records must follow the variable records and must precede the header termination record. Other than this, they may appear anywhere in the system file. Every value label record must be immediately followed by a label variable record, described below.

Value label records begin with rec_type, an int32 value set to the record type of 3. This is followed by count, an int32 value set to the number of value labels present in this record.

These two fields are followed by a series of count tuples. Each tuple is divided into two fields, the value and the label. The first of these, the value, is composed of a 64-bit value, which is either a flt64 value or up to 8 characters (padded on the right to 8 bytes) denoting a short string value. Whether the value is a flt64 or a character string is not defined inside the value label record.

The second field in the tuple, the label, has variable length. The first char is a count of the number of characters in the value label. The remainder of the field is the label itself. The field is padded on the right to a multiple of 64 bits in length.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.4 Value Label Variable Record

Every value label variable record must be immediately preceded by a value label record, described above.

 
struct sysfile_value_label_variable
  {
     int32              rec_type;
     int32              count;
     int32              vars[/* variable length */];
  };

int32 rec_type;
Record type. Always set to 4.

int32 count;
Number of variables that the associated value labels from the value label record are to be applied.

int32 vars[/* variable length];
A list of variables to which to apply the value labels. There are count elements.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.5 Document Record

There must be no more than one document record per system file. Document records must follow the variable records and precede the dictionary termination record.

 
struct sysfile_document
  {
    int32               rec_type;
    int32               n_lines;
    char                lines[/* variable length */][80];
  };

int32 rec_type;
Record type. Always set to 6.

int32 n_lines;
Number of lines of documents present.

char lines[/* variable length */][80];
Document lines. The number of elements is defined by n_lines. Lines shorter than 80 characters are padded on the right with spaces.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.6 Machine int32 Info Record

There must be no more than one machine int32 info record per system file. Machine int32 info records must follow the variable records and precede the dictionary termination record.

 
struct sysfile_machine_int32_info
  {
    /* Header. */
    int32               rec_type;
    int32               subtype;
    int32               size;
    int32               count;

    /* Data. */
    int32               version_major;
    int32               version_minor;
    int32               version_revision;
    int32               machine_code;
    int32               floating_point_rep;
    int32               compression_code;
    int32               endianness;
    int32               character_code;
  };

int32 rec_type;
Record type. Always set to 7.

int32 subtype;
Record subtype. Always set to 3.

int32 size;
Size of each piece of data in the data part, in bytes. Always set to 4.

int32 count;
Number of pieces of data in the data part. Always set to 8.

int32 version_major;
PSPP major version number. In version x.y.z, this is x.

int32 version_minor;
PSPP minor version number. In version x.y.z, this is y.

int32 version_revision;
PSPP version revision number. In version x.y.z, this is z.

int32 machine_code;
Machine code. PSPP always set this field to value to -1, but other values may appear.

int32 floating_point_rep;
Floating point representation code. For IEEE 754 systems this is 1. IBM 370 sets this to 2, and DEC VAX E to 3.

int32 compression_code;
Compression code. Always set to 1.

int32 endianness;
Machine endianness. 1 indicates big-endian, 2 indicates little-endian.

int32 character_code;
Character code. 1 indicates EBCDIC, 2 indicates 7-bit ASCII, 3 indicates 8-bit ASCII, 4 indicates DEC Kanji.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.7 Machine flt64 Info Record

There must be no more than one machine flt64 info record per system file. Machine flt64 info records must follow the variable records and precede the dictionary termination record.

 
struct sysfile_machine_flt64_info
  {
    /* Header. */
    int32               rec_type;
    int32               subtype;
    int32               size;
    int32               count;

    /* Data. */
    flt64               sysmis;
    flt64               highest;
    flt64               lowest;
  };

int32 rec_type;
Record type. Always set to 3.

int32 subtype;
Record subtype. Always set to 4.

int32 size;
Size of each piece of data in the data part, in bytes. Always set to 4.

int32 count;
Number of pieces of data in the data part. Always set to 3.

flt64 sysmis;
The system missing value.

flt64 highest;
The value used for HIGHEST in missing values.

flt64 lowest;
The value used for LOWEST in missing values.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.8 Miscellaneous Informational Records

Miscellaneous informational records must follow the variable records and precede the dictionary termination record.

Miscellaneous informational records are ignored by PSPP when reading system files. They are not written by PSPP when writing system files.

 
struct sysfile_misc_info
  {
    /* Header. */
    int32               rec_type;
    int32               subtype;
    int32               size;
    int32               count;

    /* Data. */
    char                data[/* variable length */];
  };

int32 rec_type;
Record type. Always set to 3.

int32 subtype;
Record subtype. May take any value.

int32 size;
Size of each piece of data in the data part. Should have the value 4 or 8, for int32 and flt64, respectively.

int32 count;
Number of pieces of data in the data part.

char data[/* variable length */];
Arbitrary data. There must be size times count bytes of data.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.9 Dictionary Termination Record

The dictionary termination record must follow all other records, except for the actual cases, which it must precede. There must be exactly one dictionary termination record in every system file.

 
struct sysfile_dict_term
  {
    int32               rec_type;
    int32               filler;
  };

int32 rec_type;
Record type. Always set to 999.

int32 filler;
Ignored padding. Should be set to 0.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.10 Data Record

Data records must follow all other records in the data file. There must be at least one data record in every system file.

The format of data records varies depending on whether the data is compressed. Regardless, the data is arranged in a series of 8-byte elements.

When data is not compressed, Every case is composed of case_size of these 8-byte elements, where case_size comes from the file header record (see section 18.1 File Header Record). Each element corresponds to the variable declared in the respective variable record (see section 18.2 Variable Record). Numeric values are given in flt64 format; string values are literal characters string, padded on the right when necessary.

Compressed data is arranged in the following manner: the first 8-byte element in the data section is divided into a series of 1-byte command codes. These codes have meanings as described below:

0
Ignored. If the program writing the system file accumulates compressed data in blocks of fixed length, 0 bytes can be used to pad out extra bytes remaining at the end of a fixed-size block.

1 through 251
These values indicate that the corresponding numeric variable has the value (code - bias) for the case being read, where code is the value of the compression code and bias is the variable compression_bias from the file header. For example, code 105 with bias 100.0 (the normal value) indicates a numeric variable of value 5.

252
End of file. This code may or may not appear at the end of the data stream. PSPP always outputs this code but its use is not required.

253
This value indicates that the numeric or string value is not compressible. The value is stored in the 8-byte element following the current block of command bytes. If this value appears twice in a block of command bytes, then it indicates the second element following the command bytes, and so on.

254
Used to indicate a string value that is all spaces.

255
Used to indicate the system-missing value.

When the end of the first 8-byte element of command bytes is reached, any blocks of non-compressible values are skipped, and the next element of command bytes is read and interpreted, until the end of the file is reached.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19. Portable File Format

These days, most computers use the same internal data formats for integer and floating-point data, if one ignores little differences like big- versus little-endian byte ordering. However, occasionally it is necessary to exchange data between systems with incompatible data formats. This is what portable files are designed to do.

Please note: Although all of the following information is correct, as far as the author has been able to ascertain, it is gleaned from examination of ASCII-formatted portable files only, so some of it may be incorrect in the general case.

19.1 Portable File Characters  
19.2 Portable File Structure  
19.3 Portable File Header  
19.4 Version and Date Info Record  
19.5 Identification Records  
19.6 Variable Count Record  
19.7 Variable Records  
19.8 Value Label Records  
19.9 Portable File Data  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.1 Portable File Characters

Portable files are arranged as a series of lines of exactly 80 characters each. Each line is terminated by a carriage-return, line-feed sequence (henceforth, "newline"). Newlines are not delimiters: they are only used to avoid line-length limitations existing on some operating systems.

The file must be terminated with a `Z' character. In addition, if the final line in the file does not have exactly 80 characters, then it is padded on the right with `Z' characters. (The file contents may be in any character set; the file contains a description of its own character set, as explained in the next section. Therefore, the `Z' character is not necessarily an ASCII `Z'.)

For the rest of the description of the portable file format, newlines and the trailing `Z's will be ignored, as if they did not exist, because they are not an important part of understanding the file contents.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.2 Portable File Structure

Every portable file consists of the following records, in sequence:

Most records are identified by a single-character tag code. The file header and version info record do not have a tag.

Other than these single-character codes, there are three types of fields in a portable file: floating-point, integer, and string. Floating-point fields have the following format:

Integer fields take form identical to floating-point fields, but they may not contain a fraction.

String fields take the form of a integer field having value n, followed by exactly n characters, which are the string content.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.3 Portable File Header

Every portable file begins with a 464-byte header, consisting of a 200-byte collection of vanity splash strings, followed by a 256-byte character set translation table, followed by an 8-byte tag string.

The 200-byte segment is divided into five 40-byte sections, each of which represents the string ASCII SPSS PORT FILE in a different character set encoding. (If the file is encoded in EBCDIC then the string is actually EBCDIC SPSS PORT FILE, and so on.) These strings are padded on the right with spaces in their own character set.

It appears that these strings exist only to inform those who might view the file on a screen, and that they are not parsed by SPSS products. Thus, they can be safely ignored. For those interested, the strings are supposed to be in the following character sets, in the specified order: EBCDIC, 7-bit ASCII, CDC 6-bit ASCII, 6-bit ASCII, Honeywell 6-bit ASCII.

The 256-byte segment describes a mapping from the character set used in the portable file to an arbitrary character set having characters at the following positions:

0--60

Control characters. Not important enough to describe in full here.

61--63

Reserved.

64--73

Digits `0' through `9'.

74--99

Capital letters `A' through `Z'.

100--125

Lowercase letters `a' through `z'.

126

Space.

127--130

Symbols .<(+

131

Solid vertical pipe.

132--142

Symbols &[]!$*);^-/

143

Broken vertical pipe.

144--150

Symbols ,%_>?`:

151

British pound symbol.

152--155

Symbols @'=".

156

Less than or equal symbol.

157

Empty box.

158

Plus or minus.

159

Filled box.

160

Degree symbol.

161

Dagger.

162

Symbol `~'.

163

En dash.

164

Lower left corner box draw.

165

Upper left corner box draw.

166

Greater than or equal symbol.

167--176

Superscript `0' through `9'.

177

Lower right corner box draw.

178

Upper right corner box draw.

179

Not equal symbol.

180

Em dash.

181

Superscript `('.

182

Superscript `)'.

183

Horizontal dagger (?).

184--186

Symbols `{}\'.

187

Cents symbol.

188

Centered dot, or bullet.

189--255

Reserved.

Symbols that are not defined in a particular character set are set to the same value as symbol 64; i.e., to `0'.

The 8-byte tag string consists of the exact characters SPSSPORT in the portable file's character set, which can be used to verify that the file is indeed a portable file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.4 Version and Date Info Record

This record does not have a tag code. It has the following structure:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.5 Identification Records

The product identification record has tag code `1'. It consists of a single string field giving the name of the product that wrote the portable file.

The subproduct identification record has tag code `3'. It consists of a single string field giving additional information on the product that wrote the portable file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.6 Variable Count Record

The variable count record has tag code `4'. It consists of two integer fields. The first contains the number of variables in the file dictionary. The purpose of the second is unknown; it contains the value 161 in all portable files examined so far.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.7 Variable Records

Each variable record represents a single variable. Variable records have tag code `7'. They have the following structure:

Each variable record can optionally be followed by a missing value record, which has tag code `8'. A missing value record has one field, the missing value itself (a floating-point or string, as appropriate). Up to three of these missing value records can be used.

There is also a record for missing value ranges, which has tag code `B'. It is followed by two fields representing the range, which are floating-point or string as appropriate. If a missing value range is present, it may be followed by a single missing value record.

Tag codes `9' and `A' represent LO THRU x and x THRU HI ranges, respectively. Each is followed by a single field representing x. If one of the ranges is present, it may be followed by a single missing value record.

In addition, each variable record can optionally be followed by a variable label record, which has tag code `C'. A variable label record has one field, the variable label itself (string).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.8 Value Label Records

Value label records have tag code `D'. They have the following format:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.9 Portable File Data

The data record has tag code `F'. There is only one tag for all the data; thus, all the data must follow the dictionary. The data is terminated by the end-of-file marker `Z', which is not valid as the beginning of a data element.

Data elements are output in the same order as the variable records describing them. String variables are output as string fields, and numeric variables are output as floating-point fields.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20. q2c Input Format

PSPP statistical procedures have a bizarre and somewhat irregular syntax. Despite this, a parser generator has been written that adequately addresses many of the possibilities and tries to provide hooks for the exceptional cases. This parser generator is named q2c.

20.1 Invoking q2c  q2c command-line syntax.
20.2 q2c Input Structure  High-level layout of the input file.
20.3 Grammar Rules  Syntax of the grammar rules.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.1 Invoking q2c

 
q2c input.q output.c

q2c translates a `.q' file into a `.c' file. It takes exactly two command-line arguments, which are the input file name and output file name, respectively. q2c does not accept any command-line options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.2 q2c Input Structure

q2c input files are divided into two sections: the grammar rules and the supporting code. The grammar rules, which make up the first part of the input, are used to define the syntax of the statistical procedure to be parsed. The supporting code, following the grammar rules, are copied largely unchanged to the output file, except for certain escapes.

The most important lines in the grammar rules are used for defining procedure syntax. These lines can be prefixed with a dollar sign (`$'), which prevents Emacs' CC-mode from munging them. Besides this, a bang (`!') at the beginning of a line causes the line, minus the bang, to be written verbatim to the output file (useful for comments). As a third special case, any line that begins with the exact characters /* *INDENT is ignored and not written to the output. This allows .q files to be processed through indent without being munged.

The syntax of the grammar rules themselves is given in the following sections.

The supporting code is passed into the output file largely unchanged. However, the following escapes are supported. Each escape must appear on a line by itself.

/* (header) */

Expands to a series of C #include directives which include the headers that are required for the parser generated by q2c.

/* (decls scope) */

Expands to C variable and data type declarations for the variables and enums input and output by the q2c parser. scope must be either local or global. local causes the declarations to be output as function locals. global causes them to be declared as static module variables; thus, global is a bit of a misnomer.

/* (parser) */

Expands to the entire parser. Must be enclosed within a C function.

/* (free) */

Expands to a set of calls to the free function for variables declared by the parser. Only needs to be invoked if subcommands of type string are used in the grammar rules.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.3 Grammar Rules

The grammar rules describe the format of the syntax that the parser generated by q2c will understand. The way that the grammar rules are included in q2c input file are described above.

The grammar rules are divided into tokens of the following types:

Identifier (ID)

An identifier token is a sequence of letters, digits, and underscores (`_'). Identifiers are not case-sensitive.

String (STRING)

String tokens are initiated by a double-quote character (`"') and consist of all the characters between that double quote and the next double quote, which must be on the same line as the first. Within a string, a backslash can be used as a "literal escape". The only reasons to use a literal escape are to include a double quote or a backslash within a string.

Special character

Other characters, other than whitespace, constitute tokens in themselves.

The syntax of the grammar rules is as follows:

 
grammar-rules ::= ID : subcommands .
subcommands ::= subcommand
            ::= subcommands ; subcommand

The syntax begins with an ID or STRING token that gives the name of the procedure to be parsed. The rest of the syntax consists of subcommands separated by semicolons (`;') and terminated with a full stop (`.').

 
subcommand ::= sbc-options ID sbc-defn
sbc-options ::= 
            ::= sbc-option
            ::= sbc-options sbc-options
sbc-option ::= *
           ::= +
sbc-defn ::= opt-prefix = specifiers
         ::= [ ID ] = array-sbc
         ::= opt-prefix = sbc-special-form
opt-prefix ::=
           ::= ( ID )

Each subcommand can be prefixed with one or more option characters. An asterisk (`*') is used to indicate the default subcommand; the keyword used for the default subcommand can be omitted in the PSPP syntax file. A plus sign (`+') is used to indicate that a subcommand can appear more than once; if it is not present then that subcommand can appear no more than once.

The subcommand name appears after the option characters.

There are three forms of subcommands. The first and most common form simply gives an equals sign (`=') and a list of specifiers, which can each be set to a single setting. The second form declares an array, which is a set of flags that can be individually turned on by the user. There are also several special forms that do not take a list of specifiers.

Arrays require an additional ID argument. This is used as a prefix, prepended to the variable names constructed from the specifiers. The other forms also allow an optional prefix to be specified.

 
array-sbc ::= alternatives
          ::= array-sbc , alternatives
alternatives ::= ID
             ::= alternatives | ID

An array subcommand is a set of Boolean values that can independently be turned on by the user, listed separated by commas (`,'). If an value has more than one name then these names are separated by pipes (`|').

 
specifiers ::= specifier
           ::= specifiers , specifier
specifier ::= opt-id : settings
opt-id ::=
       ::= ID

Ordinary subcommands (other than arrays and special forms) require a list of specifiers. Each specifier has an optional name and a list of settings. If the name is given then a correspondingly named variable will be used to store the user's choice of setting. If no name is given then there is no way to tell which setting the user picked; in this case the settings should probably have values attached.

 
settings ::= setting
         ::= settings / setting
setting ::= setting-options ID setting-value
setting-options ::=
                ::= *
                ::= !
                ::= * !

Individual settings are separated by forward slashes (`/'). Each setting can be as little as an ID token, but options and values can optionally be included. The `*' option means that, for this setting, the ID can be omitted. The `!' option means that this option is the default for its specifier.

 
setting-value ::=
              ::= ( setting-value-2 )
              ::= setting-value-2
setting-value-2 ::= setting-value-options setting-value-type : ID 
                    setting-value-restriction
setting-value-options ::=
                      ::= *
setting-value-type ::= N
                   ::= D
setting-value-restriction ::= 
                          ::= , STRING

Settings may have values. If the value must be enclosed in parentheses, then enclose the value declaration in parentheses. Declare the setting type as `n' or `d' for integer or floating point type, respectively. The given ID is used to construct a variable name. If option `*' is given, then the value is optional; otherwise it must be specified whenever the corresponding setting is specified. A "restriction" can also be specified which is a string giving a C expression limiting the valid range of the value. The special escape %s should be used within the restriction to refer to the setting's value variable.

 
sbc-special-form ::= VAR
                 ::= VARLIST varlist-options
                 ::= INTEGER opt-list
                 ::= DOUBLE opt-list
                 ::= PINT
                 ::= STRING (the literal word STRING) string-options
                 ::= CUSTOM
varlist-options ::= 
                ::= ( STRING )
opt-list ::=
         ::= LIST
string-options ::= 
               ::= ( STRING STRING )

The special forms are of the following types:

VAR

A single variable name.

VARLIST

A list of variables. If given, the string can be used to provide PV_* options to the call to parse_variables.

INTEGER

A single integer value.

INTEGER LIST

A list of integers separated by spaces or commas.

DOUBLE

A single floating-point value.

DOUBLE LIST

A list of floating-point values.

PINT

A single positive integer value.

STRING

A string value. If the options are given then the first string is an expression giving a restriction on the value of the string; the second string is an error message to display when the restriction is violated.

CUSTOM

A custom function is used to parse this subcommand. The function must have prototype int custom_name (void). It should return 0 on failure (when it has already issued an appropriate diagnostic), 1 on success, or 2 if it fails and the calling function should issue a syntax error on behalf of the custom handler.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21. Bugs

As of fvwm 0.99 there were exactly 39.342 unidentified bugs. Identified bugs have mostly been fixed, though. Since then 9.34 bugs have been fixed. Assuming that there are at least 10 unidentified bugs for every identified one, that leaves us with 39.342 - 9.34 + 10 * 9.34 = 123.422 unidentified bugs. If we follow this to its logical conclusion we will have an infinite number of unidentified bugs before the number of bugs can start to diminish, at which point the program will be bug-free. Since this is a computer program infinity = 3.4028e+38 if you don't insist on double-precision. At the current rate of bug discovery we should expect to achieve this point in 3.37e+27 years. I guess I better plan on passing this thing on to my children....

---Robert Nation, fvwm manpage.

21.1 Known bugs  Pointers to other files.
21.2 Contacting the Author  Where to send the bug reports.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21.1 Known bugs

This is the list of known bugs in PSPP. In addition, See section 17. Not Implemented, and See section 8.7.11 Functions Not Implemented, for lists of bugs due to features not implemented. For known bugs in individual language features, see the documentation for that feature.

See below for information on reporting bugs not listed here.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21.2 Contacting the Author

The author can be contacted at e-mail address <blp@gnu.org>.

PSPP bug reports should be sent to <bug-gnu-pspp@gnu.org>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22. Function Index

Jump to:   A   C   D   E   I   L   M   N   P   R   S   T   U   V   X   Y  

Index Entry Section

A
ABS8.7.2 Miscellaneous Mathematical Functions
ACOS8.7.3 Trigonometric Functions
ANY8.7.6 Set-Membership Functions
ARCOS8.7.3 Trigonometric Functions
ARSIN8.7.3 Trigonometric Functions
ARTAN8.7.3 Trigonometric Functions
ASIN8.7.3 Trigonometric Functions
ATAN8.7.3 Trigonometric Functions

C
CDF.xxx8.7.11 Functions Not Implemented
CDFNORM8.7.11 Functions Not Implemented
CFVAR8.7.7 Statistical Functions
CONCAT8.7.8 String Functions
COS8.7.3 Trigonometric Functions
CTIME.DAYS8.7.9.3 Functions that Examine Times
CTIME.HOURS8.7.9.3 Functions that Examine Times
CTIME.MINUTES8.7.9.3 Functions that Examine Times
CTIME.SECONDS8.7.9.3 Functions that Examine Times

D
DATE.DMY8.7.9.4 Functions that Produce Dates
DATE.MDY8.7.9.4 Functions that Produce Dates
DATE.MOYR8.7.9.4 Functions that Produce Dates
DATE.QYR8.7.9.4 Functions that Produce Dates
DATE.WKYR8.7.9.4 Functions that Produce Dates
DATE.YRDAY8.7.9.4 Functions that Produce Dates

E
EXP8.7.1 Advanced Mathematical Functions

I
IDF.xxx8.7.11 Functions Not Implemented
INDEX8.7.8 String Functions
INDEX8.7.8 String Functions

L
LAG8.7.10 Miscellaneous Functions
LAG8.7.10 Miscellaneous Functions
LENGTH8.7.8 String Functions
LG108.7.1 Advanced Mathematical Functions
LN8.7.1 Advanced Mathematical Functions
LOWER8.7.8 String Functions
LPAD8.7.8 String Functions
LPAD8.7.8 String Functions
LTRIM8.7.8 String Functions
LTRIM8.7.8 String Functions

M
MAX8.7.7 Statistical Functions
MEAN8.7.7 Statistical Functions
MIN8.7.7 Statistical Functions
MISSING8.7.4 Missing-Value Functions
MOD8.7.2 Miscellaneous Mathematical Functions
MOD108.7.2 Miscellaneous Mathematical Functions

N
NCDF.xxx8.7.11 Functions Not Implemented
NMISS8.7.4 Missing-Value Functions
NORMAL8.7.5 Pseudo-Random Number Generation Functions
NUMBER8.7.8 String Functions
NUMBER8.7.8 String Functions
NVALID8.7.4 Missing-Value Functions

P
PROBIT8.7.11 Functions Not Implemented

R
RANGE8.7.6 Set-Membership Functions
RINDEX8.7.8 String Functions
RINDEX8.7.8 String Functions
RND8.7.2 Miscellaneous Mathematical Functions
RPAD8.7.8 String Functions
RPAD8.7.8 String Functions
RTRIM8.7.8 String Functions
RTRIM8.7.8 String Functions
RV.xxx8.7.11 Functions Not Implemented

S
SD8.7.7 Statistical Functions
SIN8.7.3 Trigonometric Functions
SQRT8.7.1 Advanced Mathematical Functions
STRING8.7.8 String Functions
SUBSTR8.7.8 String Functions
SUBSTR8.7.8 String Functions
SUM8.7.7 Statistical Functions
SYSMIS8.7.4 Missing-Value Functions

T
TAN8.7.3 Trigonometric Functions
TIME.DAYS8.7.9.2 Functions that Produce Times
TIME.HMS8.7.9.2 Functions that Produce Times
TRUNC8.7.2 Miscellaneous Mathematical Functions

U
UNIFORM8.7.5 Pseudo-Random Number Generation Functions
UPCASE8.7.8 String Functions

V
VALUE8.7.4 Missing-Value Functions
VAR8.7.7 Statistical Functions
VARIANCE8.7.7 Statistical Functions

X
XDATE.DATE8.7.9.5 Functions that Examine Dates
XDATE.HOUR8.7.9.5 Functions that Examine Dates
XDATE.JDAY(date)8.7.9.5 Functions that Examine Dates
XDATE.MDAY(date)8.7.9.5 Functions that Examine Dates
XDATE.MINUTE(time-or-date)8.7.9.5 Functions that Examine Dates
XDATE.MONTH(date)8.7.9.5 Functions that Examine Dates
XDATE.QUARTER(date)8.7.9.5 Functions that Examine Dates
XDATE.SECOND(time-or-date)8.7.9.5 Functions that Examine Dates
XDATE.TDAY(time)8.7.9.5 Functions that Examine Dates
XDATE.TIME(date)8.7.9.5 Functions that Examine Dates
XDATE.WEEK(date)8.7.9.5 Functions that Examine Dates
XDATE.WKDAY(date)8.7.9.5 Functions that Examine Dates
XDATE.YEAR8.7.9.5 Functions that Examine Dates

Y
YRMODA8.7.10 Miscellaneous Functions

Jump to:   A   C   D   E   I   L   M   N   P   R   S   T   U   V   X   Y  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

23. Concept Index

Jump to:   "   $   &   '   (   )   *   +   -   .   /   0   :   <   =   >   [   |   ~  
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y  

Index Entry Section

"
`"'7.1 Tokens
"is defined as"7.8 Backus-Naur Form

$
$CASENUM7.6.2 Variables Automatically Defined by PSPP
$DATE7.6.2 Variables Automatically Defined by PSPP
$JDATE7.6.2 Variables Automatically Defined by PSPP
$LENGTH7.6.2 Variables Automatically Defined by PSPP
$SYSMIS7.6.2 Variables Automatically Defined by PSPP
$TIME7.6.2 Variables Automatically Defined by PSPP
$WIDTH7.6.2 Variables Automatically Defined by PSPP

&
`&'8.5 Logical Operators

'
`''7.1 Tokens
`''7.1 Tokens

(
(8.7 Functions
`( )'8.3 Grouping Operators

)
)8.7 Functions

*
`*'8.4 Arithmetic Operators
`**'8.4 Arithmetic Operators

+
`+'8.4 Arithmetic Operators

-
`-'8.4 Arithmetic Operators
`-'8.4 Arithmetic Operators

.
`.'7.1 Tokens
`.'7.1 Tokens
.7.8 Backus-Naur Form

/
`/'8.4 Arithmetic Operators
`/pub/algorithms/c/julcal10'3. Credits
`/usr/local/bin/'4.1 UNIX installation
`/usr/local/info/'4.1 UNIX installation
`/usr/local/share/pspp/'4.1 UNIX installation

0
07.1 Tokens

:
::=7.8 Backus-Naur Form

<
<8.6 Relational Operators
<=8.6 Relational Operators
<>8.6 Relational Operators

=
`='8.6 Relational Operators

>
`>'8.6 Relational Operators
>=8.6 Relational Operators

[
`[ ]'7.2 Forming commands of tokens

|
`|'8.5 Logical Operators

~
`~'8.5 Logical Operators
~=8.6 Relational Operators

A
absolute value8.7.2 Miscellaneous Mathematical Functions
active file7.7 Files Used by PSPP
addition8.4 Arithmetic Operators
AND8.5 Logical Operators
arccosine8.7.3 Trigonometric Functions
arcsine8.7.3 Trigonometric Functions
arcsine8.7.3 Trigonometric Functions
arctangent8.7.3 Trigonometric Functions
arctangent8.7.3 Trigonometric Functions
arguments, invalid8.7.9 Time & Date Functions
arguments, invalid8.7.9.4 Functions that Produce Dates
arguments, minimum valid8.7.7 Statistical Functions
arguments, of date construction functions8.7.9.4 Functions that Produce Dates
arguments, of date extraction functions8.7.9.5 Functions that Examine Dates
arithmetic operators8.4 Arithmetic Operators
attributes of variables7.6.1 Attributes of Variables
authors3. Credits

B
Backus-Naur Form7.8 Backus-Naur Form
BNF7.8 Backus-Naur Form
Boolean8.1 Boolean values
Boolean8.5 Logical Operators

C
case conversion8.7.8 String Functions
case-sensitivity7.1 Tokens
case-sensitivity7.1 Tokens
Cat's Cradle3. Credits
characters, reserved7.1 Tokens
coefficient of variation8.7.7 Statistical Functions
command file7.7 Files Used by PSPP
command line, options6. Invoking PSPP
command syntax, description of7.8 Backus-Naur Form
commands, names7.2 Forming commands of tokens
commands, ordering7.4 Order of Commands
commands, structure7.2 Forming commands of tokens
compiler, gcc4. Installing PSPP
compiler, recommended4. Installing PSPP
compiling4.1 UNIX installation
concatenation8.7.8 String Functions
conditionals14. Conditional and Looping Constructs
`config.h'4.1 UNIX installation
configuration5. Configuring PSPP
configure, GNU4.1 UNIX installation
constructing dates8.7.9.4 Functions that Produce Dates
constructing times8.7.9.2 Functions that Produce Times
control flow14. Conditional and Looping Constructs
convention, TO7.6.3 Lists of variable names
cosine8.7.3 Trigonometric Functions
Covington, Michael A.3. Credits
credits3. Credits
cross-case function8.7.10 Miscellaneous Functions

D
data9. Data Input and Output
data file7.7 Files Used by PSPP
Data, embedding in syntax files9.1 BEGIN DATA
data, embedding in syntax files9.3 DATA LIST
data, fixed-format, reading9.3.1 DATA LIST FIXED
data, reading from a file9.3 DATA LIST
date examination8.7.9.5 Functions that Examine Dates
date, Julian8.7.10 Miscellaneous Functions
dates8.7.9 Time & Date Functions
dates, concepts8.7.9.1 How times & dates are defined and represented
dates, constructing8.7.9.4 Functions that Produce Dates
dates, day of the month8.7.9.5 Functions that Examine Dates
dates, day of the week8.7.9.5 Functions that Examine Dates
dates, day of the year8.7.9.5 Functions that Examine Dates
dates, day-month-year8.7.9.4 Functions that Produce Dates
dates, in days8.7.9.5 Functions that Examine Dates
dates, in hours8.7.9.5 Functions that Examine Dates
dates, in minutes8.7.9.5 Functions that Examine Dates
dates, in months8.7.9.5 Functions that Examine Dates
dates, in quarters8.7.9.5 Functions that Examine Dates
dates, in seconds8.7.9.5 Functions that Examine Dates
dates, in weekdays8.7.9.5 Functions that Examine Dates
dates, in weeks8.7.9.5 Functions that Examine Dates
dates, in years8.7.9.5 Functions that Examine Dates
dates, legal range of8.7.9 Time & Date Functions
dates, mathematical properties of8.7.9.1 How times & dates are defined and represented
dates, month-year8.7.9.4 Functions that Produce Dates
dates, quarter-year8.7.9.4 Functions that Produce Dates
dates, time of day8.7.9.5 Functions that Examine Dates
dates, week-year8.7.9.4 Functions that Produce Dates
dates, year-day8.7.9.4 Functions that Produce Dates
day of the month8.7.9.5 Functions that Examine Dates
day of the week8.7.9.5 Functions that Examine Dates
day of the year8.7.9.5 Functions that Examine Dates
day-month-year8.7.9.4 Functions that Produce Dates
days8.7.9.2 Functions that Produce Times
days8.7.9.3 Functions that Examine Times
days8.7.9.5 Functions that Examine Dates
days8.7.9.5 Functions that Examine Dates
delimiters7.1 Tokens
description of command syntax7.8 Backus-Naur Form
deviation, standard8.7.7 Statistical Functions
distribution2. Your rights and obligations
division8.4 Arithmetic Operators
documentation, installing4.1 UNIX installation
dot, terminal7.1 Tokens
dot, terminal7.2 Forming commands of tokens
dot, terminal7.8 Backus-Naur Form
dot, terminal, changing7.1 Tokens

E
Embedding data in syntax files9.1 BEGIN DATA
embedding data in syntax files9.3 DATA LIST
embedding fixed-format data9.3.1 DATA LIST FIXED
EQ8.6 Relational Operators
equality, testing8.6 Relational Operators
examination, of times8.7.9.3 Functions that Examine Times
exponentiation8.4 Arithmetic Operators
expression7.8 Backus-Naur Form
expressions, mathematical8. Mathematical Expressions
extraction, of dates8.7.9.5 Functions that Examine Dates
extraction, of time8.7.9.3 Functions that Examine Times

F
false8.5 Logical Operators
features, not implemented8.7.11 Functions Not Implemented
file, active7.7 Files Used by PSPP
file, command7.7 Files Used by PSPP
file, data7.7 Files Used by PSPP
file, output7.7 Files Used by PSPP
file, syntax file7.7 Files Used by PSPP
files, PSPP1. Introduction
fixed-format data, reading9.3.1 DATA LIST FIXED
flow of control14. Conditional and Looping Constructs
Free Software Foundation1. Introduction
Free Software Foundation2. Your rights and obligations
`ftp.cdrom.com'3. Credits
function, cross-case8.7.10 Miscellaneous Functions
functions8.7 Functions
functions, miscellaneous8.7.10 Miscellaneous Functions
functions, missing-value8.7.4 Missing-Value Functions
functions, not implemented8.7.11 Functions Not Implemented
functions, statistical8.7.7 Statistical Functions
functions, string8.7.8 String Functions
functions, time & date8.7.9 Time & Date Functions

G
gcc4. Installing PSPP
GE8.6 Relational Operators
General Public License2. Your rights and obligations
Ghostscript1. Introduction
GNU C compiler4. Installing PSPP
GNU configure4.1 UNIX installation
GNU General Public License2. Your rights and obligations
GPL2. Your rights and obligations
graphics1. Introduction
greater than8.6 Relational Operators
greater than or equal to8.6 Relational Operators
grouping operators8.3 Grouping Operators
GT8.6 Relational Operators

H
hexstrings7.1 Tokens
hours8.7.9.3 Functions that Examine Times
hours8.7.9.5 Functions that Examine Dates
hours-minutes-seconds8.7.9.2 Functions that Produce Times

I
identifiers7.1 Tokens
inequality, testing8.6 Relational Operators
input9. Data Input and Output
installation4. Installing PSPP
installation4.1 UNIX installation
installation, under UNIX4.1 UNIX installation
integer7.8 Backus-Naur Form
integers7.1 Tokens
intersection, logical8.5 Logical Operators
introduction1. Introduction
invalid arguments8.7.9 Time & Date Functions
inverse cosine8.7.3 Trigonometric Functions
inverse sine8.7.3 Trigonometric Functions
inverse sine8.7.3 Trigonometric Functions
inverse tangent8.7.3 Trigonometric Functions
inverse tangent8.7.3 Trigonometric Functions
inversion, logical8.5 Logical Operators
invocation6. Invoking PSPP

J
`julcal.c'3. Credits
`julcal.h'3. Credits
Julian date8.7.10 Miscellaneous Functions

K
keywords7.1 Tokens
keywords7.8 Backus-Naur Form
keywords, reserved7.1 Tokens
Knuth8.7.5 Pseudo-Random Number Generation Functions

L
labels, value7.6.1 Attributes of Variables
labels, variable7.6.1 Attributes of Variables
language, command structure7.2 Forming commands of tokens
language, lexical analysis7.1 Tokens
language, PSPP1. Introduction
language, PSPP7. The PSPP language
language, tokens7.1 Tokens
LE8.6 Relational Operators
less than8.6 Relational Operators
less than or equal to8.6 Relational Operators
lexemes7.1 Tokens
lexical analysis7.1 Tokens
license2. Your rights and obligations
logarithms8.7.1 Advanced Mathematical Functions
logical intersection8.5 Logical Operators
logical inversion8.5 Logical Operators
logical operators8.5 Logical Operators
logical union8.5 Logical Operators
loops14. Conditional and Looping Constructs
LT8.6 Relational Operators

M
`Makefile'4.1 UNIX installation
makefile4.1 UNIX installation
mathematical expressions8. Mathematical Expressions
mathematics8.7 Functions
mathematics, advanced8.7.1 Advanced Mathematical Functions
mathematics, applied to times & dates8.7.9.1 How times & dates are defined and represented
mathematics, miscellaneous8.7.2 Miscellaneous Mathematical Functions
maximum8.7.7 Statistical Functions
mean8.7.7 Statistical Functions
membership, of set8.7.6 Set-Membership Functions
minimum8.7.7 Statistical Functions
minimum valid number of arguments8.7.7 Statistical Functions
Minton, Claire3. Credits
minutes8.7.9.3 Functions that Examine Times
minutes8.7.9.5 Functions that Examine Dates
missing values7.5 Handling missing observations
missing values7.6.1 Attributes of Variables
missing values8.7.4 Missing-Value Functions
modulus8.7.2 Miscellaneous Mathematical Functions
modulus, by 108.7.2 Miscellaneous Mathematical Functions
month-year8.7.9.4 Functions that Produce Dates
months8.7.9.5 Functions that Examine Dates
multiplication8.4 Arithmetic Operators

N
names, of functions8.7 Functions
names, variable7.1 Tokens
NE8.6 Relational Operators
negation8.4 Arithmetic Operators
nonterminals7.8 Backus-Naur Form
NOT8.5 Logical Operators
not implemented8.7.11 Functions Not Implemented
number7.8 Backus-Naur Form
numbers7.1 Tokens
numbers, converting from strings8.7.8 String Functions
numbers, converting to strings8.7.8 String Functions

O
obligations, your2. Your rights and obligations
operations, order of8.8 Operator Precedence
operator precedence8.8 Operator Precedence
operators7.1 Tokens
operators7.8 Backus-Naur Form
operators8.7 Functions
operators, arithmetic8.4 Arithmetic Operators
operators, grouping8.3 Grouping Operators
operators, logical8.5 Logical Operators
options, command-line6. Invoking PSPP
OR8.5 Logical Operators
order of commands7.4 Order of Commands
order of operations8.8 Operator Precedence
output9. Data Input and Output
output file7.7 Files Used by PSPP
output, PSPP1. Introduction

P
padding strings8.7.8 String Functions
parentheses8.3 Grouping Operators
parentheses8.7 Functions
period7.1 Tokens
period7.1 Tokens
Pfaff, Ben3. Credits
portability7.1 Tokens
PostScript1. Introduction
precedence, operator8.8 Operator Precedence
`pref.h'4.1 UNIX installation
print format7.6.1 Attributes of Variables
productions7.8 Backus-Naur Form
productions7.8 Backus-Naur Form
pseudo-random numbers (see random numbers)8.7.5 Pseudo-Random Number Generation Functions
PSPP language1. Introduction
PSPP, command structure7.2 Forming commands of tokens
PSPP, configuring5. Configuring PSPP
PSPP, installing4. Installing PSPP
PSPP, installing4.1 UNIX installation
PSPP, invoking6. Invoking PSPP
PSPP, language7. The PSPP language
punctuation7.1 Tokens
punctuators7.8 Backus-Naur Form

Q
quarter-year8.7.9.4 Functions that Produce Dates
quarters8.7.9.5 Functions that Examine Dates
quotations3. Credits

R
random numbers8.7.5 Pseudo-Random Number Generation Functions
random numbers, normally-distributed8.7.5 Pseudo-Random Number Generation Functions
random numbers, uniformly-distributed8.7.5 Pseudo-Random Number Generation Functions
reading data from a file9.3 DATA LIST
reading fixed-format data9.3.1 DATA LIST FIXED
reals7.1 Tokens
redistribution2. Your rights and obligations
reserved keywords7.1 Tokens
rights, your2. Your rights and obligations
rounding8.7.2 Miscellaneous Mathematical Functions

S
searching strings8.7.8 String Functions
seconds8.7.9.3 Functions that Examine Times
seconds8.7.9.5 Functions that Examine Dates
self-tests, running4.1 UNIX installation
set membership8.7.6 Set-Membership Functions
sine8.7.3 Trigonometric Functions
square roots8.7.1 Advanced Mathematical Functions
standard deviation8.7.7 Statistical Functions
start symbol7.8 Backus-Naur Form
statistics8.7.7 Statistical Functions
string7.8 Backus-Naur Form
string functions8.7.8 String Functions
strings7.1 Tokens
strings, case of8.7.8 String Functions
strings, case of8.7.8 String Functions
strings, concatenation of8.7.8 String Functions
strings, converting from numbers8.7.8 String Functions
strings, converting to numbers8.7.8 String Functions
strings, finding length of8.7.8 String Functions
strings, padding8.7.8 String Functions
strings, padding8.7.8 String Functions
strings, searching backwards8.7.8 String Functions
strings, taking substrings of8.7.8 String Functions
strings, trimming8.7.8 String Functions
strings, trimming8.7.8 String Functions
subcommands7.2 Forming commands of tokens
substrings8.7.8 String Functions
subtraction8.4 Arithmetic Operators
sum8.7.7 Statistical Functions
symbol, start7.8 Backus-Naur Form
syntax file7.7 Files Used by PSPP
system variables7.6.2 Variables Automatically Defined by PSPP
system-missing8.5 Logical Operators

T
tangent8.7.3 Trigonometric Functions
terminal dot7.1 Tokens
terminal dot7.2 Forming commands of tokens
terminal dot7.8 Backus-Naur Form
terminal dot, changing7.1 Tokens
terminals7.8 Backus-Naur Form
terminals and nonterminals, differences7.8 Backus-Naur Form
testing for equality8.6 Relational Operators
testing for inequality8.6 Relational Operators
time8.7.9.5 Functions that Examine Dates
time examination8.7.9.3 Functions that Examine Times
time, concepts8.7.9.1 How times & dates are defined and represented
time, in days8.7.9.2 Functions that Produce Times
time, in days8.7.9.3 Functions that Examine Times
time, in days8.7.9.5 Functions that Examine Dates
time, in hours8.7.9.3 Functions that Examine Times
time, in hours8.7.9.5 Functions that Examine Dates
time, in hours-minutes-seconds8.7.9.2 Functions that Produce Times
time, in minutes8.7.9.3 Functions that Examine Times
time, in minutes8.7.9.5 Functions that Examine Dates
time, in seconds8.7.9.3 Functions that Examine Times
time, in seconds8.7.9.5 Functions that Examine Dates
time, instants of8.7.9.1 How times & dates are defined and represented
time, intervals8.7.9.1 How times & dates are defined and represented
time, lengths of8.7.9.3 Functions that Examine Times
time, mathematical properties of8.7.9.1 How times & dates are defined and represented
times8.7.9 Time & Date Functions
times, constructing8.7.9.2 Functions that Produce Times
times, in days8.7.9.5 Functions that Examine Dates
TO7.6.3 Lists of variable names
TO convention7.6.3 Lists of variable names
tokens7.1 Tokens
trigonometry8.7.3 Trigonometric Functions
true8.5 Logical Operators
truncation8.7.2 Miscellaneous Mathematical Functions
type of variables7.6.1 Attributes of Variables

U
union, logical8.5 Logical Operators
UNIX, installing PSPP under4.1 UNIX installation

V
value labels7.6.1 Attributes of Variables
values, Boolean8.1 Boolean values
values, missing7.5 Handling missing observations
values, missing7.6.1 Attributes of Variables
values, missing8.7.4 Missing-Value Functions
values, system-missing8.5 Logical Operators
Van Zandt, James3. Credits
var-list7.8 Backus-Naur Form
var-name7.8 Backus-Naur Form
variable labels7.6.1 Attributes of Variables
variable names7.1 Tokens
variable names, ending with period7.1 Tokens
variables7.6 Variables
variables, attributes of7.6.1 Attributes of Variables
variables, system7.6.2 Variables Automatically Defined by PSPP
variables, type7.6.1 Attributes of Variables
variables, width7.6.1 Attributes of Variables
variance8.7.7 Statistical Functions
variation, coefficient of8.7.7 Statistical Functions
Vonnegut, Kurt, Jr.3. Credits

W
week8.7.9.5 Functions that Examine Dates
week-year8.7.9.4 Functions that Produce Dates
weekday8.7.9.5 Functions that Examine Dates
whitespace7.1 Tokens
whitespace7.1 Tokens
whitespace7.1 Tokens
whitespace, trimming8.7.8 String Functions
whitespace, trimming8.7.8 String Functions
width of variables7.6.1 Attributes of Variables
write format7.6.1 Attributes of Variables

X
`X''7.1 Tokens

Y
year-day8.7.9.4 Functions that Produce Dates
years8.7.9.5 Functions that Examine Dates
your rights and obligations2. Your rights and obligations

Jump to:   "   $   &   '   (   )   *   +   -   .   /   0   :   <   =   >   [   |   ~  
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

24. Command Index

Jump to:   *   @  
A   B   C   D   E   F   G   I   L   M   N   P   Q   R   S   T   V   W   X  

Index Entry Section

*
*16.1 COMMENT

@
@16.8 INCLUDE

A
ADD VALUE LABELS11.1 ADD VALUE LABELS
AGGREGATE12.1 AGGREGATE
APPLY DICTIONARY10.1 APPLY DICTIONARY
AUTORECODE12.2 AUTORECODE

B
BEGIN DATA9.1 BEGIN DATA
BREAK14.1 BREAK

C
CLEAR TRANSFORMATIONS9.2 CLEAR TRANSFORMATIONS
COMMENT16.1 COMMENT

D
DATA LIST9.3 DATA LIST
DATA LIST FIXED9.3.1 DATA LIST FIXED
DATA LIST FREE9.3.2 DATA LIST FREE
DATA LIST LIST9.3.3 DATA LIST LIST
DISPLAY11.2 DISPLAY
DISPLAY DOCUMENTS16.3 DISPLAY DOCUMENTS
DISPLAY FILE LABEL16.4 DISPLAY FILE LABEL
DISPLAY VECTORS11.3 DISPLAY VECTORS
DO IF14.2 DO IF
DO REPEAT14.3 DO REPEAT
DOCUMENT16.2 DOCUMENT
DROP DOCUMENTS16.5 DROP DOCUMENTS

E
END CASE9.4 END CASE
END DATA9.1 BEGIN DATA
END FILE9.5 END FILE
EXECUTE16.6 EXECUTE
EXPORT10.2 EXPORT

F
FILE HANDLE9.6 FILE HANDLE
FILE LABEL16.7 FILE LABEL
FILTER13.1 FILTER
FLIP12.5 FLIP
FORMATS11.4 FORMATS

G
GET10.3 GET

I
IMPORT10.4 IMPORT
INCLUDE16.8 INCLUDE
INPUT PROGRAM9.7 INPUT PROGRAM

L
LEAVE11.5 LEAVE
LIST9.8 LIST
LOOP14.4 LOOP

M
MATCH FILES10.5 MATCH FILES
MATRIX DATA9.9 MATRIX DATA
MISSING VALUES11.6 MISSING VALUES
MODIFY VARS11.7 MODIFY VARS

N
N OF CASES13.2 N OF CASES
NEW FILE9.10 NEW FILE
NUMERIC11.8 NUMERIC

P
PRINT9.11 PRINT
PRINT EJECT9.12 PRINT EJECT
PRINT FORMATS11.9 PRINT FORMATS
PRINT SPACE9.13 PRINT SPACE
PROCESS IF13.3 PROCESS IF

Q
QUIT16.9 QUIT

R
RENAME VARIABLES11.10 RENAME VARIABLES
REPEATING DATA9.15 REPEATING DATA
REREAD9.14 REREAD

S
SAMPLE13.4 SAMPLE
SAVE10.6 SAVE
SELECT IF13.5 SELECT IF
SET16.10 SET
SORT CASES12.8 SORT CASES
SPLIT FILE13.6 SPLIT FILE
STRING11.12 STRING
SUBTITLE16.11 SUBTITLE
SYSFILE INFO10.7 SYSFILE INFO

T
TEMPORARY13.7 TEMPORARY
TITLE16.12 TITLE

V
VALUE LABELS11.11 VALUE LABELS
VARIABLE LABELS11.13 VARIABLE LABELS
VECTOR11.14 VECTOR

W
WEIGHT13.8 WEIGHT
WRITE9.16 WRITE
WRITE FORMATS11.15 WRITE FORMATS

X
XSAVE10.8 XSAVE

Jump to:   *   @  
A   B   C   D   E   F   G   I   L   M   N   P   Q   R   S   T   V   W   X  


[Top] [Contents] [Index] [ ? ]

Footnotes

(1)

Do What I Mean


[Top] [Contents] [Index] [ ? ]

Table of Contents

1. Introduction
2. Your rights and obligations
3. Credits
4. Installing PSPP
4.1 UNIX installation
5. Configuring PSPP
5.1 Locating configuration files
5.2 Configuration techniques
5.3 Configuration files
5.4 Environment variables
5.4.1 Values of environment variables
5.4.2 Environment substitutions
5.4.3 Predefined environment variables
5.5 Output devices
5.5.1 Driver categories
5.5.2 Macro definitions
5.5.3 Driver definitions
5.5.4 Dimensions
5.5.5 Paper sizes
5.5.6 How lines are divided into types
5.5.7 How lines are divided into tokens
5.6 The PostScript driver class
5.6.1 PostScript output options
5.6.2 PostScript page options
5.6.3 PostScript file options
5.6.4 PostScript font options
5.6.5 PostScript line options
5.6.6 The PostScript prologue
5.6.7 PostScript encodings
5.7 The ASCII driver class
5.7.1 ASCII output options
5.7.2 ASCII page options
5.7.3 ASCII font options
5.8 The HTML driver class
5.8.1 The HTML prologue
5.9 Miscellaneous configuration
5.10 Improving output quality
6. Invoking PSPP
6.1 Non-option Arguments
6.2 Configuration Options
6.3 Input and output options
6.4 Language control options
6.5 Informational options
7. The PSPP language
7.1 Tokens
7.2 Forming commands of tokens
7.3 Types of Commands
7.4 Order of Commands
7.5 Handling missing observations
7.6 Variables
7.6.1 Attributes of Variables
7.6.2 Variables Automatically Defined by PSPP
7.6.3 Lists of variable names
7.6.4 Input and Output Formats
7.6.5 Scratch Variables
7.7 Files Used by PSPP
7.8 Backus-Naur Form
8. Mathematical Expressions
8.1 Boolean values
8.2 Missing Values in Expressions
8.3 Grouping Operators
8.4 Arithmetic Operators
8.5 Logical Operators
8.6 Relational Operators
8.7 Functions
8.7.1 Advanced Mathematical Functions
8.7.2 Miscellaneous Mathematical Functions
8.7.3 Trigonometric Functions
8.7.4 Missing-Value Functions
8.7.5 Pseudo-Random Number Generation Functions
8.7.6 Set-Membership Functions
8.7.7 Statistical Functions
8.7.8 String Functions
8.7.9 Time & Date Functions
8.7.9.1 How times & dates are defined and represented
8.7.9.2 Functions that Produce Times
8.7.9.3 Functions that Examine Times
8.7.9.4 Functions that Produce Dates
8.7.9.5 Functions that Examine Dates
8.7.10 Miscellaneous Functions
8.7.11 Functions Not Implemented
8.8 Operator Precedence
9. Data Input and Output
9.1 BEGIN DATA
9.2 CLEAR TRANSFORMATIONS
9.3 DATA LIST
9.3.1 DATA LIST FIXED
Examples
9.3.2 DATA LIST FREE
9.3.3 DATA LIST LIST
9.4 END CASE
9.5 END FILE
9.6 FILE HANDLE
9.7 INPUT PROGRAM
9.8 LIST
9.9 MATRIX DATA
9.10 NEW FILE
9.11 PRINT
9.12 PRINT EJECT
9.13 PRINT SPACE
9.14 REREAD
9.15 REPEATING DATA
9.16 WRITE
10. System Files and Portable Files
10.1 APPLY DICTIONARY
10.2 EXPORT
10.3 GET
10.4 IMPORT
10.5 MATCH FILES
10.6 SAVE
10.7 SYSFILE INFO
10.8 XSAVE
11. Manipulating variables
11.1 ADD VALUE LABELS
11.2 DISPLAY
11.3 DISPLAY VECTORS
11.4 FORMATS
11.5 LEAVE
11.6 MISSING VALUES
11.7 MODIFY VARS
11.8 NUMERIC
11.9 PRINT FORMATS
11.10 RENAME VARIABLES
11.11 VALUE LABELS
11.12 STRING
11.13 VARIABLE LABELS
11.14 VECTOR
11.15 WRITE FORMATS
12. Data transformations
12.1 AGGREGATE
12.2 AUTORECODE
12.3 COMPUTE
12.4 COUNT
12.5 FLIP
12.6 IF
12.7 RECODE
12.8 SORT CASES
13. Selecting data for analysis
13.1 FILTER
13.2 N OF CASES
13.3 PROCESS IF
13.4 SAMPLE
13.5 SELECT IF
13.6 SPLIT FILE
13.7 TEMPORARY
13.8 WEIGHT
14. Conditional and Looping Constructs
14.1 BREAK
14.2 DO IF
14.3 DO REPEAT
14.4 LOOP
15. Statistics
15.1 DESCRIPTIVES
15.2 FREQUENCIES
15.3 CROSSTABS
16. Utilities
16.1 COMMENT
16.2 DOCUMENT
16.3 DISPLAY DOCUMENTS
16.4 DISPLAY FILE LABEL
16.5 DROP DOCUMENTS
16.6 EXECUTE
16.7 FILE LABEL
16.8 INCLUDE
16.9 QUIT
16.10 SET
16.11 SUBTITLE
16.12 TITLE
17. Not Implemented
18. Data File Format
18.1 File Header Record
18.2 Variable Record
18.3 Value Label Record
18.4 Value Label Variable Record
18.5 Document Record
18.6 Machine int32 Info Record
18.7 Machine flt64 Info Record
18.8 Miscellaneous Informational Records
18.9 Dictionary Termination Record
18.10 Data Record
19. Portable File Format
19.1 Portable File Characters
19.2 Portable File Structure
19.3 Portable File Header
19.4 Version and Date Info Record
19.5 Identification Records
19.6 Variable Count Record
19.7 Variable Records
19.8 Value Label Records
19.9 Portable File Data
20. q2c Input Format
20.1 Invoking q2c
20.2 q2c Input Structure
20.3 Grammar Rules
21. Bugs
21.1 Known bugs
21.2 Contacting the Author
22. Function Index
23. Concept Index
24. Command Index

[Top] [Contents] [Index] [ ? ]

Short Table of Contents

1. Introduction
2. Your rights and obligations
3. Credits
4. Installing PSPP
5. Configuring PSPP
6. Invoking PSPP
7. The PSPP language
8. Mathematical Expressions
9. Data Input and Output
10. System Files and Portable Files
11. Manipulating variables
12. Data transformations
13. Selecting data for analysis
14. Conditional and Looping Constructs
15. Statistics
16. Utilities
17. Not Implemented
18. Data File Format
19. Portable File Format
20. q2c Input Format
21. Bugs
22. Function Index
23. Concept Index
24. Command Index

[Top] [Contents] [Index] [ ? ]

About this document

This document was generated by using texi2html

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back previous section in reading order 1.2.2
[ > ] Forward next section in reading order 1.2.4
[ << ] FastBack beginning of this chapter or previous chapter 1
[ Up ] Up up section 1.2
[ >> ] FastForward next chapter 2
[Top] Top cover (top) of document  
[Contents] Contents table of contents  
[Index] Index concept index  
[ ? ] About this page  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:



This document was generated by root on October, 25 2003 using texi2html