Fully implement arbitrary delimiters on DATA LIST, extending the half
[pspp-builds.git] / doc / pspp.texi
1 \input texinfo @c -*- texinfo -*-
2 @c %**start of header
3 @setfilename pspp.info
4 @settitle PSPP
5 @set TIMESTAMP Time-stamp:  Sat Dec 20 20:25:33 WST 2003 jmd
6 @set EDITION 0.2
7 @set VERSION 0.3
8 @c For double-sided printing, uncomment:
9 @c @setchapternewpage odd
10 @c %**end of header
11
12 @macro cmd{CMDNAME}
13 \CMDNAME\
14 @end macro
15
16 @iftex
17 @finalout
18 @end iftex
19
20 @dircategory Math
21 @direntry
22 * PSPP: (pspp).             Statistical analysis package.
23 @end direntry
24
25 @ifinfo
26 PSPP, for statistical analysis of sampled data, by Ben Pfaff.
27
28 This file documents PSPP, a statistical package for analysis of
29 sampled data that uses a command language compatible with SPSS.
30
31 Copyright (C) 1996-9, 2000 Free Software Foundation, Inc.
32
33 This version of the PSPP documentation is consistent with version 2 of
34 ``texinfo.tex''.
35
36 Permission is granted to make and distribute verbatim copies of this
37 manual provided the copyright notice and this permission notice are
38 preserved on all copies.
39
40 @ignore
41 Permission is granted to process this file through TeX and print the
42 results, provided the printed document carries copying permission notice
43 identical to this one except for the removal of this paragraph (this
44 paragraph not being relevant to the printed manual).
45
46 @end ignore
47 Permission is granted to copy and distribute modified versions of this
48 manual under the conditions for verbatim copying, provided that the
49 entire resulting derived work is distributed under the terms of a
50 permission notice identical to this one.
51
52 Permission is granted to copy and distribute translations of this
53 manual into another language, under the above condition for modified 
54 versions, except that this permission notice may be stated in a 
55 translation approved by the Free Software Foundation.
56 @end ifinfo
57
58 @titlepage
59 @title PSPP
60 @subtitle A System for Statistical Analysis
61 @subtitle Edition @value{EDITION}, for PSPP version @value{VERSION}
62 @author by Ben Pfaff
63
64 @page
65 @vskip 0pt plus 1filll
66
67 PSPP Copyright @copyright{} 1997, 1998 Free Software Foundation, Inc.
68
69 Permission is granted to make and distribute verbatim copies of this
70 manual provided the copyright notice and this permission notice are
71 preserved on all copies.
72
73 Permission is granted to copy and distribute modified versions of this
74 manual under the conditions for verbatim copying, provided that the
75 entire derived work is distributed under the terms of a permission
76 notice identical to this one.
77
78 Permission is granted to copy and distribute translations of this manual
79 into another language, under the above conditions for modified versions,
80 except that this permission notice may be stated in a translation
81 approved by the Foundation.
82 @end titlepage
83
84 @node Top, Introduction, (dir), (dir)
85 @ifinfo
86 @top PSPP
87
88 This file documents the PSPP package for statistical analysis of sampled
89 data.  This is edition @value{EDITION}, for PSPP version
90 @value{VERSION}, last modified at @value{TIMESTAMP}.
91
92 @end ifinfo
93
94 @menu
95 * Introduction::                Description of the package.
96 * License::                     Your rights and obligations.
97 * Credits::                     Acknowledgement of authors.
98
99 * Installation::                How to compile and install PSPP.
100 * Configuration::               Configuring PSPP.
101 * Invocation::                  Starting and running PSPP.
102
103 * Language::                    Basics of the PSPP command language.
104 * Expressions::                 Numeric and string expression syntax.
105
106 * Data Input and Output::       Reading data from user files.
107 * System and Portable Files::   Dealing with system & portable files.
108 * Variable Attributes::         Adjusting and examining variables.
109 * Data Manipulation::           Simple operations on data.
110 * Data Selection::              Select certain cases for analysis.
111 * Conditionals and Looping::    Doing things many times or not at all.
112 * Statistics::                  Basic statistical procedures.
113 * Utilities::                   Other commands.
114 * Not Implemented::             What's not here yet
115
116 * Data File Format::            Format of PSPP system files.
117 * Portable File Format::        Format of PSPP portable files.
118 * q2c Input Format::            Format of syntax accepted by q2c.
119
120 * Bugs::                        Known problems; submitting bug reports.
121
122 * Function Index::              Index of PSPP functions for expressions.
123 * Concept Index::               Index of concepts.
124 * Command Index::               Index of PSPP procedures.
125
126 @end menu
127
128 @node Introduction, License, Top, Top
129 @chapter Introduction
130 @cindex introduction
131
132 @cindex PSPP language
133 @cindex language, PSPP
134 PSPP is a tool for statistical analysis of sampled data.  It reads a
135 syntax file and a data file, analyzes the data, and writes the results
136 to a listing file or to standard output.
137
138 The language accepted by PSPP is similar to those accepted by SPSS
139 statistical products.  The details of PSPP's language are given
140 later in this manual.
141
142 @cindex files, PSPP
143 @cindex output, PSPP
144 @cindex PostScript
145 @cindex graphics
146 @cindex Ghostscript
147 @cindex Free Software Foundation
148 PSPP produces output in two forms: tables and charts.  Both of these can
149 be written in several formats; currently, ASCII, PostScript, and HTML
150 are supported.  In the future, more drivers, such as PCL and X Window
151 System drivers, may be developed.  For now, Ghostscript, available from
152 the Free Software Foundation, may be used to convert PostScript chart
153 output to other formats.
154
155 The current version of PSPP, @value{VERSION}, is woefully incomplete in
156 terms of its statistical procedure support.  PSPP is a work in progress.
157 The author hopes to support fully support all features in the products
158 that PSPP replaces, eventually.  The author welcomes questions,
159 comments, donations, and code submissions.  @xref{Bugs,,Submitting Bug
160 Reports}, for instructions on contacting the author.
161
162 @node License, Credits, Introduction, Top
163 @chapter Your rights and obligations
164 @cindex license
165 @cindex your rights and obligations
166 @cindex rights, your
167 @cindex obligations, your
168
169 @cindex Free Software Foundation
170 @cindex GNU General Public License
171 @cindex General Public License
172 @cindex GPL
173 @cindex distribution
174 @cindex redistribution
175 Most of PSPP is distributed under the GNU General Public
176 License.  The General Public License says, in effect, that you may
177 modify and distribute PSPP as you like, as long as you grant the
178 same rights to others.  It also states that you must provide source code
179 when you distribute PSPP, or, if you obtained PSPP
180 source code from an anonymous ftp site, give out the name of that site.
181
182 The General Public License is given in full in the source distribution
183 as file @file{COPYING}.  In Debian GNU/Linux, this file is also
184 available as file @file{/usr/share/common-licenses/GPL-2}.
185
186 To quote the GPL itself:
187
188 @quotation
189 This program is free software; you can redistribute it and/or modify it
190 under the terms of the GNU General Public License as published by the
191 Free Software Foundation; either version 2 of the License, or (at your
192 option) any later version.
193
194 This program is distributed in the hope that it will be useful, but
195 WITHOUT ANY WARRANTY; without even the implied warranty of
196 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
197 General Public License for more details.
198
199 You should have received a copy of the GNU General Public License along
200 with this program; if not, write to the Free Software Foundation, Inc.,
201 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
202 @end quotation
203
204 @node Credits, Installation, License, Top
205 @chapter Credits
206 @cindex credits
207 @cindex authors
208
209 @cindex Pfaff, Ben
210 Most of PSPP, as well as this manual,
211 was written by Ben Pfaff.  @xref{Contacting the Author}, for
212 instructions on contacting the author.
213
214 @cindex Covington, Michael A.
215 @cindex Van Zandt, James
216 @cindex @file{ftp.cdrom.com}
217 @cindex @file{/pub/algorithms/c/julcal10}
218 @cindex @file{julcal.c}
219 @cindex @file{julcal.h}
220 The PSPP source code incorporates @code{julcal10} originally
221 written by Michael A. Covington and translated into C by Jim Van Zandt.
222 The original package can be found in directory
223 @url{ftp://ftp.cdrom.com/pub/algorithms/c/julcal10}.  The entire
224 contents of that directory constitute the package.  The files actually
225 used in PSPP are @code{julcal.c} and @code{julcal.h}.
226
227 @node Installation, Configuration, Credits, Top
228 @chapter Installing PSPP
229 @cindex installation
230 @cindex PSPP, installing
231
232 @cindex GNU C compiler
233 @cindex gcc
234 @cindex compiler, recommended
235 @cindex compiler, gcc
236 PSPP conforms to the GNU Coding Standards.  PSPP is written in, and
237 requires for proper operation, ANSI/ISO C.  You might want to
238 additionally note the following points:
239
240 @itemize @bullet
241 @item
242 The compiler and linker must allow for significance of several
243 characters in external identifiers.  The exact number is unknown but at
244 least 31 is recommended.
245
246 @item
247 The @code{int} type must be 32 bits or wider.
248
249 @item
250 The recommended compiler is gcc 2.7.2.1 or later, but any ANSI compiler
251 will do if it fits the above criteria.
252 @end itemize
253
254 Many UNIX variants should work out-of-the-box, as PSPP uses GNU
255 autoconf to detect differences between environments.  Please report any
256 problems with compilation of PSPP under UNIX and UNIX-like operating
257 systems---portability is a major concern of the author.
258
259 The pages below give specific instructions for installing PSPP
260 on each type of system mentioned above.
261
262 @menu
263 * UNIX installation::           Installing on UNIX-like environments.
264 @end menu
265
266 @node UNIX installation,  , Installation, Installation
267 @section UNIX installation
268 @cindex UNIX, installing PSPP under
269 @cindex installation, under UNIX
270 @noindent
271 To install PSPP under a UNIX-like operating system, follow the steps
272 below in order.  Some of the text below was taken directly from various
273 Free Software Foundation sources.
274
275 @enumerate
276 @item
277 @code{cd} to the directory containing the PSPP source.
278
279 @cindex configure, GNU
280 @cindex GNU configure
281 @item
282 Type @samp{./configure} to configure for your particular operating
283 system and compiler.  Running @code{configure} takes a while.  While
284 running, it displays some messages telling which features it is checking
285 for.
286
287 You can optionally supply some options to @code{configure} to
288 give it hints about how to do its job.  Type @code{./configure --help}
289 to see a list of options.  One of the most useful options is
290 @samp{--with-checker}, which enables the use of the Checker memory
291 debugger under supported operating systems.  Checker must already be
292 installed to use this option.  Do not use @samp{--with-checker} if you
293 are not debugging PSPP itself.
294
295 @cindex @file{Makefile}
296 @cindex @file{config.h}
297 @cindex @file{pref.h}
298 @cindex makefile
299 @item
300 (optional) Edit @file{Makefile}, @file{config.h}, and @file{pref.h}.
301 These files are produced by @code{configure}.  Note that most PSPP
302 settings can be changed at runtime.
303
304 @file{pref.h} is only generated by @code{configure} if it does not
305 already exist.  (It's copied from @file{prefh.orig}.)
306
307 @cindex compiling
308 @item
309 Type @samp{make} to compile the package.  If there are any errors during
310 compilation, try to fix them.  If modifications are necessary to compile
311 correctly under your configuration, contact the author.
312 @xref{Bugs,,Submitting Bug Reports}, for details.
313
314 @cindex self-tests, running
315 @item
316 Type @samp{make check} to run self-tests on the compiled PSPP package.
317
318 @cindex installation
319 @cindex PSPP, installing
320 @cindex @file{/usr/local/share/pspp/}
321 @cindex @file{/usr/local/bin/}
322 @cindex @file{/usr/local/info/}
323 @cindex documentation, installing
324 @item
325 Become the superuser and type @samp{make install} to install the
326 PSPP binaries, by default in @file{/usr/local/bin/}.  The
327 directory @file{/usr/local/share/pspp/} is created and populated with
328 files needed by PSPP at runtime.  This step will also cause the
329 PSPP documentation to be installed in @file{/usr/local/info/},
330 but only if that directory already exists.
331
332 @item
333 (optional) Type @samp{make clean} to delete the PSPP binaries
334 from the source tree.
335 @end enumerate
336
337 @node Configuration, Invocation, Installation, Top
338 @chapter Configuring PSPP
339 @cindex configuration
340 @cindex PSPP, configuring
341
342 PSPP has dozens of configuration possibilities and hundreds of
343 settings.  This is both a bane and a blessing.  On one hand, it's
344 possible to easily accommodate diverse ranges of setups.  But, on the
345 other, the multitude of possibilities can overwhelm the casual user.
346 Fortunately, the configuration mechanisms are profusely described in the
347 sections below@enddots{}
348
349 @menu
350 * File locations::              How PSPP finds config files.
351 * Configuration techniques::    Many different methods of configuration@enddots{}
352 * Configuration files::         How configuration files are read.
353 * Environment variables::       All about environment variables.
354 * Output devices::              Describing your terminal(s) and printer(s).
355 * PostScript driver class::     Configuration of PostScript devices.
356 * ASCII driver class::          Configuration of character-code devices.
357 * HTML driver class::           Configuration for HTML output.
358 * Miscellaneous configuring::   Even more configuration variables.
359 * Improving output quality::    Hints for producing ever-more-lovely output.
360 @end menu
361
362 @node File locations, Configuration techniques, Configuration, Configuration
363 @section Locating configuration files
364
365 PSPP uses the same method to find most of its configuration files:
366
367 @enumerate
368 @item
369 The @dfn{base name} of the file being sought is determined.
370
371 @item
372 The path to search is determined.  
373
374 @item
375 Each directory in the search path, from left to right, is searched for a
376 file with the name of the base name.  The first occurrence is read
377 as the configuration file.
378 @end enumerate
379
380 The first two steps are elaborated below for the sake of our pedantic
381 friends.
382
383 @enumerate
384 @item
385 A @dfn{base name} is a file name lacking an absolute directory
386 reference.  Some examples of base names are: @file{ps-encodings},
387 @file{devices}, @file{devps/DESC} (under UNIX), @file{devps\DESC} (under
388 M$ environments).
389
390 Determining the base name is a two-step process:
391
392 @enumerate a
393 @item
394 If the appropriate environment variable is defined, the value of that
395 variable is used (@pxref{Environment variables}).  For instance, when
396 searching for the output driver initialization file, the variable
397 examined is @code{STAT_OUTPUT_INIT_FILE}.
398
399 @item
400 Otherwise, the compiled-in default is used.  For example, when searching
401 for the output driver initialization file, the default base name is
402 @file{devices}.
403 @end enumerate
404
405 @strong{Please note:} If a user-specified base name does contain an
406 absolute directory reference, as in a file name like
407 @file{/home/pfaff/fonts/TR}, no path is searched---the file name is used
408 exactly as given---and the algorithm terminates.
409
410 @item
411 The path is the first of the following that is defined:
412
413 @itemize @bullet
414 @item
415 A variable definition for the path given in the user environment.  This
416 is a PSPP-specific environment variable name; for instance,
417 @code{STAT_OUTPUT_INIT_PATH}.
418
419 @item 
420 In some cases, another, less-specific environment variable is checked.
421 For instance, when searching for font files, the PostScript driver first
422 checks for a variable with name @code{STAT_GROFF_FONT_PATH}, then for
423 one with name @code{GROFF_FONT_PATH}.  (However, font searching has its
424 own list of esoteric search rules.)
425
426 @item
427 The configuration file path, which is itself determined by the
428 following rules:
429
430 @enumerate a
431 @item
432 If the command line contains an option of the form @samp{-B @var{path}}
433 or @samp{--config-dir=@var{path}}, then the value given on the
434 rightmost occurrence of such an option is used.
435
436 @item
437 Otherwise, if the environment variable @code{STAT_CONFIG_PATH} is
438 defined, the value of that variable is used.
439
440 @item
441 Otherwise, the compiled-in fallback default is used.  On UNIX machines,
442 the default fallback path is
443
444 @enumerate 1
445 @item
446 @file{~/.pspp}
447
448 @item
449 @file{/usr/local/lib/pspp}
450
451 @item
452 @file{/usr/lib/pspp}
453 @end enumerate
454
455 On DOS machines, the default fallback path is:
456
457 @enumerate 1
458 @item
459 All the paths from the DOS search path in the @samp{PATH} environment
460 variable, in left-to-right order.
461
462 @item
463 @file{C:\PSPP}, as a last resort.
464 @end enumerate
465
466 Note that the installer of PSPP can easily change this default
467 fallback path; thus the above should not be taken as gospel.
468 @end enumerate
469 @end itemize
470 @end enumerate
471
472 As a final note: Under DOS, directories given in paths are delimited by
473 semicolons (@samp{;}); under UNIX, directories are delimited by colons
474 (@samp{:}).  This corresponds with the standard path delimiter under
475 these OSes.
476
477 @node Configuration techniques, Configuration files, File locations, Configuration
478 @section Configuration techniques
479
480 There are many ways that PSPP can be configured.  These are
481 described in the list below.  Values given by earlier items take
482 precedence over those given by later items.
483
484 @enumerate
485 @item
486 Syntax commands that modify settings, such as @cmd{SET}.  @xref{SET}.
487
488 @item
489 Command-line options.  @xref{Invocation}.
490
491 @item
492 PSPP-specific environment variable contents.  @xref{Environment
493 variables}.
494
495 @item
496 General environment variable contents.  @xref{Environment variables}.
497
498 @item
499 Configuration file contents.  @xref{Configuration files}.
500
501 @item
502 Fallback defaults.
503 @end enumerate
504
505 Some of the above may not apply to a particular setting.  For instance,
506 the current pager (such as @samp{more}, @samp{most}, or @samp{less})
507 cannot be determined by configuration file contents because there is no
508 appropriate configuration file.
509
510 @node Configuration files, Environment variables, Configuration techniques, Configuration
511 @section Configuration files
512
513 Most configuration files have a common form:
514
515 @itemize @bullet
516 @item
517 Each line forms a separate command or directive.  This means that lines
518 cannot be broken up, unless they are spliced together with a trailing
519 backslash, as described below.
520
521 @item
522 Before anything else is done, trailing whitespace is removed.
523
524 @item
525 When a line ends in a backslash (@samp{\}), the backslash is removed,
526 and the next line is read and appended to the current line.
527
528 @itemize @minus
529 @item
530 Whitespace preceding the backslash is retained.
531
532 @item
533 This rule continues to be applied until the line read does not end in a
534 backslash.
535
536 @item
537 It is an error if the last line in the file ends in a backslash.
538 @end itemize
539
540 @item
541 Comments are introduced by an octothorpe (@samp{#}), and continue until the
542 end of the line.
543
544 @itemize @minus
545 @item
546 An octothorpe inside balanced pairs of double quotation marks (@samp{"})
547 or single quotation marks (@samp{'}) does not introduce a comment.
548
549 @item
550 The backslash character can be used inside balanced quotes of either
551 type to escape the following character as a literal character.  
552
553 (This is distinct from the use of a backslash as a line-splicing
554 character.)
555
556 @item
557 Line splicing takes place before comment removal.
558 @end itemize
559
560 @item
561 Blank lines, and lines that contain only whitespace, are ignored.
562 @end itemize
563
564 @node Environment variables, Output devices, Configuration files, Configuration
565 @section Environment variables
566
567 You may think the concept of environment variables is a fairly simple
568 one.  However, the author of PSPP has found a way to complicate
569 even something so simple.  Environment variables are further described
570 in the sections below:
571
572 @menu
573 * Variable values::             Values of variables are determined this way.
574 * Environment substitutions::   How environment substitutions are made.
575 * Predefined variables::        A few variables are automatically defined.
576 @end menu
577
578 @node Variable values, Environment substitutions, Environment variables, Environment variables
579 @subsection Values of environment variables
580
581 Values for environment variables are obtained by the following means,
582 which are arranged in order of decreasing precedence:
583
584 @enumerate
585 @item
586 Command-line options.  @xref{Invocation}.
587
588 @item
589 The @file{environment} configuration file---more on this below.
590
591 @item
592 Actual environment variables (defined in the shell or other parent
593 process).
594 @end enumerate
595
596 The @file{environment} configuration file is located through application
597 of the usual algorithm for configuration files (@pxref{File locations}),
598 except that its contents do not affect the search path used to find
599 @file{environment} itself.  Use of @file{environment} is discouraged on
600 systems that allow an arbitrarily large environment; it is supported for
601 use on systems like MS-DOS that limit environment size.
602
603 @file{environment} is composed of lines having the form
604 @samp{@var{key}=@var{value}}, where @var{key} and the equals sign
605 (@samp{=}) are required, and @var{value} is optional.  If @var{value} is
606 given, variable @var{key} is given that value; if @var{value} is absent,
607 variable @var{key} is undefined (deleted).  Variables may not be defined
608 with a null value.
609
610 Environment substitutions are performed on each line in the file
611 (@pxref{Environment substitutions}).
612
613 See @ref{Configuration files}, for more details on formatting of the
614 environment configuration file.
615
616 @quotation
617 @strong{Please note:} Support for @file{environment} is not yet
618 implemented.
619 @end quotation
620
621 @node Environment substitutions, Predefined variables, Variable values, Environment variables
622 @subsection Environment substitutions
623
624 Much of the power of environment variables lies in the way that they may
625 be substituted into configuration files.  Variable substitutions are
626 described below.
627
628 The line is scanned from left to right.  In this scan, all characters
629 other than dollar signs (@samp{$}) are retained unmolested.  Dollar
630 signs, however, introduce an environment variable reference.  References
631 take three forms:
632
633 @table @code
634 @item $@var{var}
635 Replaced by the value of environment variable @var{var}, determined as
636 specified in @ref{Variable values}.  @var{var} must be one of the
637 following:
638
639 @itemize @bullet
640 @item
641 One or more letters.
642
643 @item
644 Exactly one nonalphabetic character.  This may not be a left brace
645 (@samp{@{}).
646 @end itemize
647
648 @item $@{@var{var}@}
649 Same as above, but @var{var} may contain any character (except
650 @samp{@}}).
651
652 @item $$
653 Replaced by a single dollar sign.
654 @end table
655
656 Undefined variables expand to a empty value.
657
658 @node Predefined variables,  , Environment substitutions, Environment variables
659 @subsection Predefined environment variables
660
661 There are two environment variables predefined for use in environment
662 substitutions:
663
664 @table @samp
665 @item VER
666 Defined as the version number of PSPP, as a string, in a format
667 something like @samp{0.9.4}.
668
669 @item ARCH
670 Defined as the host architecture of PSPP, as a string, in standard
671 cpu-manufacturer-OS format.  For instance, Debian GNU/Linux 1.1 on an
672 Intel machine defines this as @samp{i586-unknown-linux}.  This is
673 somewhat dependent on the system used to compile PSPP.
674 @end table
675
676 Nothing prevents these values from being overridden, although it's a
677 good idea not to do so.
678
679 @node Output devices, PostScript driver class, Environment variables, Configuration
680 @section Output devices
681
682 Configuring output devices is the most complicated aspect of configuring
683 PSPP.  The output device configuration file is named
684 @file{devices}.  It is searched for using the usual algorithm for
685 finding configuration files (@pxref{File locations}).  Each line in the
686 file is read in the usual manner for configuration files
687 (@pxref{Configuration files}).
688
689 Lines in @file{devices} are divided into three categories, described
690 briefly in the table below:
691
692 @table @i
693 @item driver category definitions
694 Define a driver in terms of other drivers.
695
696 @item macro definitions
697 Define environment variables local to the the output driver
698 configuration file.
699
700 @item device definitions
701 Describe the configuration of an output device.
702 @end table
703
704 The following sections further elaborate the contents of the
705 @file{devices} file.
706
707 @menu
708 * Driver categories::           How to organize the driver namespace.
709 * Macro definitions::           Environment variables local to @file{devices}.
710 * Device definitions::          Output device descriptions.
711 * Dimensions::                  Lengths, widths, sizes, @enddots{}
712 * papersize::                   Letter, legal, A4, envelope, @enddots{}
713 * Distinguishing line types::   Details on @file{devices} parsing.
714 * Tokenizing lines::            Dividing @file{devices} lines into tokens.
715 @end menu
716
717 @node Driver categories, Macro definitions, Output devices, Output devices
718 @subsection Driver categories
719
720 Drivers can be divided into categories.  Drivers are specified by their
721 names, or by the names of the categories that they are contained in.
722 Only certain drivers are enabled each time PSPP is run; by
723 default, these are the drivers in the category `default'.  To enable a
724 different set of drivers, use the @samp{-o @var{device}} command-line
725 option (@pxref{Invocation}).
726
727 Categories are specified with a line of the form
728 @samp{@var{category}=@var{driver1} @var{driver2} @var{driver3} @var{@dots{}}
729 @var{driver@var{n}}}.  This line specifies that the category
730 @var{category} is composed of drivers named @var{driver1},
731 @var{driver2}, and so on.  There may be any number of drivers in the
732 category, from zero on up.
733
734 Categories may also be specified on the command line
735 (@pxref{Invocation}).
736
737 This is all you need to know about categories.  If you're still curious,
738 read on.
739
740 First of all, the term `categories' is a bit of a misnomer.  In fact,
741 the internal representation is nothing like the hierarchy that the term
742 seems to imply: a linear list is used to keep track of the enabled
743 drivers.
744
745 When PSPP first begins reading @file{devices}, this list contains
746 the name of any drivers or categories specified on the command line, or
747 the single item `default' if none were specified.
748
749 Each time a category definition is specified, the list is searched for
750 an item with the value of @var{category}.  If a matching item is found,
751 it is deleted.  If there was a match, the list of drivers (@var{driver1}
752 through @var{driver@var{n}}) is then appended to the list.
753
754 Each time a driver definition line is encountered, the list is searched.
755 If the list contains an item with that driver's name, the driver is
756 enabled and the item is deleted from the list.  Otherwise, the driver
757 is not enabled.
758
759 It is an error if the list is not empty when the end of @file{devices}
760 is reached.
761
762 @node Macro definitions, Device definitions, Driver categories, Output devices
763 @subsection Macro definitions
764
765 Macro definitions take the form @samp{define @var{macroname}
766 @var{definition}}.  In such a macro definition, the environment variable
767 @var{macroname} is defined to expand to the value @var{definition}.
768 Before the definition is made, however, any macros used in
769 @var{definition} are expanded.
770
771 Please note the following nuances of macro usage:
772
773 @itemize @bullet
774 @item
775 For the purposes of this section, @dfn{macro} and @dfn{environment
776 variable} are synonyms.
777
778 @item
779 Macros may not take arguments.
780
781 @item
782 Macros may not recurse.
783
784 @item
785 Macros are just environment variable definitions like other environment
786 variable definitions, with the exception that they are limited in scope
787 to the @file{devices} configuration file.
788
789 @item
790 Macros override other all environment variables of the same name (within
791 the scope of @file{devices}).
792
793 @item
794 Earlier macro definitions for a particular @var{key} override later
795 ones.  In particular, macro definitions on the command line override
796 those in the device definition file.  @xref{Non-option Arguments}.
797
798 @item
799 There are two predefined macros, whose values are determined at runtime:
800
801 @table @samp
802 @item viewwidth
803 Defined as the width of the console screen, in columns of text.
804
805 @item viewlength
806 Defined as the length of the console screen, in lines of text.
807 @end table
808 @end itemize
809
810 @node Device definitions, Dimensions, Macro definitions, Output devices
811 @subsection Driver definitions
812
813 Driver definitions are the ultimate purpose of the @file{devices}
814 configuration file.  These are where the real action is.  Driver
815 definitions tell PSPP where it should send its output.
816
817 Each driver definition line is divided into four fields.  These fields
818 are delimited by colons (@samp{:}).  Each line is subjected to
819 environment variable interpolation before it is processed further
820 (@pxref{Environment substitutions}).  From left to right, the four
821 fields are, in brief:
822
823 @table @i
824 @item driver name
825 A unique identifier, used to determine whether to enable the driver.
826
827 @item class name
828 One of the predefined driver classes supported by PSPP.  The
829 currently supported driver classes include `postscript' and `ascii'.
830
831 @item device type(s)
832 Zero or more of the following keywords, delimited by spaces:
833
834 @table @code
835 @item screen
836
837 Indicates that the device is a screen display.  This may reduce the
838 amount of buffering done by the driver, to make interactive use more
839 convenient.
840
841 @item printer
842
843 Indicates that the device is a printer.
844
845 @item listing
846
847 Indicates that the device is a listing file.
848 @end table
849
850 These options are just hints to PSPP and do not cause the output to be
851 directed to the screen, or to the printer, or to a listing file---those
852 must be set elsewhere in the options.  They are used primarily to decide
853 which devices should be enabled at any given time.  @xref{SET}, for more
854 information.
855
856 @item options
857 An optional set of options to pass to the driver itself.  The exact
858 format for the options varies among drivers.
859 @end table
860
861 The driver is enabled if:
862
863 @enumerate
864 @item
865 Its driver name is specified on the command line, or
866
867 @item
868 It's in a category specified on the command line, or
869
870 @item
871 If no categories or driver names are specified on the command line, it
872 is in category @code{default}.
873 @end enumerate
874
875 For more information on driver names, see @ref{Driver categories}.
876
877 The class name must be one of those supported by PSPP.  The
878 classes supported depend on the options with which PSPP was
879 compiled.  See later sections in this chapter for descriptions of the
880 available driver classes.
881
882 Options are dependent on the driver.  See the driver descriptions for
883 details.
884
885 @node Dimensions, papersize, Device definitions, Output devices
886 @subsection Dimensions
887
888 Quite often in configuration it is necessary to specify a length or a
889 size.  PSPP uses a common syntax for all such, calling them
890 collectively by the name @dfn{dimensions}.
891
892 @itemize @bullet
893 @item
894 You can specify dimensions in decimal form (@samp{12.5}) or as
895 fractions, either as mixed numbers (@samp{12-1/2}) or raw fractions
896 (@samp{25/2}).
897
898 @item 
899 A number of different units are available.  These are suffixed to the
900 numeric part of the dimension.  There must be no spaces between the
901 number and the unit.  The available units are identical to those offered
902 by the popular typesetting system @TeX{}:
903
904 @table @code
905 @item in
906 inch (1 @code{in} = 2.54 @code{cm})
907
908 @item "
909 inch (1 @code{in} = 2.54 @code{cm})
910
911 @item pt
912 printer's point (1 @code{in} = 72.27 @code{pt})
913
914 @item pc
915 pica (12 @code{pt} = 1 @code{pc})
916
917 @item bp
918 PostScript point (1 @code{in} = 72 @code{bp})
919
920 @item cm
921 centimeter
922
923 @item mm
924 millimeter (10 @code{mm} = 1 @code{cm})
925
926 @item dd
927 didot point (1157 @code{dd} = 1238 @code{pt})
928
929 @item cc
930 cicero (1 @code{cc} = 12 @code{dd})
931
932 @item sp
933 scaled point (65536 @code{sp} = 1 @code{pt})
934 @end table
935
936 @item
937 If no explicit unit is given, PSPP attempts to guess the best unit:
938
939 @itemize @minus
940 @item
941 Numbers less than 50 are assumed to be in inches.
942
943 @item
944 Numbers 50 or greater are assumed to be in millimeters.
945 @end itemize
946 @end itemize
947
948 @node papersize, Distinguishing line types, Dimensions, Output devices
949 @subsection Paper sizes
950
951 Output drivers usually deal with some sort of hardcopy media.  This
952 media is called @dfn{paper} by the drivers, though in reality it could
953 be a transparency or film or thinly veiled sarcasm.  To make it easier
954 for you to deal with paper, PSPP allows you to have (of course!) a
955 configuration file that gives symbolic names, like ``letter'' or
956 ``legal'' or ``a4'', to paper sizes, rather than forcing you to use
957 cryptic numbers like ``8-1/2 x 11'' or ``210 by 297''.  Surprisingly
958 enough, this configuration file is named @file{papersize}.
959 @xref{Configuration files}.
960
961 When PSPP tries to connect a symbolic paper name to a paper size, it
962 reads and parses each non-comment line in the file, in order.  The first
963 field on each line must be a symbolic paper name in double quotes.
964 Paper names may not contain double quotes.  Paper names are not
965 case-sensitive: @samp{legal} and @samp{Legal} are equivalent.
966
967 If a match is found for the paper name, the rest of the line is parsed.
968 If it is found to be a pair of dimensions (@pxref{Dimensions}) separated
969 by either @samp{x} or @samp{by}, then those are taken to be the paper
970 size, in order of width followed by length.  There @emph{must} be at
971 least one space on each side of @samp{x} or @samp{by}.
972
973 Otherwise the line must be of the form
974 @samp{"@var{paper-1}"="@var{paper-2}"}.  In this case the target of the
975 search becomes paper name @var{paper-2} and the search through the file
976 continues.
977
978 @node Distinguishing line types, Tokenizing lines, papersize, Output devices
979 @subsection How lines are divided into types
980
981 The lines in @file{devices} are distinguished in the following manner:
982
983 @enumerate
984 @item
985 Leading whitespace is removed.
986
987 @item
988 If the resulting line begins with the exact string @code{define},
989 followed by one or more whitespace characters, the line is processed as
990 a macro definition.
991
992 @item
993 Otherwise, the line is scanned for the first instance of a colon
994 (@samp{:}) or an equals sign (@samp{=}).
995
996 @item
997 If a colon is encountered first, the line is processed as a driver
998 definition.
999
1000 @item
1001 Otherwise, if an equals sign is encountered, the line is processed as a
1002 macro definition.
1003
1004 @item
1005 Otherwise, the line is ill-formed.
1006 @end enumerate
1007
1008 @node Tokenizing lines,  , Distinguishing line types, Output devices
1009 @subsection How lines are divided into tokens
1010
1011 Each driver definition line is run through a simple tokenizer.  This
1012 tokenizer recognizes two basic types of tokens.
1013
1014 The first type is an equals sign (@samp{=}).  Equals signs are both
1015 delimiters between tokens and tokens in themselves.
1016
1017 The second type is an identifier or string token.  Identifiers and
1018 strings are equivalent after tokenization, though they are written
1019 differently.  An identifier is any string of characters other than
1020 whitespace or equals sign.
1021
1022 A string is introduced by a single- or double-quote character (@samp{'}
1023 or @samp{"}) and, in general, continues until the next occurrence of
1024 that same character.  The following standard C escapes can also be
1025 embedded within strings:
1026
1027 @table @code
1028 @item \'
1029 A single-quote (@samp{'}).
1030
1031 @item \"
1032 A double-quote (@samp{"}).
1033
1034 @item \?
1035 A question mark (@samp{?}).  Included for hysterical raisins.
1036
1037 @item \\
1038 A backslash (@samp{\}).
1039
1040 @item \a
1041 Audio bell (ASCII 7).
1042
1043 @item \b
1044 Backspace (ASCII 8).
1045
1046 @item \f
1047 Formfeed (ASCII 12).
1048
1049 @item \n
1050 New-line (ASCII 10)
1051
1052 @item \r
1053 Carriage return (ASCII 13).
1054
1055 @item \t
1056 Tab (ASCII 9).
1057
1058 @item \v
1059 Vertical tab (ASCII 11).
1060
1061 @item \@var{o}@var{o}@var{o}
1062 Each @samp{o} must be an octal digit.  The character is the one having
1063 the octal value specified.  Any number of octal digits is read and
1064 interpreted; only the lower 8 bits are used.
1065
1066 @item \x@var{h}@var{h}
1067 Each @samp{h} must be a hex digit.  The character is the one having the
1068 hexadecimal value specified.  Any number of hex digits is read and
1069 interpreted; only the lower 8 bits are used.
1070 @end table
1071
1072 Tokens, outside of quoted strings, are delimited by whitespace or equals
1073 signs.
1074
1075 @node PostScript driver class, ASCII driver class, Output devices, Configuration
1076 @section The PostScript driver class
1077
1078 The @code{postscript} driver class is used to produce output that is
1079 acceptable to PostScript printers and to PC-based PostScript
1080 interpreters such as Ghostscript.  Continuing a long tradition,
1081 PSPP's PostScript driver is configurable to the point of
1082 absurdity.
1083
1084 There are actually two PostScript drivers.  The first one,
1085 @samp{postscript}, produces ordinary DSC-compliant PostScript output.
1086 The second one @samp{epsf}, produces an Encapsulated PostScript file.
1087 The two drivers are otherwise identical in configuration and in
1088 operation.
1089
1090 The PostScript driver is described in further detail below.
1091
1092 @menu
1093 * PS output options::           Output file options.
1094 * PS page options::             Paper, margins, scaling & rotation, more!
1095 * PS file options::             Configuration files.
1096 * PS font options::             Default fonts, font options.
1097 * PS line options::             Line widths, options.
1098 * Prologue::                    Details on the PostScript prologue.
1099 * Encodings::                   Details on PostScript font encodings.
1100 @end menu
1101
1102 @node PS output options, PS page options, PostScript driver class, PostScript driver class
1103 @subsection PostScript output options
1104
1105 These options deal with the form of the output and the output file
1106 itself:
1107
1108 @table @code
1109 @item output-file=@var{filename}
1110
1111 File to which output should be sent.  This can be an ordinary filename
1112 (i.e., @code{"pspp.ps"}), a pipe filename (i.e., @code{"|lpr"}), or
1113 stdout (@code{"-"}).  Default: @code{"pspp.ps"}.
1114
1115 @item color=@var{boolean}
1116
1117 Most of the time black-and-white PostScript devices are smart enough to
1118 map colors to shades themselves.  However, you can cause the PSPP
1119 output driver to do an ugly simulation of this in its own driver by
1120 turning @code{color} off.  Default: @code{on}.
1121
1122 This is a boolean setting, as are many settings in the PostScript
1123 driver.  Valid positive boolean values are @samp{on}, @samp{true},
1124 @samp{yes}, and nonzero integers.  Negative boolean values are
1125 @samp{off}, @samp{false}, @samp{no}, and zero.
1126
1127 @item data=@var{data-type}
1128
1129 One of @code{clean7bit}, @code{clean8bit}, or @code{binary}.  This
1130 controls what characters will be written to the output file.  PostScript
1131 produced with @code{clean7bit} can be transmitted over 7-bit
1132 transmission channels that use ASCII control characters for line
1133 control.  @code{clean8bit} is similar but allows characters above 127 to
1134 be written to the output file.  @code{binary} allows any character in
1135 the output file.  Default: @code{clean7bit}.
1136
1137 @item line-ends=@var{line-end-type}
1138
1139 One of @code{cr}, @code{lf}, or @code{crlf}.  This controls what is used
1140 for new-line in the output file.  Default: @code{cr}.
1141
1142 @item optimize-line-size=@var{level}
1143
1144 Either @code{0} or @code{1}.  If @var{level} is @code{1}, then short
1145 line segments will be collected and merged into longer ones.  This
1146 reduces output file size but requires more time and memory.  A
1147 @var{level} of @code{0} has the advantage of being better for
1148 interactive environments.  @code{1} is the default unless the
1149 @code{screen} flag is set; in that case, the default is @code{0}.
1150
1151 @item optimize-text-size=@var{level}
1152
1153 One of @code{0}, @code{1}, or @code{2}, each higher level representing
1154 correspondingly more aggressive space savings for text in the output
1155 file and requiring correspondingly more time and memory.  Unfortunately
1156 the levels presently are all the same.  @code{1} is the default unless
1157 the @code{screen} flag is set; in that case, the default is @code{0}.
1158 @end table
1159
1160 @node PS page options, PS file options, PS output options, PostScript driver class
1161 @subsection PostScript page options
1162
1163 These options affect page setup:
1164
1165 @table @code
1166 @item headers=@var{boolean}
1167
1168 Controls whether the standard headers showing the time and date and
1169 title and subtitle are printed at the top of each page.  Default:
1170 @code{on}.
1171
1172 @item paper-size=@var{paper-size}
1173
1174 Paper size, either as a symbolic name (i.e., @code{letter} or @code{a4})
1175 or specific measurements (i.e., @code{8-1/2x11} or @code{"210 x 297"}.
1176 @xref{papersize, , Paper sizes}.  Default: @code{letter}.
1177
1178 @item orientation=@var{orientation}
1179
1180 Either @code{portrait} or @code{landscape}.  Default: @code{portrait}.
1181
1182 @item left-margin=@var{dimension}
1183 @itemx right-margin=@var{dimension}
1184 @itemx top-margin=@var{dimension}
1185 @itemx bottom-margin=@var{dimension}
1186
1187 Sets the margins around the page.  The headers, if enabled, are not
1188 included in the margins; they are in addition to the margins.  For a
1189 description of dimensions, see @ref{Dimensions}.  Default: @code{0.5in}.
1190
1191 @end table
1192
1193 @node PS file options, PS font options, PS page options, PostScript driver class
1194 @subsection PostScript file options
1195
1196 Oh, my.  You don't really want to know about the way that the PostScript
1197 driver deals with files, do you?  Well I suppose you're entitled, but I
1198 warn you right now: it's not pretty.  Here goes@enddots{}
1199
1200 First let's look at the options that are available:
1201
1202 @table @code
1203
1204 @item font-dir=@var{font-directory}
1205
1206 Sets the font directory.  Default: @code{devps}.
1207
1208 @item prologue-file=@var{prologue-file-name}
1209
1210 Sets the name of the PostScript prologue file.  You can write your own
1211 prologue, though I have no idea why you'd want to: see @ref{Prologue}.
1212 Default: @code{ps-prologue}.
1213
1214 @item device-file=@var{device-file-name}
1215
1216 Sets the name of the Groff-format device description file.  The
1217 PostScript driver reads this to know about the scaling of fonts
1218 and so on.  The format of such files is described in groff_font(5),
1219 included with Groff.  Default: @code{DESC}.
1220
1221 @item encoding-file=@var{encoding-file-name}
1222
1223 Sets the name of the encoding file.  This file contains a list of all
1224 font encodings that will be needed so that the driver can put all of
1225 them at the top of the prologue.  @xref{Encodings}.  Default:
1226 @code{ps-encodings}.
1227
1228 If the specified encoding file cannot be found, this error will be
1229 silently ignored, since most people do not need any encodings besides
1230 the ones that can be found using @code{auto-encodings}, described below.
1231
1232 @item auto-encode=@var{boolean}
1233
1234 When enabled, the font encodings needed by the default proportional- and
1235 fixed-pitch fonts will automatically be dumped to the PostScript
1236 output.  Otherwise, it is assumed that the user has an encoding file
1237 and knows how to use it (@pxref{Encodings}).  There is probably no good
1238 reason to turn off this convenient feature.  Default: @code{on}.
1239
1240 @end table
1241
1242 Next I suppose it's time to describe the search algorithm.  When the
1243 PostScript driver needs a file, whether that file be a font, a
1244 PostScript prologue, or what you will, it searches in this manner:
1245
1246 @enumerate
1247
1248 @item
1249 Constructs a path by taking the first of the following that is defined:
1250
1251 @enumerate a
1252
1253 @item
1254 Environment variable @code{STAT_GROFF_FONT_PATH}.  @xref{Environment
1255 variables}.
1256
1257 @item
1258 Environment variable @code{GROFF_FONT_PATH}.
1259
1260 @item
1261 The compiled-in fallback default.
1262 @end enumerate
1263
1264 @item
1265 Constructs a base name from concatenating, in order, the font directory,
1266 a path separator (@samp{/} or @samp{\}), and the file to be found.  A
1267 typical base name would be something like @code{devps/ps-encodings}.
1268
1269 @item
1270 Searches for the base name in the path constructed above.  If the file
1271 is found, the algorithm terminates.
1272
1273 @item
1274 Searches for the base name in the standard configuration path.  See
1275 @ref{File locations}, for more details.  If the file is found, the
1276 algorithm terminates.
1277
1278 @item
1279 At this point we remove the font directory and path separator from the
1280 base name.  Now the base name is simply the file to be found, i.e.,
1281 @code{ps-encodings}.
1282
1283 @item
1284 Searches for the base name in the path constructed in the first step.
1285 If the file is found, the algorithm terminates.
1286
1287 @item
1288 Searches for the base name in the standard configuration path.  If the
1289 file is found, the algorithm terminates.
1290
1291 @item
1292 The algorithm terminates unsuccessfully.
1293 @end enumerate
1294
1295 So, as you see, there are several ways to configure the PostScript
1296 drivers.  Careful selection of techniques can make the configuration
1297 very flexible indeed.
1298
1299 @node PS font options, PS line options, PS file options, PostScript driver class
1300 @subsection PostScript font options
1301
1302 The list of available font options is short and sweet:
1303
1304 @table @code
1305 @item prop-font=@var{font-name}
1306
1307 Sets the default proportional font.  The name should be that of a
1308 PostScript font.  Default: @code{"Helvetica"}.
1309
1310 @item fixed-font=@var{font-name}
1311
1312 Sets the default fixed-pitch font.  The name should be that of a
1313 PostScript font.  Default: @code{"Courier"}.
1314
1315 @item font-size=@var{font-size}
1316
1317 Sets the size of the default fonts, in thousandths of a point.  Default:
1318 @code{10000}.
1319
1320 @end table
1321
1322 @node PS line options, Prologue, PS font options, PostScript driver class
1323 @subsection PostScript line options
1324
1325 Most tables contain lines, or rules, between cells.  Some features of
1326 the way that lines are drawn in PostScript tables are user-definable:
1327
1328 @table @code
1329
1330 @item line-style=@var{style}
1331
1332 Sets the style used for lines used to divide tables into sections.
1333 @var{style} must be either @code{thick}, in which case thick lines are
1334 used, or @var{double}, in which case double lines are used.  Default:
1335 @code{thick}.
1336
1337 @item line-gutter=@var{dimension}
1338
1339 Sets the line gutter, which is the amount of whitespace on either side
1340 of lines that border text or graphics objects.  @xref{Dimensions}.
1341 Default: @code{0.5pt}.
1342
1343 @item line-spacing=@var{dimension}
1344
1345 Sets the line spacing, which is the amount of whitespace that separates
1346 lines that are side by side, as in a double line.  Default:
1347 @code{0.5pt}.
1348
1349 @item line-width=@var{dimension}
1350
1351 Sets the width of a typical line used in tables.  Default: @code{0.5pt}.
1352
1353 @item line-width-thick=@var{dimension}
1354
1355 Sets the width of a thick line used in tables.  Not used if
1356 @code{line-style} is set to @code{thick}.  Default: @code{1.5pt}.
1357
1358 @end table
1359
1360 @node Prologue, Encodings, PS line options, PostScript driver class
1361 @subsection The PostScript prologue
1362
1363 Most PostScript files that are generated mechanically by programs
1364 consist of two parts: a prologue and a body.  The prologue is generally
1365 a collection of boilerplate.  Only the body differs greatly between
1366 two outputs from the same program.
1367  
1368 This is also the strategy used in the PSPP PostScript driver.  In
1369 general, the prologue supplied with PSPP will be more than sufficient.
1370 In this case, you will not need to read the rest of this section.
1371 However, hackers might want to know more.  Read on, if you fall into
1372 this category.
1373
1374 The prologue is dumped into the output stream essentially unmodified.
1375 However, two actions are performed on its lines.  First, certain lines
1376 may be omitted as specified in the prologue file itself.  Second,
1377 variables are substituted.
1378
1379 The following lines are omitted:
1380
1381 @enumerate
1382 @item
1383 All lines that contain three bangs in a row (@code{!!!}).
1384
1385 @item
1386 Lines that contain @code{!eps}, if the PostScript driver is producing
1387 ordinary PostScript output.  Otherwise an EPS file is being produced,
1388 and the line is included in the output, although everything following
1389 @code{!eps} is deleted.
1390
1391 @item
1392 Lines that contain @code{!ps}, if the PostScript driver is producing EPS
1393 output.  Otherwise, ordinary PostScript is being produced, and the line
1394 is included in the output, although everything following @code{!ps} is
1395 deleted.
1396 @end enumerate
1397
1398 The following are the variables that are substituted.  Only the
1399 variables listed are substituted; environment variables are not.
1400 @xref{Environment substitutions}.
1401
1402 @table @code
1403 @item bounding-box
1404
1405 The page bounding box, in points, as four space-separated numbers.  For
1406 U.S. letter size paper, this is @samp{0 0 612 792}.
1407
1408 @item creator
1409
1410 PSPP version as a string: @samp{GNU PSPP 0.1b}, for example.
1411
1412 @item date
1413
1414 Date the file was created.  Example: @samp{Tue May 21 13:46:22 1991}.
1415
1416 @item data
1417
1418 Value of the @code{data} PostScript driver option, as one of the strings
1419 @samp{Clean7Bit}, @samp{Clean8Bit}, or @samp{Binary}.
1420
1421 @item orientation
1422
1423 Page orientation, as one of the strings @code{Portrait} or
1424 @code{Landscape}.
1425
1426 @item user
1427
1428 Under multiuser OSes, the user's login name, taken either from the
1429 environment variable @code{LOGNAME} or, if that fails, the result of the
1430 C library function @code{getlogin()}.  Defaults to @samp{nobody}.
1431
1432 @item host
1433
1434 System hostname as reported by @code{gethostname()}.  Defaults to
1435 @samp{nowhere}.
1436
1437 @item prop-font
1438
1439 Name of the default proportional font, prefixed by the word
1440 @samp{font} and a space.  Example: @samp{font Times-Roman}.
1441
1442 @item fixed-font
1443
1444 Name of the default fixed-pitch font, prefixed by the word @samp{font}
1445 and a space.
1446
1447 @item scale-factor
1448
1449 The page scaling factor as a floating-point number.  Example:
1450 @code{1.0}.  Note that this is also passed as an argument to the BP
1451 macro.
1452
1453 @item paper-length
1454 @item paper-width
1455
1456 The paper length and paper width, respectively, in thousandths of a
1457 point.  Note that these are also passed as arguments to the BP macro.
1458
1459 @item left-margin
1460 @item top-margin
1461
1462 The left margin and top margin, respectively, in thousandths of a
1463 point.  Note that these are also passed as arguments to the BP macro.
1464
1465 @item title
1466
1467 Document title as a string.  This is not the title specified in the
1468 PSPP syntax file.  A typical title is the word @samp{PSPP} followed
1469 by the syntax file name in parentheses.  Example: @samp{PSPP
1470 (<stdin>)}.
1471
1472 @item source-file
1473
1474 PSPP syntax file name.  Example: @samp{mary96/first.stat}.
1475
1476 @end table
1477
1478 Any other questions about the PostScript prologue can best be answered
1479 by examining the default prologue or the PSPP source.
1480
1481 @node Encodings,  , Prologue, PostScript driver class
1482 @subsection PostScript encodings
1483
1484 PostScript fonts often contain many more than 256 characters, in order
1485 to accommodate foreign language characters and special symbols.
1486 PostScript uses @dfn{encodings} to map these onto single-byte symbol
1487 sets.  Each font can have many different encodings applied to it.
1488
1489 PSPP's PostScript driver needs to know which encoding to apply to each
1490 font.  It can determine this from the information encapsulated in the
1491 Groff font description that it reads.  However, there is an additional
1492 problem---for efficiency, the PostScript driver needs to have a complete
1493 list of all encodings that will be used in the entire session @emph{when
1494 it opens the output file}.  For this reason, it can't use the
1495 information built into the fonts because it doesn't know which fonts
1496 will be used.
1497
1498 As a stopgap solution, there are two mechanisms for specifying which
1499 encodings will be used.  The first mechanism is automatic and it is the
1500 only one that most PSPP users will ever need.  The second mechanism is
1501 manual, but it is more flexible.  Either mechanism or both may be used
1502 at one time.
1503
1504 The first mechanism is activated by the @samp{auto-encode} driver option
1505 (@pxref{PS file options}).  When enabled, @samp{auto-encode} causes the
1506 PostScript driver to include the encodings used by the default
1507 proportional and fixed-pitch fonts (@pxref{PS font options}).  Many
1508 PSPP output files will only need these encodings.
1509
1510 The second mechanism is the file specified by the @samp{encoding-file}
1511 option (@pxref{PS file options}).  If it exists, this file must consist
1512 of lines in PSPP configuration-file format (@pxref{Configuration
1513 files}).  Each line that is not a comment should name a PostScript
1514 encoding to include in the output.
1515
1516 It is not an error if an encoding is included more than once, by either
1517 mechanism.  It will appear only once in the output.  It is also not an
1518 error if an encoding is included in the output but never used.  It
1519 @emph{is} an error if an encoding is used but not included by one of
1520 these mechanisms.  In this case, the built-in PostScript encoding
1521 @samp{ISOLatin1Encoding} is substituted.
1522
1523 @node ASCII driver class, HTML driver class, PostScript driver class, Configuration
1524 @section The ASCII driver class
1525
1526 The ASCII driver class produces output that can be displayed on a
1527 terminal or output to printers.  All of its options are highly
1528 configurable.  The ASCII driver has class name @samp{ascii}.
1529
1530 The ASCII driver is described in further detail below.
1531
1532 @menu
1533 * ASCII output options::        Output file options.
1534 * ASCII page options::          Page size, margins, more.
1535 * ASCII font options::          Box character, bold & italics.
1536 @end menu
1537
1538 @node ASCII output options, ASCII page options, ASCII driver class, ASCII driver class
1539 @subsection ASCII output options
1540
1541 @table @code
1542 @item output-file=@var{filename}
1543
1544 File to which output should be sent.  This can be an ordinary filename
1545 (e.g., @code{"pspp.txt"}), a pipe filename (e.g., @code{"|lpr"}), or
1546 stdout (@code{"-"}).  Default: @code{"pspp.list"}.
1547
1548 @item char-set=@var{char-set-type}
1549
1550 One of @samp{ascii} or @samp{latin1}.  This has no effect on output at
1551 the present time.  Default: @code{ascii}.
1552
1553 @item form-feed-string=@var{form-feed-value}
1554
1555 The string written to the output to cause a formfeed.  See also
1556 @code{paginate}, described below, for a related setting.  Default:
1557 @code{"\f"}.
1558
1559 @item newline-string=@var{new-line-value}
1560
1561 The string written to the output to cause a new-line (carriage return
1562 plus linefeed).  The default, which can be specified explicitly with
1563 @code{newline-string=default}, is to use the system-dependent new-line
1564 sequence by opening the output file in text mode.  This is usually the
1565 right choice.
1566
1567 However, @code{newline-string} can be set to any string.  When this is
1568 done, the output file is opened in binary mode.
1569
1570 @item paginate=@var{boolean}
1571
1572 If set, a formfeed (as set in @code{form-feed-string}, described above)
1573 will be written to the device after every page.  Default: @code{on}.
1574
1575 @item tab-width=@var{tab-width-value}
1576
1577 The distance between tab stops for this device.  If set to 0, tabs will
1578 not be used in the output.  Default: @code{8}.
1579
1580 @item init=@var{initialization-string}.
1581
1582 String written to the device before anything else, at the beginning of
1583 the output.  Default: @code{""} (the empty string).
1584
1585 @item done=@var{finalization-string}.
1586
1587 String written to the device after everything else, at the end of the
1588 output.  Default: @code{""} (the empty string).
1589 @end table
1590
1591 @node ASCII page options, ASCII font options, ASCII output options, ASCII driver class
1592 @subsection ASCII page options
1593
1594 These options affect page setup:
1595
1596 @table @code
1597 @item headers=@var{boolean}
1598
1599 If enabled, two lines of header information giving title and subtitle,
1600 page number, date and time, and PSPP version are printed at the top of
1601 every page.  These two lines are in addition to any top margin
1602 requested.  Default: @code{on}.
1603
1604 @item length=@var{line-count}
1605
1606 Physical length of a page, in lines.  Headers and margins are subtracted
1607 from this value.  Default: @code{66}.
1608
1609 @item width=@var{character-count}
1610
1611 Physical width of a page, in characters.  Margins are subtracted from
1612 this value.  Default: @code{130}.
1613
1614 @item lpi=@var{lines-per-inch}
1615
1616 Number of lines per vertical inch.  Not currently used.  Default: @code{6}.
1617
1618 @item cpi=@var{characters-per-inch}
1619
1620 Number of characters per horizontal inch.  Not currently used.  Default:
1621 @code{10}.
1622
1623 @item left-margin=@var{left-margin-width}
1624
1625 Width of the left margin, in characters.  PSPP subtracts this value
1626 from the page width.  Default: @code{0}.
1627
1628 @item right-margin=@var{right-margin-width}
1629
1630 Width of the right margin, in characters.  PSPP subtracts this value
1631 from the page width.  Default: @code{0}.
1632
1633 @item top-margin=@var{top-margin-lines}
1634
1635 Length of the top margin, in lines.  PSPP subtracts this value from
1636 the page length.  Default: @code{2}.
1637
1638 @item bottom-margin=@var{bottom-margin-lines}
1639
1640 Length of the bottom margin, in lines.  PSPP subtracts this value from
1641 the page length.  Default: @code{2}.
1642
1643 @end table
1644
1645 @node ASCII font options,  , ASCII page options, ASCII driver class
1646 @subsection ASCII font options
1647
1648 These are the ASCII font options:
1649
1650 @table @code
1651 @item box[@var{line-type}]=@var{box-chars}
1652
1653 The characters used for lines in tables produced by the ASCII driver can
1654 be changed using this option.  @var{line-type} is used to indicate which
1655 type of line to change; @var{box-chars} is the character or string of
1656 characters to use for this type of line.
1657
1658 @var{line-type} must be a 4-digit number in base 4.  The digits are in
1659 the order `right', `bottom', `left', `top'.  The four possibilities for
1660 each digit are:
1661
1662 @table @asis
1663 @item 0
1664 No line.
1665
1666 @item 1
1667 Single line.
1668
1669 @item 2
1670 Double line.
1671
1672 @item 3
1673 Special device-defined line, if one is available; otherwise, a double
1674 line.
1675 @end table
1676
1677 Examples:
1678
1679 @table @code
1680 @item box[0101]="|"
1681
1682 Sets @samp{|} as the character to use for a single-width line with
1683 bottom and top components.
1684
1685 @item box[2222]="#"
1686
1687 Sets @samp{#} as the character to use for the intersection of four
1688 double-width lines, one each from the top, bottom, left and right.
1689
1690 @item box[1100]="\xda"
1691
1692 Sets @samp{"\xda"}, which under MS-DOS is a box character suitable for
1693 the top-left corner of a box, as the character for the intersection of
1694 two single-width lines, one each from the right and bottom.
1695
1696 @end table
1697
1698 Defaults:
1699
1700 @itemize @bullet
1701 @item
1702 @code{box[0000]=" "}
1703
1704 @item
1705 @code{box[1000]="-"}
1706 @*@code{box[0010]="-"}
1707 @*@code{box[1010]="-"}
1708
1709 @item
1710 @code{box[0100]="|"}
1711 @*@code{box[0001]="|"}
1712 @*@code{box[0101]="|"}
1713
1714 @item
1715 @code{box[2000]="="}
1716 @*@code{box[0020]="="}
1717 @*@code{box[2020]="="}
1718
1719 @item
1720 @code{box[0200]="#"}
1721 @*@code{box[0002]="#"}
1722 @*@code{box[0202]="#"}
1723
1724 @item
1725 @code{box[3000]="="}
1726 @*@code{box[0030]="="}
1727 @*@code{box[3030]="="}
1728
1729 @item
1730 @code{box[0300]="#"}
1731 @*@code{box[0003]="#"}
1732 @*@code{box[0303]="#"}
1733
1734 @item
1735 For all others, @samp{+} is used unless there are double lines or
1736 special lines, in which case @samp{#} is used.
1737 @end itemize
1738
1739 @item italic-on=@var{italic-on-string}
1740
1741 Character sequence written to turn on italics or underline printing.  If
1742 this is set to @code{overstrike}, then the driver will simulate
1743 underlining by overstriking with underscore characters (@samp{_}) in the
1744 manner described by @code{overstrike-style} and
1745 @code{carriage-return-style}.  Default: @code{overstrike}.
1746
1747 @item italic-off=@var{italic-off-string}
1748
1749 Character sequence to turn off italics or underline printing.  Default:
1750 @code{""} (the empty string).
1751
1752 @item bold-on=@var{bold-on-string}
1753
1754 Character sequence written to turn on bold or emphasized printing.  If
1755 set to @code{overstrike}, then the driver will simulated bold printing
1756 by overstriking characters in the manner described by
1757 @code{overstrike-style} and @code{carriage-return-style}.  Default:
1758 @code{overstrike}.
1759
1760 @item bold-off=@var{bold-off-string}
1761
1762 Character sequence to turn off bold or emphasized printing.  Default:
1763 @code{""} (the empty string).
1764
1765 @item bold-italic-on=@var{bold-italic-on-string}
1766
1767 Character sequence written to turn on bold-italic printing.  If set to
1768 @code{overstrike}, then the driver will simulate bold-italics by
1769 overstriking twice, once with the character, a second time with an
1770 underscore (@samp{_}) character, in the manner described by
1771 @code{overstrike-style} and @code{carriage-return-style}.  Default:
1772 @code{overstrike}.
1773
1774 @item bold-italic-off=@var{bold-italic-off-string}
1775
1776 Character sequence to turn off bold-italic printing.  Default: @code{""}
1777 (the empty string).
1778
1779 @item overstrike-style=@var{overstrike-option}
1780
1781 Either @code{single} or @code{line}:
1782
1783 @itemize @bullet
1784 @item
1785 If @code{single} is selected, then, to overstrike a line of text, the
1786 output driver will output a character, backspace, overstrike, output a
1787 character, backspace, overstrike, and so on along a line.
1788
1789 @item
1790 If @code{line} is selected then the output driver will output an entire
1791 line, then backspace or emit a carriage return (as indicated by
1792 @code{carriage-return-style}), then overstrike the entire line at once.
1793 @end itemize
1794
1795 @code{single} is recommended for use with ttys and programs that
1796 understand overstriking in text files, such as the pager @code{less}.
1797 @code{single} will also work with printer devices but results in rapid
1798 back-and-forth motions of the printhead that can cause the printer to
1799 physically overheat!
1800
1801 @code{line} is recommended for use with printer devices.  Most programs
1802 that understand overstriking in text files will not properly deal with
1803 @code{line} mode.  
1804
1805 Default: @code{single}.
1806
1807 @item carriage-return-style=@var{carriage-return-type}
1808
1809 Either @code{bs} or @code{cr}.  This option applies only when one or
1810 more of the font commands is set to @code{overstrike} and, at the same
1811 time, @code{overstrike-style} is set to @code{line}.
1812
1813 @itemize @bullet
1814 @item
1815 If @code{bs} is selected then the driver will return to the beginning of
1816 a line by emitting a sequence of backspace characters (ASCII 8).
1817
1818 @item
1819 If @code{cr} is selected then the driver will return to the beginning of
1820 a line by emitting a single carriage-return character (ASCII 13).
1821 @end itemize
1822
1823 Although @code{cr} is preferred as being more compact, @code{bs} is more
1824 general since some devices do not interpret carriage returns in the
1825 desired manner.  Default: @code{bs}.
1826 @end table
1827
1828 @node HTML driver class, Miscellaneous configuring, ASCII driver class, Configuration
1829 @section The HTML driver class
1830
1831 The @code{html} driver class is used to produce output for viewing in
1832 tables-capable web browsers such as Emacs' w3-mode.  Its configuration
1833 is very simple.  Currently, the output has a very plain format.  In the
1834 future, further work may be done on improving the output appearance.
1835
1836 There are few options for use with the @code{html} driver class:
1837
1838 @table @code
1839 @item output-file=@var{filename}
1840
1841 File to which output should be sent.  This can be an ordinary filename
1842 (i.e., @code{"pspp.ps"}), a pipe filename (i.e., @code{"|lpr"}), or
1843 stdout (@code{"-"}).  Default: @code{"pspp.html"}.
1844
1845 @item prologue-file=@var{prologue-file-name}
1846
1847 Sets the name of the PostScript prologue file.  You can write your own
1848 prologue if you want to customize colors or other settings: see
1849 @ref{HTML Prologue}.  Default: @code{html-prologue}.
1850 @end table
1851
1852 @menu
1853 * HTML Prologue::               Format of the HTML prologue file.
1854 @end menu
1855
1856 @node HTML Prologue,  , HTML driver class, HTML driver class
1857 @subsection The HTML prologue
1858
1859 HTML files that are generated by PSPP consist of two parts: a prologue
1860 and a body.  The prologue is a collection of boilerplate.  Only the body
1861 differs greatly between two outputs.  You can tune the colors and other
1862 attributes of the output by editing the prologue.
1863  
1864 The prologue is dumped into the output stream essentially unmodified.
1865 However, two actions are performed on its lines.  First, certain lines
1866 may be omitted as specified in the prologue file itself.  Second,
1867 variables are substituted.
1868
1869 The following lines are omitted:
1870
1871 @enumerate
1872 @item
1873 All lines that contain three bangs in a row (@code{!!!}).
1874
1875 @item
1876 Lines that contain @code{!title}, if no title is set for the output.  If
1877 a title is set, then the characters @code{!title} are removed before the
1878 line is output.
1879
1880 @item
1881 Lines that contain @code{!subtitle}, if no subtitle is set for the
1882 output.  If a subtitle is set, then the characters @code{!subtitle} are
1883 removed before the line is output.
1884 @end enumerate
1885
1886 The following are the variables that are substituted.  Only the
1887 variables listed are substituted; environment variables are not.
1888 @xref{Environment substitutions}.
1889
1890 @table @code
1891 @item generator
1892
1893 PSPP version as a string: @samp{GNU PSPP 0.1b}, for example.
1894
1895 @item date
1896
1897 Date the file was created.  Example: @samp{Tue May 21 13:46:22 1991}.
1898
1899 @item user
1900
1901 Under multiuser OSes, the user's login name, taken either from the
1902 environment variable @code{LOGNAME} or, if that fails, the result of the
1903 C library function @code{getlogin()}.  Defaults to @samp{nobody}.
1904
1905 @item host
1906
1907 System hostname as reported by @code{gethostname()}.  Defaults to
1908 @samp{nowhere}.
1909
1910 @item title
1911
1912 Document title as a string.  This is the title specified in the PSPP
1913 syntax file.
1914
1915 @item subtitle
1916
1917 Document subtitle as a string.  
1918
1919 @item source-file
1920
1921 PSPP syntax file name.  Example: @samp{mary96/first.stat}.
1922 @end table
1923
1924 @node Miscellaneous configuring, Improving output quality, HTML driver class, Configuration
1925 @section Miscellaneous configuration
1926
1927 The following environment variables can be used to further configure
1928 PSPP:
1929
1930 @table @code
1931 @item HOME
1932
1933 Used to determine the user's home directory.  No default value.
1934
1935 @item STAT_INCLUDE_PATH
1936
1937 Path used to find include files in PSPP syntax files.  Defaults vary
1938 across operating systems:
1939
1940 @table @asis
1941 @item UNIX
1942
1943 @itemize @bullet
1944 @item
1945 @file{.}
1946
1947 @item
1948 @file{~/.pspp/include}
1949
1950 @item
1951 @file{/usr/local/lib/pspp/include}
1952
1953 @item
1954 @file{/usr/lib/pspp/include}
1955
1956 @item
1957 @file{/usr/local/share/pspp/include}
1958
1959 @item
1960 @file{/usr/share/pspp/include}
1961 @end itemize
1962
1963 @item MS-DOS
1964
1965 @itemize @bullet
1966 @item
1967 @file{.}
1968
1969 @item
1970 @file{C:\PSPP\INCLUDE}
1971
1972 @item
1973 @file{$PATH}
1974 @end itemize
1975
1976 @item Other OSes
1977 No default path.
1978 @end table
1979
1980 @item STAT_PAGER
1981 @itemx PAGER
1982
1983 When PSPP invokes an external pager, it uses the first of these that
1984 is defined.  There is a default pager only if the person who compiled
1985 PSPP defined one.
1986
1987 @item TERM
1988
1989 The terminal type @code{termcap} or @code{ncurses} will use, if such
1990 support was compiled into PSPP.
1991
1992 @item STAT_OUTPUT_INIT_FILE
1993
1994 The basename used to search for the driver definition file.
1995 @xref{Output devices}.  @xref{File locations}.  Default: @code{devices}.
1996
1997 @item STAT_OUTPUT_PAPERSIZE_FILE
1998
1999 The basename used to search for the papersize file.  @xref{papersize}.
2000 @xref{File locations}.  Default: @code{papersize}.
2001
2002 @item STAT_OUTPUT_INIT_PATH
2003
2004 The path used to search for the driver definition file and the papersize
2005 file.  @xref{File locations}.  Default: the standard configuration path.
2006
2007 @item TMPDIR
2008
2009 The @code{sort} procedure stores its temporary files in this directory.
2010 Default: (UNIX) @file{/tmp}, (MS-DOS) @file{\}, (other OSes) empty string.
2011
2012 @item TEMP
2013 @item TMP
2014
2015 Under MS-DOS only, these variables are consulted after TMPDIR, in this
2016 order.
2017 @end table
2018
2019 @node Improving output quality,  , Miscellaneous configuring, Configuration
2020 @section Improving output quality
2021
2022 When its drivers are set up properly, PSPP can produce output that
2023 looks very good indeed.  The PostScript driver, suitably configured, can
2024 produce presentation-quality output.  Here are a few guidelines for
2025 producing better-looking output, regardless of output driver.  Your
2026 mileage may vary, of course, and everyone has different esthetic
2027 preferences.
2028
2029 @itemize @bullet
2030 @item
2031 Width is important in PSPP output.  Greater output width leads to more
2032 readable output, to a point.  Try the following to increase the output
2033 width:
2034
2035 @itemize @minus
2036 @item
2037 If you're using the ASCII driver with a dot-matrix printer, figure out
2038 what you need to do to put the printer into compressed mode.  Put that
2039 string into the @code{init-string} setting.  Try to get 132 columns; 160
2040 might be better, but you might find that print that tiny is difficult to
2041 read.
2042
2043 @item
2044 With the PostScript driver, try these ideas:
2045
2046 @itemize +
2047 @item
2048 Landscape mode.
2049
2050 @item
2051 Legal-size (8.5" x 14") paper in landscape mode.
2052
2053 @item
2054 Reducing font sizes.  If you're using 12-point fonts, try 10 point; if
2055 you're using 10-point fonts, try 8 point.  Some fonts are more readable
2056 than others at small sizes.
2057 @end itemize
2058 @end itemize
2059
2060 Try to strike a balance between character size and page width.
2061
2062 @item
2063 Use high-quality fonts.  Many public domain fonts are poor in quality.
2064 Recently, URW made some high-quality fonts available under the GPL.
2065 These are probably suitable.
2066
2067 @item
2068 Be sure you're using the proper font metrics.  The font metrics provided
2069 with PSPP may not correspond to the fonts actually being printed.
2070 This can cause bizarre-looking output.
2071
2072 @item
2073 Make sure that you're using good ink/ribbon/toner.  Darker print is
2074 easier to read.
2075
2076 @item
2077 Use plain fonts with serifs, such as Times-Roman or Palatino.  Avoid
2078 choosing italic or bold fonts as document base fonts.
2079 @end itemize
2080
2081 @node Invocation, Language, Configuration, Top
2082 @chapter Invoking PSPP
2083 @cindex invocation
2084 @cindex PSPP, invoking
2085
2086 @cindex command line, options
2087 @cindex options, command-line
2088 @example
2089 pspp [ -B @var{dir} | --config-dir=@var{dir} ] [ -o @var{device} | --device=@var{device} ]
2090        [ -d @var{var}[=@var{value}] | --define=@var{var}[=@var{value}] ] [-u @var{var} | --undef=@var{var} ]
2091        [ -f @var{file} | --out-file=@var{file} ] [ -p | --pipe ] [ -I- | --no-include ]
2092        [ -I @var{dir} | --include=@var{dir} ] [ -i | --interactive ] 
2093        [ -n | --edit | --dry-run | --just-print | --recon ] 
2094        [ -r | --no-statrc ] [ -h | --help ] [ -l | --list ] 
2095        [ -c @var{command} | --command @var{command} ] [ -s | --safer ]
2096        [ --testing-mode ] [ -V | --version ] [ -v | --verbose ] 
2097        [ @var{key}=@var{value} ] @var{file}@enddots{}
2098 @end example
2099
2100 @menu
2101 * Non-option Arguments::        Specifying syntax files and output devices.
2102 * Configuration Options::       Change the configuration for the current run.
2103 * Input and output options::    Controlling input and output files.
2104 * Language control options::    Language variants.
2105 * Informational options::       Helpful information about PSPP.
2106 @end menu
2107
2108 @node Non-option Arguments, Configuration Options, Invocation, Invocation
2109 @section Non-option Arguments
2110
2111 Syntax files and output device substitutions can be specified on
2112 PSPP's command line:
2113
2114 @table @code
2115 @item @var{file}
2116
2117 A file by itself on the command line will be executed as a syntax file.
2118 PSPP terminates after the syntax file runs, unless the @code{-i} or
2119 @code{--interactive} option is given (@pxref{Language control options}).
2120
2121 @item @var{file1} @var{file2}
2122
2123 When two or more filenames are given on the command line, the first
2124 syntax file is executed, then PSPP's dictionary is cleared, then the second
2125 syntax file is executed.
2126
2127 @item @var{file1} + @var{file2}
2128
2129 If syntax files' names are delimited by a plus sign (@samp{+}), then the
2130 dictionary is not cleared between their executions, as if they were
2131 concatenated together into a single file.
2132
2133 @item @var{key}=@var{value}
2134
2135 Defines an output device macro @var{key} to expand to @var{value},
2136 overriding any macro having the same @var{key} defined in the device
2137 configuration file.  @xref{Macro definitions}.
2138
2139 @end table
2140
2141 There is one other way to specify a syntax file, if your operating
2142 system supports it.  If you have a syntax file @file{foobar.stat}, put
2143 the notation
2144
2145 @example
2146 #! /usr/local/bin/pspp
2147 @end example
2148
2149 at the top, and mark the file as executable with @code{chmod +x
2150 foobar.stat}.  (If PSPP is not installed in @file{/usr/local/bin},
2151 then insert its actual installation directory into the syntax file
2152 instead.)  Now you should be able to invoke the syntax file just by
2153 typing its name.  You can include any options on the command line as
2154 usual.  PSPP entirely ignores any lines beginning with @samp{#!}.
2155
2156 @node Configuration Options, Input and output options, Non-option Arguments, Invocation
2157 @section Configuration Options
2158
2159 Configuration options are used to change PSPP's configuration for the
2160 current run.  The configuration options are:
2161
2162 @table @code
2163 @item -a @{compatible|enhanced@}
2164 @itemx --algorithm=@{compatible|enhanced@}
2165
2166 If you chose @code{compatible}, then PSPP will use the same  algorithms 
2167 as used by some proprietary statistical analysis packages.
2168 This is not recommended, as  these algorithms are inferior and in some cases 
2169 compeletely broken.
2170 The default setting is @code{enhanced}.
2171 Certain commands have subcommands which allow you to override this setting on 
2172 a per command basis.
2173
2174 @item -B @var{dir}
2175 @itemx --config-dir=@var{dir}
2176
2177 Sets the configuration directory to @var{dir}.  @xref{File locations}.
2178
2179 @item -o @var{device}
2180 @itemx --device=@var{device}
2181
2182 Selects the output device with name @var{device}.  If this option is
2183 given more than once, then all devices mentioned are selected.  This
2184 option disables all devices besides those mentioned on the command line.
2185
2186 @item -d @var{var}[=@var{value}]
2187 @itemx --define=@var{var}[=@var{value}]
2188
2189 Defines an `environment variable' named @var{var} having the optional
2190 value @var{value} specified.  @xref{Variable values}.
2191
2192 @item -u @var{var}
2193 @itemx --undef=@var{var}
2194
2195 Undefines the `environment variable' named @var{var}.  @xref{Variable
2196 values}.
2197 @end table
2198
2199 @node Input and output options, Language control options, Configuration Options, Invocation
2200 @section Input and output options
2201
2202 Input and output options affect how PSPP reads input and writes
2203 output.  These are the input and output options:
2204
2205 @table @code
2206 @item -f @var{file}
2207 @itemx --out-file=@var{file}
2208
2209 This overrides the output file name for devices designated as listing
2210 devices.  If a file named @var{file} already exists, it is overwritten.
2211
2212 @item -p
2213 @itemx --pipe
2214
2215 Allows PSPP to be used as a filter by causing the syntax file to be
2216 read from stdin and output to be written to stdout.  Conflicts with the
2217 @code{-f @var{file}} and @code{--file=@var{file}} options.
2218
2219 @item -I-
2220 @itemx --no-include
2221
2222 Clears all directories from the include path.  This includes all
2223 directories put in the include path by default.  @xref{Miscellaneous
2224 configuring}.
2225
2226 @item -I @var{dir}
2227 @itemx --include=@var{dir}
2228
2229 Appends directory @var{dir} to the path that is searched for include
2230 files in PSPP syntax files.
2231
2232 @item -c @var{command}
2233 @itemx --command=@var{command}
2234
2235 Execute literal command @var{command}.  The command is executed before
2236 startup syntax files, if any.
2237
2238 @item --testing-mode
2239
2240 Invoke heuristics to assist with testing PSPP.  For use by @code{make
2241 check} and similar scripts.
2242 @end table
2243
2244 @node Language control options, Informational options, Input and output options, Invocation
2245 @section Language control options
2246
2247 Language control options control how PSPP syntax files are parsed and
2248 interpreted.  The available language control options are:
2249
2250 @table @code
2251 @item -i
2252 @itemx --interactive
2253
2254 When a syntax file is specified on the command line, PSPP normally
2255 terminates after processing it.  Giving this option will cause PSPP to
2256 bring up a command prompt after processing the syntax file.
2257
2258 In addition, this forces syntax files to be interpreted in interactive
2259 mode, rather than the default batch mode.  @xref{Tokenizing lines}, for
2260 information on the differences between batch mode and interactive mode
2261 command interpretation.
2262
2263 @item -n
2264 @itemx --edit
2265 @itemx --dry-run
2266 @itemx --just-print
2267 @itemx --recon
2268
2269 Only the syntax of any syntax file specified or of commands entered at
2270 the command line is checked.  Transformations are not performed and
2271 procedures are not executed.  Not yet implemented.
2272
2273 @item -r
2274 @itemx --no-statrc
2275
2276 Prevents the execution of the PSPP startup syntax file.  Not yet
2277 implemented, as startup syntax files aren't, either.
2278
2279 @item -s
2280 @itemx --safer
2281
2282 Disables certain unsafe operations.  This includes the ERASE and
2283 HOST commands, as well as use of pipes as input and output files.
2284 @end table
2285
2286 @node Informational options,  , Language control options, Invocation
2287 @section Informational options
2288
2289 Informational options cause information about PSPP to be written to
2290 the terminal.  Here are the available options:
2291
2292 @table @code
2293 @item -h
2294 @item --help
2295
2296 Prints a message describing PSPP command-line syntax and the available
2297 device driver classes, then terminates.
2298
2299 @item -l
2300 @item --list
2301
2302 Lists the available device driver classes, then terminates.
2303
2304 @item -x @{compatible|enhanced@}
2305 @itemx --syntax=@{compatible|enhanced@}
2306
2307 If you chose @code{compatible}, then PSPP will only accept command syntax that 
2308 is compatible with the proprietary program SPSS.
2309 If you choose @code{enhanced} then additional syntax will be available.
2310 The default is @code{enhanced}.
2311
2312
2313 @item -V
2314 @item --version
2315
2316 Prints a brief message listing PSPP's version, warranties you don't
2317 have, copying conditions and copyright, and e-mail address for bug
2318 reports, then terminates.
2319
2320 @item -v
2321 @item --verbose
2322
2323 Increments PSPP's verbosity level.  Higher verbosity levels cause
2324 PSPP to display greater amounts of information about what it is
2325 doing.  Often useful for debugging PSPP's configuration.  
2326
2327 This option can be given multiple times to set the verbosity level to
2328 that value.  The default verbosity level is 0, in which no informational
2329 messages will be displayed.
2330
2331 Higher verbosity levels cause messages to be displayed when the
2332 corresponding events take place.
2333
2334 @table @asis
2335 @item 1
2336
2337 Driver and subsystem initializations.
2338
2339 @item 2
2340
2341 Completion of driver initializations.  Beginning of driver closings.
2342
2343 @item 3
2344
2345 Completion of driver closings.
2346
2347 @item 4
2348
2349 Files searched for; success of searches.
2350
2351 @item 5
2352
2353 Individual directories included in file searches.
2354 @end table
2355
2356 Each verbosity level also includes messages from lower verbosity levels.
2357
2358 @end table
2359
2360 @node Language, Expressions, Invocation, Top
2361 @chapter The PSPP language
2362 @cindex language, PSPP
2363 @cindex PSPP, language
2364
2365 @quotation
2366 @strong{Please note:} PSPP is not even close to completion.
2367 Only a few actual statistical procedures are implemented.  PSPP
2368 is a work in progress.
2369 @end quotation
2370
2371 This chapter discusses elements common to many PSPP commands.
2372 Later chapters will describe individual commands in detail.
2373
2374 @menu
2375 * Tokens::                      Characters combine to form tokens.
2376 * Commands::                    Tokens combine to form commands.
2377 * Types of Commands::           Commands come in several flavors.
2378 * Order of Commands::           Commands combine to form syntax files.
2379 * Missing Observations::        Handling missing observations.
2380 * Variables::                   The unit of data storage.
2381 * Files::                       Files used by PSPP.
2382 * BNF::                         How command syntax is described.
2383 @end menu
2384
2385 @node Tokens, Commands, Language, Language
2386 @section Tokens
2387 @cindex language, lexical analysis
2388 @cindex language, tokens
2389 @cindex tokens
2390 @cindex lexical analysis
2391 @cindex lexemes
2392
2393 PSPP divides most syntax file lines into series of short chunks
2394 called @dfn{tokens}, @dfn{lexical elements}, or @dfn{lexemes}.  These
2395 tokens are then grouped to form commands, each of which tells
2396 PSPP to take some action---read in data, write out data, perform
2397 a statistical procedure, etc.  The process of dividing input into tokens
2398 is @dfn{tokenization}, or @dfn{lexical analysis}.  Each type of token is
2399 described below.
2400
2401 @cindex delimiters
2402 @cindex whitespace
2403 Tokens must be separated from each other by @dfn{delimiters}.
2404 Delimiters include whitespace (spaces, tabs, carriage returns, line
2405 feeds, vertical tabs), punctuation (commas, forward slashes, etc.), and
2406 operators (plus, minus, times, divide, etc.)  Note that while whitespace
2407 only separates tokens, other delimiters are tokens in themselves.
2408
2409 @table @strong
2410 @cindex identifiers
2411 @item Identifiers
2412 Identifiers are names that specify variable names, commands, or command
2413 details.
2414
2415 @itemize @bullet
2416 @item
2417 The first character in an identifier must be a letter, @samp{#}, or
2418 @samp{@@}.  Some system identifiers begin with @samp{$}, but
2419 user-defined variables' names may not begin with @samp{$}.
2420
2421 @item
2422 The remaining characters in the identifier must be letters, digits, or
2423 one of the following special characters: 
2424
2425 @example
2426 .  _  $  #  @@
2427 @end example
2428
2429 @item
2430 @cindex variable names
2431 @cindex names, variable
2432 Variable names may be any length, but only the first 8 characters are
2433 significant.
2434
2435 @item
2436 @cindex case-sensitivity
2437 Identifiers are not case-sensitive: @code{foobar}, @code{Foobar},
2438 @code{FooBar}, @code{FOOBAR}, and @code{FoObaR} are different
2439 representations of the same identifier.
2440
2441 @item
2442 @cindex keywords
2443 Identifiers other than variable names may be abbreviated to their first
2444 3 characters if this abbreviation is unambiguous.  These identifiers are
2445 often called @dfn{keywords}.  (Unique abbreviations of 3 or more
2446 characters are also accepted: @samp{FRE}, @samp{FREQ}, and
2447 @samp{FREQUENCIES} are equivalent when the last is a keyword.)
2448
2449 @item
2450 Whether an identifier is a keyword depends on the context.
2451
2452 @item
2453 @cindex keywords, reserved
2454 @cindex reserved keywords
2455 Some keywords are reserved.  These keywords may not be used in any
2456 context besides those explicitly described in this manual.  The reserved
2457 keywords are:
2458
2459 @example
2460 ALL  AND  BY  EQ  GE  GT  LE  LT  NE  NOT  OR  TO  WITH
2461 @end example
2462
2463 @item 
2464 Since keywords are identifiers, all the rules for identifiers apply.
2465 Specifically, they must be delimited as are other identifiers:
2466 @code{WITH} is a reserved keyword, but @code{WITHOUT} is a valid
2467 variable name.
2468 @end itemize
2469
2470 @cindex @samp{.}
2471 @cindex period
2472 @cindex variable names, ending with period
2473 @strong{Caution:} It is legal to end a variable name with a period, but
2474 @emph{don't do it!}  The variable name will be misinterpreted when it is
2475 the final token on a line: @code{FOO.} will be divided into two separate
2476 tokens, @samp{FOO} and @samp{.}, the @dfn{terminal dot}.
2477 @xref{Commands, , Forming commands of tokens}.
2478
2479 @item Numbers
2480 @cindex numbers
2481 @cindex integers
2482 @cindex reals
2483 Numbers may be specified as integers or reals.  Integers are internally
2484 converted into reals.  Scientific notation is not supported.  Here are
2485 some examples of valid numbers:
2486
2487 @example
2488 1234  3.14159265359  .707106781185  8945.
2489 @end example
2490
2491 @strong{Caution:} The last example will be interpreted as two tokens,
2492 @samp{8945} and @samp{.}, if it is the last token on a line.
2493
2494 @item Strings
2495 @cindex strings
2496 @cindex @samp{'}
2497 @cindex @samp{"}
2498 @cindex case-sensitivity
2499 Strings are literal sequences of characters enclosed in pairs of single
2500 quotes (@samp{'}) or double quotes (@samp{"}).
2501
2502 @itemize @bullet
2503 @item
2504 Whitespace and case of letters @emph{are} significant inside strings.
2505 @item
2506 Whitespace characters inside a string are not delimiters.
2507 @item
2508 To include single-quote characters in a string, enclose the string in
2509 double quotes.
2510 @item
2511 To include double-quote characters in a string, enclose the string in
2512 single quotes.
2513 @item
2514 It is not possible to put both single- and double-quote characters
2515 inside one string.
2516 @end itemize
2517
2518 @item Hexstrings
2519 @cindex hexstrings
2520 Hexstrings are string variants that use hex digits to specify
2521 characters.
2522
2523 @itemize @bullet
2524 @item
2525 A hexstring may be used anywhere that an ordinary string is allowed.
2526
2527 @item
2528 @cindex @samp{X'}
2529 @cindex @samp{'}
2530 A hexstring begins with @samp{X'} or @samp{x'}, and ends with @samp{'}.
2531
2532 @cindex whitespace
2533 @item
2534 No whitespace is allowed between the initial @samp{X} and @samp{'}.
2535
2536 @item
2537 Double quotes @samp{"} may be used in place of single quotes @samp{'} if
2538 done in both places.
2539
2540 @item
2541 Each pair of hex digits is internally changed into a single character
2542 with the given value.
2543
2544 @item
2545 If there is an odd number of hex digits, the missing last digit is
2546 assumed to be @samp{0}.
2547
2548 @item
2549 @cindex portability
2550 @strong{Please note:} Use of hexstrings is nonportable because the same
2551 numeric values are associated with different glyphs by different
2552 operating systems.  Therefore, their use should be confined to syntax
2553 files that will not be widely distributed.
2554
2555 @item
2556 @cindex characters, reserved
2557 @cindex 0
2558 @cindex whitespace
2559 @strong{Please note also:} The character with value 00 is reserved for
2560 internal use by PSPP.  Its use in strings causes an error and
2561 replacement with a blank space (in ASCII, hex 20, decimal 32).
2562 @end itemize
2563
2564 @item Punctuation
2565 @cindex punctuation
2566 Punctuation separates tokens; punctuators are delimiters.  These are the
2567 punctuation characters:
2568
2569 @example
2570 ,  /  =  (  )
2571 @end example
2572
2573 @item Operators
2574 @cindex operators
2575 Operators describe mathematical operations.  Some operators are delimiters:
2576
2577 @example
2578 (  )  +  -  *  /  **
2579 @end example
2580
2581 Many of the above operators are also punctuators.  Punctuators are
2582 distinguished from operators by context. 
2583
2584 The other operators are all reserved keywords.  None of these are
2585 delimiters:
2586
2587 @example
2588 AND  EQ  GE  GT  LE  LT  NE  OR
2589 @end example
2590
2591 @item Terminal Dot
2592 @cindex terminal dot
2593 @cindex dot, terminal
2594 @cindex period
2595 @cindex @samp{.}
2596 A period (@samp{.}) at the end of a line (except for whitespace) is one
2597 type of a @dfn{terminal dot}, although not every terminal dot is a
2598 period at the end of a line.  @xref{Commands, , Forming commands of
2599 tokens}.  A period is a terminal dot @emph{only}
2600 when it is at the end of a line; otherwise it is part of a
2601 floating-point number.  (A period outside a number in the middle of a
2602 line is an error.)
2603
2604 @quotation
2605 @cindex terminal dot, changing
2606 @cindex dot, terminal, changing
2607 @strong{Please note:} The character used for the @dfn{terminal dot}
2608 can be changed with @cmd{SET}'s ENDCMD subcommand (@pxref{SET}).  This
2609 is strongly discouraged, and throughout all the remainder of this
2610 manual it will be assumed that the default setting is in effect.
2611 @end quotation
2612
2613 @end table
2614
2615 @node Commands, Types of Commands, Tokens, Language
2616 @section Forming commands of tokens
2617
2618 @cindex PSPP, command structure
2619 @cindex language, command structure
2620 @cindex commands, structure
2621
2622 Most PSPP commands share a common structure, diagrammed below:
2623
2624 @example
2625 @var{cmd}@dots{} [@var{sbc}[=][@var{spec} [[,]@var{spec}]@dots{}]] [[/[=][@var{spec} [[,]@var{spec}]@dots{}]]@dots{}].
2626 @end example
2627
2628 @cindex @samp{[  ]}
2629 In the above, rather daunting, expression, pairs of square brackets
2630 (@samp{[ ]}) indicate optional elements, and names such as @var{cmd}
2631 indicate parts of the syntax that vary from command to command.
2632 Ellipses (@samp{...}) indicate that the preceding part may be repeated
2633 an arbitrary number of times.  Let's pick apart what it says above:
2634
2635 @itemize @bullet
2636 @cindex commands, names
2637 @item
2638 A command begins with a command name of one or more keywords, such as
2639 @cmd{FREQUENCIES}, @cmd{DATA LIST}, or @cmd{N OF CASES}.  @var{cmd}
2640 may be abbreviated to its first word if that is unambiguous; each word
2641 in @var{cmd} may be abbreviated to a unique prefix of three or more
2642 characters as described above.
2643
2644 @cindex subcommands
2645 @item
2646 The command name may be followed by one or more @dfn{subcommands}:
2647
2648 @itemize @minus
2649 @item
2650 Each subcommand begins with a unique keyword, indicated by @var{sbc}
2651 above.  This is analogous to the command name.
2652
2653 @item
2654 The subcommand name is optionally followed by an equals sign (@samp{=}).
2655
2656 @item
2657 Some subcommands accept a series of one or more specifications
2658 (@var{spec}), optionally separated by commas.
2659
2660 @item
2661 Each subcommand must be separated from the next (if any) by a forward
2662 slash (@samp{/}).
2663 @end itemize
2664
2665 @cindex dot, terminal
2666 @cindex terminal dot
2667 @item
2668 Each command must be terminated with a @dfn{terminal dot}.  
2669 The terminal dot may be given one of three ways:
2670
2671 @itemize @minus
2672 @item
2673 (most commonly) A period character at the very end of a line, as
2674 described above.
2675
2676 @item
2677 (only if NULLINE is on: @xref{SET, , Setting user preferences}, for more
2678 details.)  A completely blank line.
2679
2680 @item
2681 (in batch mode only) Any line that is not indented from the left side of
2682 the page causes a terminal dot to be inserted before that line.
2683 Therefore, each command begins with a line that is flush left, followed
2684 by zero or more lines that are indented one or more characters from the
2685 left margin.
2686
2687 In batch mode, PSPP will ignore a plus sign, minus sign, or period
2688 (@samp{+}, @samp{@minus{}}, or @samp{.}) as the first character in a
2689 line.  Any of these characters as the first character on a line will
2690 begin a new command.  This allows for visual indentation of a command
2691 without that command being considered part of the previous command.
2692
2693 PSPP is in batch mode when it is reading input from a file, rather
2694 than from an interactive user.  Note that the other forms of the
2695 terminal dot may also be used in batch mode.
2696
2697 Sometimes, one encounters syntax files that are intended to be
2698 interpreted in interactive mode rather than batch mode (for instance,
2699 this can happen if a session log file is used directly as a syntax
2700 file).  When this occurs, use the @samp{-i} command line option to force
2701 interpretation in interactive mode (@pxref{Language control options}).
2702 @end itemize
2703 @end itemize
2704
2705 PSPP ignores empty commands when they are generated by the above
2706 rules.  Note that, as a consequence of these rules, each command must
2707 begin on a new line.
2708
2709 @node Types of Commands, Order of Commands, Commands, Language
2710 @section Types of Commands
2711
2712 Commands in PSPP are divided roughly into six categories:
2713
2714 @table @strong
2715 @item Utility commands
2716 @cindex utility commands
2717 Set or display various global options that affect PSPP operations.
2718 May appear anywhere in a syntax file.  @xref{Utilities, , Utility
2719 commands}.
2720
2721 @item File definition commands
2722 @cindex file definition commands
2723 Give instructions for reading data from text files or from special
2724 binary ``system files''.  Most of these commands discard any previous
2725 data or variables to replace it with the new data and
2726 variables.  At least one must appear before the first command in any of
2727 the categories below.  @xref{Data Input and Output}.
2728
2729 @item Input program commands
2730 @cindex input program commands
2731 Though rarely used, these provide powerful tools for reading data files
2732 in arbitrary textual or binary formats.  @xref{INPUT PROGRAM}.
2733
2734 @item Transformations
2735 @cindex transformations
2736 Perform operations on data and write data to output files.  Transformations
2737 are not carried out until a procedure is executed.  
2738
2739 @item Restricted transformations
2740 @cindex restricted transformations
2741 Same as transformations for most purposes.  @xref{Order of Commands}, for a
2742 detailed description of the differences.
2743
2744 @item Procedures
2745 @cindex procedures
2746 Analyze data, writing results of analyses to the listing file.  Cause
2747 transformations specified earlier in the file to be performed.  In a
2748 more general sense, a @dfn{procedure} is any command that causes the
2749 active file (the data) to be read.
2750 @end table
2751
2752 @node Order of Commands, Missing Observations, Types of Commands, Language
2753 @section Order of Commands
2754 @cindex commands, ordering
2755 @cindex order of commands
2756
2757 PSPP does not place many restrictions on ordering of commands.
2758 The main restriction is that variables must be defined with one of the
2759 file-definition commands before they are otherwise referred to.
2760
2761 Of course, there are specific rules, for those who are interested.
2762 PSPP possesses five internal states, called initial, INPUT PROGRAM,
2763 FILE TYPE, transformation, and procedure states.  (Please note the
2764 distinction between the @cmd{INPUT PROGRAM} and @cmd{FILE TYPE}
2765 @emph{commands} and the INPUT PROGRAM and FILE TYPE @emph{states}.)
2766
2767 PSPP starts up in the initial state.  Each successful completion
2768 of a command may cause a state transition.  Each type of command has its
2769 own rules for state transitions:
2770
2771 @table @strong
2772 @item Utility commands
2773 @itemize @bullet
2774 @item
2775 Legal in all states.
2776 @item
2777 Do not cause state transitions.  Exception: when @cmd{N OF CASES}
2778 is executed in the procedure state, it causes a transition to the
2779 transformation state.
2780 @end itemize
2781
2782 @item @cmd{DATA LIST}
2783 @itemize @bullet
2784 @item
2785 Legal in all states.
2786 @item
2787 When executed in the initial or procedure state, causes a transition to
2788 the transformation state.  
2789 @item
2790 Clears the active file if executed in the procedure or transformation
2791 state.
2792 @end itemize
2793
2794 @item @cmd{INPUT PROGRAM}
2795 @itemize @bullet
2796 @item
2797 Invalid in INPUT PROGRAM and FILE TYPE states.
2798 @item
2799 Causes a transition to the INPUT PROGRAM state.  
2800 @item
2801 Clears the active file.
2802 @end itemize
2803
2804 @item @cmd{FILE TYPE}
2805 @itemize @bullet
2806 @item
2807 Invalid in INPUT PROGRAM and FILE TYPE states.
2808 @item
2809 Causes a transition to the FILE TYPE state.
2810 @item
2811 Clears the active file.
2812 @end itemize
2813
2814 @item Other file definition commands
2815 @itemize @bullet
2816 @item
2817 Invalid in INPUT PROGRAM and FILE TYPE states.
2818 @item
2819 Cause a transition to the transformation state.
2820 @item
2821 Clear the active file, except for @cmd{ADD FILES}, @cmd{MATCH FILES},
2822 and @cmd{UPDATE}.
2823 @end itemize
2824
2825 @item Transformations
2826 @itemize @bullet
2827 @item
2828 Invalid in initial and FILE TYPE states.
2829 @item
2830 Cause a transition to the transformation state.
2831 @end itemize
2832
2833 @item Restricted transformations
2834 @itemize @bullet
2835 @item
2836 Invalid in initial, INPUT PROGRAM, and FILE TYPE states.
2837 @item
2838 Cause a transition to the transformation state.
2839 @end itemize
2840
2841 @item Procedures
2842 @itemize @bullet
2843 @item
2844 Invalid in initial, INPUT PROGRAM, and FILE TYPE states.
2845 @item
2846 Cause a transition to the procedure state.
2847 @end itemize
2848 @end table
2849
2850 @node Missing Observations, Variables, Order of Commands, Language
2851 @section Handling missing observations
2852 @cindex missing values
2853 @cindex values, missing
2854
2855 PSPP includes special support for unknown numeric data values.
2856 Missing observations are assigned a special value, called the
2857 @dfn{system-missing value}.  This ``value'' actually indicates the
2858 absence of value; it means that the actual value is unknown.  Procedures
2859 automatically exclude from analyses those observations or cases that
2860 have missing values.  Whether single observations or entire cases are
2861 excluded depends on the procedure.
2862
2863 The system-missing value exists only for numeric variables.  String
2864 variables always have a defined value, even if it is only a string of
2865 spaces.
2866
2867 Variables, whether numeric or string, can have designated
2868 @dfn{user-missing values}.  Every user-missing value is an actual value
2869 for that variable.  However, most of the time user-missing values are
2870 treated in the same way as the system-missing value.  String variables
2871 that are wider than a certain width, usually 8 characters (depending on
2872 computer architecture), cannot have user-missing values.
2873
2874 For more information on missing values, see the following sections:
2875 @ref{Variables}, @ref{MISSING VALUES}, @ref{Expressions}.  See also the
2876 documentation on individual procedures for information on how they
2877 handle missing values.
2878
2879 @node Variables, Files, Missing Observations, Language
2880 @section Variables
2881 @cindex variables
2882 @cindex dictionary
2883
2884 Variables are the basic unit of data storage in PSPP.  All the
2885 variables in a file taken together, apart from any associated data, are
2886 said to form a @dfn{dictionary}.  
2887 Some details of variables are described in the sections below.
2888
2889 @menu
2890 * Attributes::                  Attributes of variables.
2891 * System Variables::            Variables automatically defined by PSPP.
2892 * Sets of Variables::           Lists of variable names.
2893 * Input/Output Formats::        Input and output formats.
2894 * Scratch Variables::           Variables deleted by procedures.
2895 @end menu
2896
2897 @node Attributes, System Variables, Variables, Variables
2898 @subsection Attributes of Variables
2899 @cindex variables, attributes of
2900 @cindex attributes of variables
2901 Each variable has a number of attributes, including:
2902
2903 @table @strong
2904 @item Name
2905 This is an identifier.  Each variable must have a different name.
2906 @xref{Tokens}.
2907
2908 @cindex variables, type
2909 @cindex type of variables
2910 @item Type
2911 Numeric or string.
2912
2913 @cindex variables, width
2914 @cindex width of variables
2915 @item Width
2916 (string variables only) String variables with a width of 8 characters or
2917 fewer are called @dfn{short string variables}.  Short string variables
2918 can be used in many procedures where @dfn{long string variables} (those
2919 with widths greater than 8) are not allowed.
2920
2921 @quotation
2922 @strong{Please note:} Certain systems may consider strings longer than 8
2923 characters to be short strings.  Eight characters represents a minimum
2924 figure for the maximum length of a short string.
2925 @end quotation
2926
2927 @item Position
2928 Variables in the dictionary are arranged in a specific order.
2929 @cmd{DISPLAY} can be used to show this order: see @ref{DISPLAY}.
2930
2931 @item Initialization
2932 Either reinitialized to 0 or spaces for each case, or left at its
2933 existing value.  @xref{LEAVE}.
2934
2935 @cindex missing values
2936 @cindex values, missing
2937 @item Missing values
2938 Optionally, up to three values, or a range of values, or a specific
2939 value plus a range, can be specified as @dfn{user-missing values}.
2940 There is also a @dfn{system-missing value} that is assigned to an
2941 observation when there is no other obvious value for that observation.
2942 Observations with missing values are automatically excluded from
2943 analyses.  User-missing values are actual data values, while the
2944 system-missing value is not a value at all.  @xref{Missing Observations}.
2945
2946 @cindex variable labels
2947 @cindex labels, variable
2948 @item Variable label
2949 A string that describes the variable.  @xref{VARIABLE LABELS}.
2950
2951 @cindex value labels
2952 @cindex labels, value
2953 @item Value label
2954 Optionally, these associate each possible value of the variable with a
2955 string.  @xref{VALUE LABELS}.
2956
2957 @cindex print format
2958 @item Print format
2959 Display width, format, and (for numeric variables) number of decimal
2960 places.  This attribute does not affect how data are stored, just how
2961 they are displayed.  Example: a width of 8, with 2 decimal places.
2962 @xref{PRINT FORMATS}.
2963
2964 @cindex write format
2965 @item Write format
2966 Similar to print format, but used by certain commands that are
2967 designed to write to binary files.  @xref{WRITE FORMATS}.
2968 @end table
2969
2970 @node System Variables, Sets of Variables, Attributes, Variables
2971 @subsection Variables Automatically Defined by PSPP
2972 @cindex system variables
2973 @cindex variables, system
2974
2975 There are seven system variables.  These are not like ordinary
2976 variables, as they are not stored in each case.  They can only be used
2977 in expressions.  These system variables, whose values and output formats
2978 cannot be modified, are described below.
2979
2980 @table @code
2981 @cindex @code{$CASENUM}
2982 @item $CASENUM
2983 Case number of the case at the moment.  This changes as cases are
2984 shuffled around.
2985
2986 @cindex @code{$DATE}
2987 @item $DATE
2988 Date the PSPP process was started, in format A9, following the
2989 pattern @code{DD MMM YY}.
2990
2991 @cindex @code{$JDATE}
2992 @item $JDATE
2993 Number of days between 15 Oct 1582 and the time the PSPP process
2994 was started.
2995
2996 @cindex @code{$LENGTH}
2997 @item $LENGTH
2998 Page length, in lines, in format F11.
2999
3000 @cindex @code{$SYSMIS}
3001 @item $SYSMIS
3002 System missing value, in format F1.
3003
3004 @cindex @code{$TIME}
3005 @item $TIME
3006 Number of seconds between midnight 14 Oct 1582 and the time the active file
3007 was read, in format F20.
3008
3009 @cindex @code{$WIDTH}
3010 @item $WIDTH
3011 Page width, in characters, in format F3.
3012 @end table
3013
3014 @node Sets of Variables, Input/Output Formats, System Variables, Variables
3015 @subsection Lists of variable names
3016 @cindex TO convention
3017 @cindex convention, TO
3018
3019 There are several ways to specify a set of variables:
3020
3021 @enumerate
3022 @item
3023 (Most commonly.)  List the variable names one after another, optionally
3024 separating them by commas.
3025
3026 @cindex @code{TO}
3027 @item
3028 (This method cannot be used on commands that define the dictionary, such
3029 as @cmd{DATA LIST}.)  The syntax is the names of two existing variables,
3030 separated by the reserved keyword @code{TO}.  The meaning is to include
3031 every variable in the dictionary between and including the variables
3032 specified.  For instance, if the dictionary contains six variables with
3033 the names @code{ID}, @code{X1}, @code{X2}, @code{GOAL}, @code{MET}, and
3034 @code{NEXTGOAL}, in that order, then @code{X2 TO MET} would include
3035 variables @code{X2}, @code{GOAL}, and @code{MET}.
3036
3037 @item
3038 (This method can be used only on commands that define the dictionary,
3039 such as @cmd{DATA LIST}.)  It is used to define sequences of variables
3040 that end in consecutive integers.  The syntax is two identifiers that
3041 end in numbers.  This method is best illustrated with examples:
3042
3043 @itemize @bullet
3044 @item
3045 The syntax @code{X1 TO X5} defines 5 variables:
3046
3047 @itemize @minus
3048 @item
3049 X1
3050 @item
3051 X2
3052 @item
3053 X3
3054 @item
3055 X4
3056 @item
3057 X5
3058 @end itemize
3059
3060 @item
3061 The syntax @code{ITEM0008 TO ITEM0013} defines 6 variables:
3062
3063 @itemize @minus
3064 @item
3065 ITEM0008
3066 @item
3067 ITEM0009
3068 @item
3069 ITEM0010
3070 @item
3071 ITEM0011
3072 @item
3073 ITEM0012
3074 @item
3075 ITEM0013
3076 @end itemize
3077
3078 @item
3079 Each of the syntaxes @code{QUES001 TO QUES9} and @code{QUES6 TO QUES3}
3080 are invalid, although for different reasons, which should be evident.
3081 @end itemize
3082
3083 Note that after a set of variables has been defined with @cmd{DATA LIST}
3084 or another command with this method, the same set can be referenced on
3085 later commands using the same syntax.
3086
3087 @item
3088 The above methods can be combined, either one after another or delimited
3089 by commas.  For instance, the combined syntax @code{A Q5 TO Q8 X TO Z}
3090 is legal as long as each part @code{A}, @code{Q5 TO Q8}, @code{X TO Z}
3091 is individually legal.
3092 @end enumerate
3093
3094 @node Input/Output Formats, Scratch Variables, Sets of Variables, Variables
3095 @subsection Input and Output Formats
3096
3097 Data that PSPP inputs and outputs must have one of a number of formats.
3098 These formats are described, in general, by a format specification of
3099 the form @code{NAMEw.d}, where @var{name} is the
3100 format name and @var{w} is a field width.  @var{d} is the optional
3101 desired number of decimal places, if appropriate.  If @var{d} is not
3102 included then it is assumed to be 0.  Some formats do not allow @var{d}
3103 to be specified.
3104
3105 When an input format is specified on @cmd{DATA LIST} or another
3106 command, then
3107 it is converted to an output format for the purposes of @cmd{PRINT}
3108 and other
3109 data output commands.  For most purposes, input and output formats are
3110 the same; the salient differences are described below.
3111
3112 Below are listed the input and output formats supported by PSPP.  If an
3113 input format is mapped to a different output format by default, then
3114 that mapping is indicated with @result{}.  Each format has the listed
3115 bounds on input width (iw) and output width (ow).
3116
3117 The standard numeric input and output formats are given in the following
3118 table:
3119
3120 @table @asis
3121 @item Fw.d: 1 <= iw,ow <= 40
3122 Standard decimal format with @var{d} decimal places.  If the number is
3123 too large to fit within the field width, it is expressed in scientific
3124 notation (@code{1.2+34}) if w >= 6, with always at least two digits in
3125 the exponent.  When used as an input format, scientific notation is
3126 allowed but an E or an F must be used to introduce the exponent.
3127
3128 The default output format is the same as the input format, except if
3129 @var{d} > 1.  In that case the output @var{w} is always made to be at
3130 least 2 + @var{d}.
3131
3132 @item Ew.d: 1 <= iw <= 40; 6 <= ow <= 40
3133 For input this is equivalent to F format except that no E or F is
3134 require to introduce the exponent.  For output, produces scientific
3135 notation in the form @code{1.2+34}.  There are always at least two
3136 digits given in the exponent.
3137
3138 The default output @var{w} is the largest of the input @var{w}, the
3139 input @var{d} + 7, and 10.  The default output @var{d} is the input
3140 @var{d}, but at least 3.
3141
3142 @item COMMAw.d: 1 <= iw,ow <= 40
3143 Equivalent to F format, except that groups of three digits are
3144 comma-separated on output.  If the number is too large to express in the
3145 field width, then first commas are eliminated, then if there is still
3146 not enough space the number is expressed in scientific notation given
3147 that w >= 6.  Commas are allowed and ignored when this is used as an
3148 input format.  
3149
3150 @item DOTw.d: 1 <= iw,ow <= 40
3151 Equivalent to COMMA format except that the roles of comma and decimal
3152 point are interchanged.  However: If SET /DECIMAL=DOT is in effect, then
3153 COMMA uses @samp{,} for a decimal point and DOT uses @samp{.} for a
3154 decimal point.
3155
3156 @item DOLLARw.d: 1 <= iw <= 40; 2 <= ow <= 40
3157 Equivalent to COMMA format, except that the number is prefixed by a
3158 dollar sign (@samp{$}) if there is room.  On input the value is allowed
3159 to be prefixed by a dollar sign, which is ignored.
3160
3161 The default output @var{w} is the input @var{w}, but at least 2.
3162
3163 @item PCTw.d: 2 <= iw,ow <= 40
3164 Equivalent to F format, except that the number is suffixed by a percent
3165 sign (@samp{%}) if there is room.  On input the value is allowed to be
3166 suffixed by a percent sign, which is ignored.
3167
3168 The default output @var{w} is the input @var{w}, but at least 2.
3169
3170 @item Nw.d: 1 <= iw,ow <= 40
3171 Only digits are allowed within the field width.  The decimal point is
3172 assumed to be @var{d} digits from the right margin.
3173
3174 The default output format is F with the same @var{w} and @var{d}, except
3175 if @var{d} > 1.  In that case the output @var{w} is always made to be at
3176 least 2 + @var{d}.
3177
3178 @item Zw.d @result{} F: 1 <= iw,ow <= 40
3179 Zoned decimal input.  If you need to use this then you know how.
3180
3181 @item IBw.d @result{} F: 1 <= iw,ow <= 8
3182 Integer binary format.  The field is interpreted as a fixed-point
3183 positive or negative binary number in two's-complement notation.  The
3184 location of the decimal point is implied.  Endianness is the same as the
3185 host machine.
3186
3187 The default output format is F8.2 if @var{d} is 0.  Otherwise it is F,
3188 with output @var{w} as 9 + input @var{d} and output @var{d} as input
3189 @var{d}.
3190
3191 @item PIB @result{} F: 1 <= iw,ow <= 8
3192 Positive integer binary format.  The field is interpreted as a
3193 fixed-point positive binary number.  The location of the decimal point
3194 is implied.  Endianness is teh same as the host machine.
3195
3196 The default output format follows the rules for IB format.
3197
3198 @item Pw.d @result{} F: 1 <= iw,ow <= 16
3199 Binary coded decimal format.  Each byte from left to right, except the
3200 rightmost, represents two digits.  The upper nibble of each byte is more
3201 significant.  The upper nibble of the final byte is the least
3202 significant digit.  The lower nibble of the final byte is the sign; a
3203 value of D represents a negative sign and all other values are
3204 considered positive.  The decimal point is implied.
3205
3206 The default output format follows the rules for IB format.
3207
3208 @item PKw.d @result{} F: 1 <= iw,ow <= 16
3209 Positive binary code decimal format.  Same as P but the last byte is the
3210 same as the others.
3211
3212 The default output format follows the rules for IB format.
3213
3214 @item RBw @result{} F: 2 <= iw,ow <= 8
3215
3216 Binary C architecture-dependent ``double'' format.  For a standard
3217 IEEE754 implementation @var{w} should be 8.
3218
3219 The default output format follows the rules for IB format.
3220
3221 @item PIBHEXw.d @result{} F: 2 <= iw,ow <= 16
3222 PIB format encoded as textual hex digit pairs.  @var{w} must be even.
3223
3224 The input width is mapped to a default output width as follows:
3225 2@result{}4, 4@result{}6, 6@result{}9, 8@result{}11, 10@result{}14,
3226 12@result{}16, 14@result{}18, 16@result{}21.  No allowances are made for
3227 decimal places.
3228
3229 @item RBHEXw @result{} F: 4 <= iw,ow <= 16
3230
3231 RB format encoded as textual hex digits pairs.  @var{w} must be even.
3232
3233 The default output format is F8.2.
3234
3235 @item CCAw.d: 1 <= ow <= 40
3236 @itemx CCBw.d: 1 <= ow <= 40
3237 @itemx CCCw.d: 1 <= ow <= 40
3238 @itemx CCDw.d: 1 <= ow <= 40
3239 @itemx CCEw.d: 1 <= ow <= 40
3240
3241 User-defined custom currency formats.  May not be used as an input
3242 format.  @xref{SET}, for more details.
3243 @end table
3244
3245 The date and time numeric input and output formats accept a number of
3246 possible formats.  Before describing the formats themselves, some
3247 definitions of the elements that make up their formats will be helpful:
3248
3249 @table @dfn
3250 @item leader
3251 All formats accept an optional whitespace leader.
3252
3253 @item day
3254 An integer between 1 and 31 representing the day of month.
3255
3256 @item day-count
3257 An integer representing a number of days.
3258
3259 @item date-delimiter
3260 One or more characters of whitespace or the following characters:
3261 @code{- / . ,}
3262
3263 @item month
3264 A month name in one of the following forms:
3265 @itemize @bullet
3266 @item
3267 An integer between 1 and 12.
3268 @item
3269 Roman numerals representing an integer between 1 and 12.
3270 @item
3271 At least the first three characters of an English month name (January,
3272 February, @dots{}).
3273 @end itemize
3274
3275 @item year
3276 An integer year number between 1582 and 19999, or between 1 and 199.
3277 Years between 1 and 199 will have 1900 added.
3278
3279 @item julian
3280 A single number with a year number in the first 2, 3, or 4 digits (as
3281 above) and the day number within the year in the last 3 digits.
3282
3283 @item quarter
3284 An integer between 1 and 4 representing a quarter.
3285
3286 @item q-delimiter
3287 The letter @samp{Q} or @samp{q}.
3288
3289 @item week
3290 An integer between 1 and 53 representing a week within a year.
3291
3292 @item wk-delimiter
3293 The letters @samp{wk} in any case.
3294
3295 @item time-delimiter
3296 At least one characters of whitespace or @samp{:} or @samp{.}.
3297
3298 @item hour
3299 An integer greater than 0 representing an hour.
3300
3301 @item minute
3302 An integer between 0 and 59 representing a minute within an hour.
3303
3304 @item opt-second
3305 Optionally, a time-delimiter followed by a real number representing a
3306 number of seconds.
3307
3308 @item hour24
3309 An integer between 0 and 23 representing an hour within a day.
3310
3311 @item weekday
3312 At least the first two characters of an English day word.
3313
3314 @item spaces
3315 Any amount or no amount of whitespace.
3316
3317 @item sign
3318 An optional positive or negative sign.
3319
3320 @item trailer
3321 All formats accept an optional whitespace trailer.
3322 @end table
3323
3324 The date input formats are strung together from the above pieces.  On
3325 output, the date formats are always printed in a single canonical
3326 manner, based on field width.  The date input and output formats are
3327 described below:
3328
3329 @table @asis
3330 @item DATEw: 9 <= iw,ow <= 40
3331 Date format. Input format: leader + day + date-delimiter +
3332 month + date-delimiter + year + trailer.  Output format: DD-MMM-YY for
3333 @var{w} < 11, DD-MMM-YYYY otherwise.
3334
3335 @item EDATEw: 8 <= iw,ow <= 40
3336 European date format.  Input format same as DATE.  Output format:
3337 DD.MM.YY for @var{w} < 10, DD.MM.YYYY otherwise.
3338
3339 @item SDATEw: 8 <= iw,ow <= 40
3340 Standard date format. Input format: leader + year + date-delimiter +
3341 month + date-delimiter + day + trailer.  Output format: YY/MM/DD for
3342 @var{w} < 10, YYYY/MM/DD otherwise.
3343
3344 @item ADATEw: 8 <= iw,ow <= 40
3345 American date format.  Input format: leader + month + date-delimiter +
3346 day + date-delimiter + year + trailer.  Output format: MM/DD/YY for
3347 @var{w} < 10, MM/DD/YYYY otherwise.
3348
3349 @item JDATEw: 5 <= iw,ow <= 40
3350 Julian date format.  Input format: leader + julian + trailer.  Output
3351 format: YYDDD for @var{w} < 7, YYYYDDD otherwise.
3352
3353 @item QYRw: 4 <= iw <= 40, 6 <= ow <= 40
3354 Quarter/year format.  Input format: leader + quarter + q-delimiter +
3355 year + trailer.  Output format: @samp{Q Q YY}, where the first
3356 @samp{Q} is one of the digits 1, 2, 3, 4, if @var{w} < 8, @code{Q Q
3357 YYYY} otherwise.
3358
3359 @item MOYRw: 6 <= iw,ow <= 40
3360 Month/year format.  Input format: leader + month + date-delimiter + year
3361 + trailer.  Output format: @samp{MMM YY} for @var{w} < 8, @samp{MMM
3362 YYYY} otherwise.
3363
3364 @item WKYRw: 6 <= iw <= 40, 8 <= ow <= 40
3365 Week/year format.  Input format: leader + week + wk-delimiter + year +
3366 trailer.  Output format: @samp{WW WK YY} for @var{w} < 10, @samp{WW WK
3367 YYYY} otherwise.
3368
3369 @item DATETIMEw.d: 17 <= iw,ow <= 40
3370 Date and time format.  Input format: leader + day + date-delimiter +
3371 month + date-delimiter + yaer + time-delimiter + hour24 + time-delimiter
3372 + minute + opt-second.  Output format: @samp{DD-MMM-YYYY HH:MM}.  If
3373 @var{w} > 19 then seconds @samp{:SS} is added.  If @var{w} > 22 and
3374 @var{d} > 0 then fractional seconds @samp{.SS} are added.
3375
3376 @item TIMEw.d: 5 <= iw,ow <= 40
3377 Time format.  Input format: leader + sign + spaces + hour +
3378 time-delimiter + minute + opt-second.  Output format: @samp{HH:MM}.
3379 Seconds and fractional seconds are available with @var{w} of at least 8
3380 and 10, respectively.
3381
3382 @item DTIMEw.d: 1 <= iw <= 40, 8 <= ow <= 40
3383 Time format with day count.  Input format: leader + sign + spaces +
3384 day-count + time-delimiter + hour + time-delimiter + minute +
3385 opt-second.  Output format: @samp{DD HH:MM}.  Seconds and fractional
3386 seconds are available with @var{w} of at least 8 and 10, respectively.
3387
3388 @item WKDAYw: 2 <= iw,ow <= 40
3389 A weekday as a number between 1 and 7, where 1 is Sunday.  Input format:
3390 leader + weekday + trailer.  Output format: as many characters, in all
3391 capital letters, of the English name of the weekday as will fit in the
3392 field width.
3393
3394 @item MONTHw: 3 <= iw,ow <= 40
3395 A month as a number between 1 and 12, where 1 is January.  Input format:
3396 leader + month + trailer.  Output format: as many character, in all
3397 capital letters, of the English name of the month as will fit in the
3398 field width.
3399 @end table
3400
3401 There are only two formats that may be used with string variables:
3402
3403 @table @asis
3404 @item Aw: 1 <= iw <= 255, 1 <= ow <= 254
3405 The entire field is treated as a string value.
3406
3407 @item AHEXw @result{} A: 2 <= iw <= 254; 2 <= ow <= 510
3408 The field is composed of characters in a string encoded as textual hex
3409 digit pairs.
3410
3411 The default output @var{w} is half the input @var{w}.
3412 @end table
3413
3414 @node Scratch Variables,  , Input/Output Formats, Variables
3415 @subsection Scratch Variables
3416
3417 Most of the time, variables don't retain their values between cases.
3418 Instead, either they're being read from a data file or the active file,
3419 in which case they assume the value read, or, if created with
3420 @cmd{COMPUTE} or
3421 another transformation, they're initialized to the system-missing value
3422 or to blanks, depending on type.
3423
3424 However, sometimes it's useful to have a variable that keeps its value
3425 between cases.  You can do this with @cmd{LEAVE} (@pxref{LEAVE}), or you can
3426 use a @dfn{scratch variable}.  Scratch variables are variables whose
3427 names begin with an octothorpe (@samp{#}).  
3428
3429 Scratch variables have the same properties as variables left with
3430 @cmd{LEAVE}:
3431 they retain their values between cases, and for the first case they are
3432 initialized to 0 or blanks.  They have the additional property that they
3433 are deleted before the execution of any procedure.  For this reason,
3434 scratch variables can't be used for analysis.  To obtain the same
3435 effect, use @cmd{COMPUTE} (@pxref{COMPUTE}) to copy the scratch variable's
3436 value into an ordinary variable, then analysis that variable.
3437
3438 @node Files, BNF, Variables, Language
3439 @section Files Used by PSPP
3440
3441 PSPP makes use of many files each time it runs.  Some of these it
3442 reads, some it writes, some it creates.  Here is a table listing the
3443 most important of these files:
3444
3445 @table @strong
3446 @cindex file, command
3447 @cindex file, syntax file
3448 @cindex command file
3449 @cindex syntax file
3450 @item command file
3451 @itemx syntax file
3452 These names (synonyms) refer to the file that contains instructions to
3453 PSPP that tell it what to do.  The syntax file's name is specified on
3454 the PSPP command line.  Syntax files can also be pulled in with
3455 @cmd{INCLUDE} (@pxref{INCLUDE}).
3456
3457 @cindex file, data
3458 @cindex data file
3459 @item data file
3460 Data files contain raw data in ASCII format suitable for being read in
3461 by @cmd{DATA LIST}.  Data can be embedded in the syntax
3462 file with @cmd{BEGIN DATA} and @cmd{END DATA}: this makes the
3463 syntax file a data file too.
3464
3465 @cindex file, output
3466 @cindex output file
3467 @item listing file
3468 One or more output files are created by PSPP each time it is
3469 run.  The output files receive the tables and charts produced by
3470 statistical procedures.  The output files may be in any number of formats,
3471 depending on how PSPP is configured.
3472
3473 @cindex active file
3474 @cindex file, active
3475 @item active file
3476 The active file is the ``file'' on which all PSPP procedures
3477 are performed.  The active file contains variable definitions and
3478 cases.  The active file is not necessarily a disk file: it is stored
3479 in memory if there is room.
3480 @end table
3481
3482 @node BNF,  , Files, Language
3483 @section Backus-Naur Form
3484 @cindex BNF
3485 @cindex Backus-Naur Form
3486 @cindex command syntax, description of
3487 @cindex description of command syntax
3488
3489 The syntax of some parts of the PSPP language is presented in this
3490 manual using the formalism known as @dfn{Backus-Naur Form}, or BNF. The
3491 following table describes BNF:
3492
3493 @itemize @bullet
3494 @cindex keywords
3495 @cindex terminals
3496 @item
3497 Words in all-uppercase are PSPP keyword tokens.  In BNF, these are
3498 often called @dfn{terminals}.  There are some special terminals, which
3499 are actually written in lowercase for clarity:
3500
3501 @table @asis
3502 @cindex @code{number}
3503 @item @code{number}
3504 A real number.
3505
3506 @cindex @code{integer}
3507 @item @code{integer}
3508 An integer number.
3509
3510 @cindex @code{string}
3511 @item @code{string}
3512 A string.
3513
3514 @cindex @code{var-name}
3515 @item @code{var-name}
3516 A single variable name.
3517
3518 @cindex operators
3519 @cindex punctuators
3520 @item @code{=}, @code{/}, @code{+}, @code{-}, etc.
3521 Operators and punctuators.
3522
3523 @cindex @code{.}
3524 @cindex terminal dot
3525 @cindex dot, terminal
3526 @item @code{.}
3527 The terminal dot.  This is not necessarily an actual dot in the syntax
3528 file: @xref{Commands}, for more details.
3529 @end table
3530
3531 @item
3532 @cindex productions
3533 @cindex nonterminals
3534 Other words in all lowercase refer to BNF definitions, called
3535 @dfn{productions}.  These productions are also known as
3536 @dfn{nonterminals}.  Some nonterminals are very common, so they are
3537 defined here in English for clarity:
3538
3539 @table @code
3540 @cindex @code{var-list}
3541 @item var-list
3542 A list of one or more variable names or the keyword @code{ALL}.
3543
3544 @cindex @code{expression}
3545 @item expression
3546 An expression.  @xref{Expressions}, for details.
3547 @end table
3548
3549 @item
3550 @cindex @code{::=}
3551 @cindex ``is defined as''
3552 @cindex productions
3553 @samp{::=} means ``is defined as''.  The left side of @samp{::=} gives
3554 the name of the nonterminal being defined.  The right side of @samp{::=}
3555 gives the definition of that nonterminal.  If the right side is empty,
3556 then one possible expansion of that nonterminal is nothing.  A BNF
3557 definition is called a @dfn{production}.
3558
3559 @item
3560 @cindex terminals and nonterminals, differences
3561 So, the key difference between a terminal and a nonterminal is that a
3562 terminal cannot be broken into smaller parts---in fact, every terminal
3563 is a single token (@pxref{Tokens}).  On the other hand, nonterminals are
3564 composed of a (possibly empty) sequence of terminals and nonterminals.
3565 Thus, terminals indicate the deepest level of syntax description.  (In
3566 parsing theory, terminals are the leaves of the parse tree; nonterminals
3567 form the branches.)
3568
3569 @item
3570 @cindex start symbol
3571 @cindex symbol, start
3572 The first nonterminal defined in a set of productions is called the
3573 @dfn{start symbol}.  The start symbol defines the entire syntax for
3574 that command.
3575 @end itemize
3576
3577 @node Expressions, Data Input and Output, Language, Top
3578 @chapter Mathematical Expressions
3579 @cindex expressions, mathematical
3580 @cindex mathematical expressions
3581
3582 Some PSPP commands use expressions, which share a common syntax
3583 among all PSPP commands.  Expressions are made up of
3584 @dfn{operands}, which can be numbers, strings, or variable names,
3585 separated by @dfn{operators}.  There are five types of operators:
3586 grouping, arithmetic, logical, relational, and functions.
3587
3588 Every operator takes one or more @dfn{arguments} as input and produces
3589 or @dfn{returns} exactly one result as output.  Both strings and numeric
3590 values can be used as arguments and are produced as results, but each
3591 operator accepts only specific combinations of numeric and string values
3592 as arguments.  With few exceptions, operator arguments may be
3593 full-fledged expressions in themselves.
3594
3595 @menu
3596 * Boolean Values::              Boolean values.
3597 * Missing Values in Expressions::  Using missing values in expressions.
3598 * Grouping Operators::          parentheses
3599 * Arithmetic Operators::        add sub mul div pow
3600 * Logical Operators::           AND NOT OR
3601 * Relational Operators::        EQ GE GT LE LT NE
3602 * Functions::                   More-sophisticated operators.
3603 * Order of Operations::         Operator precedence.
3604 @end menu
3605
3606 @node Boolean Values, Missing Values in Expressions, Expressions, Expressions
3607 @section Boolean Values
3608 @cindex Boolean
3609 @cindex values, Boolean
3610
3611 Some PSPP operators and expressions work with Boolean values, which
3612 represent true/false conditions.  Booleans have only three possible
3613 values: 0 (false), 1 (true), and system-missing (unknown).
3614 System-missing is neither true nor false and indicates that the true
3615 value is unknown.
3616
3617 Boolean-typed operands or function arguments must take on one of these
3618 three values.  Other values are considered false, but cause an error
3619 when the expression is evaluated.
3620
3621 Strings and Booleans are not compatible, and neither may be used in
3622 place of the other.
3623
3624 @node Missing Values in Expressions, Grouping Operators, Boolean Values, Expressions
3625 @section Missing Values in Expressions
3626
3627 String missing values are not treated specially in expressions.  Most
3628 numeric operators return system-missing when given system-missing
3629 arguments.  Exceptions are listed under particular operator
3630 descriptions.
3631
3632 User-missing values for numeric variables are always transformed into
3633 the system-missing value, except inside the arguments  to the
3634 @code{VALUE} and @code{SYSMIS} functions.
3635
3636 The missing-value functions can be used to precisely control how missing
3637 values are treated in expressions.  @xref{Missing Value Functions}, for
3638 more details.
3639
3640 @node Grouping Operators, Arithmetic Operators, Missing Values in Expressions, Expressions
3641 @section Grouping Operators
3642 @cindex parentheses
3643 @cindex @samp{(  )}
3644 @cindex grouping operators
3645 @cindex operators, grouping
3646
3647 Parentheses (@samp{()}) are the grouping operators.  Surround an
3648 expression with parentheses to force early evaluation.
3649
3650 Parentheses also surround the arguments to functions, but in that
3651 situation they act as punctuators, not as operators.
3652
3653 @node Arithmetic Operators, Logical Operators, Grouping Operators, Expressions
3654 @section Arithmetic Operators
3655 @cindex operators, arithmetic
3656 @cindex arithmetic operators
3657
3658 The arithmetic operators take numeric arguments and produce numeric
3659 results.
3660
3661 @table @code
3662 @cindex @samp{+}
3663 @cindex addition
3664 @item @var{a} + @var{b}
3665 Adds @var{a} and @var{b}, returning the sum.
3666
3667 @cindex @samp{-}
3668 @cindex subtraction
3669 @item @var{a} - @var{b}
3670 Subtracts @var{b} from @var{a}, returning the difference.
3671
3672 @cindex @samp{*}
3673 @cindex multiplication
3674 @item @var{a} * @var{b}
3675 Multiplies @var{a} and @var{b}, returning the product.
3676
3677 @cindex @samp{/}
3678 @cindex division
3679 @item @var{a} / @var{b}
3680 Divides @var{a} by @var{b}, returning the quotient.  If @var{b} is
3681 zero, the result is system-missing.
3682
3683 @cindex @samp{**}
3684 @cindex exponentiation
3685 @item @var{a} ** @var{b}
3686 Returns the result of raising @var{a} to the power @var{b}.  If
3687 @var{a} is negative and @var{b} is not an integer, the result is
3688 system-missing.  The result of @code{0**0} is system-missing as well.
3689
3690 @cindex @samp{-}
3691 @cindex negation
3692 @item - @var{a}
3693 Reverses the sign of @var{a}.  
3694 @end table
3695
3696 @node Logical Operators, Relational Operators, Arithmetic Operators, Expressions
3697 @section Logical Operators
3698 @cindex logical operators
3699 @cindex operators, logical
3700
3701 @cindex true
3702 @cindex false
3703 @cindex Boolean
3704 @cindex values, system-missing
3705 @cindex system-missing
3706 The logical operators take logical arguments and produce logical
3707 results, meaning ``true or false''.  PSPP logical operators are
3708 not true Boolean operators because they may also result in a
3709 system-missing value.
3710
3711 @table @code
3712 @cindex @code{AND}
3713 @cindex @samp{&}
3714 @cindex intersection, logical
3715 @cindex logical intersection
3716 @item @var{a} AND @var{b}
3717 @itemx @var{a} & @var{b}
3718 True if both @var{a} and @var{b} are true, false otherwise.  If one
3719 argument is false, the result is false even if the other is missing.  If
3720 both arguments are missing, the result is missing.
3721
3722 @cindex @code{OR}
3723 @cindex @samp{|}
3724 @cindex union, logical
3725 @cindex logical union
3726 @item @var{a} OR @var{b}
3727 @itemx @var{a} | @var{b}
3728 True if at least one of @var{a} and @var{b} is true.  If one argument is
3729 true, the result is true even if the other argument is missing.  If both
3730 arguments are missing, the result is missing.
3731
3732 @cindex @code{NOT}
3733 @cindex @samp{~}
3734 @cindex inversion, logical
3735 @cindex logical inversion
3736 @item NOT @var{a}
3737 @itemx ~ @var{a}
3738 True if @var{a} is false.  If the argument is missing, then the result
3739 is missing.
3740 @end table
3741
3742 @node Relational Operators, Functions, Logical Operators, Expressions
3743 @section Relational Operators
3744
3745 The relational operators take numeric or string arguments and produce Boolean
3746 results.
3747
3748 Strings cannot be compared to numbers.  When strings of different
3749 lengths are compared, the shorter string is right-padded with spaces
3750 to match the length of the longer string.
3751
3752 The results of string comparisons, other than tests for equality or
3753 inequality, are dependent on the character set in use.  String
3754 comparisons are case-sensitive.
3755
3756 @table @code
3757 @cindex equality, testing
3758 @cindex testing for equality
3759 @cindex @code{EQ}
3760 @cindex @samp{=}
3761 @item @var{a} EQ @var{b}
3762 @itemx @var{a} = @var{b}
3763 True if @var{a} is equal to @var{b}.
3764
3765 @cindex less than or equal to
3766 @cindex @code{LE}
3767 @cindex @code{<=}
3768 @item @var{a} LE @var{b}
3769 @itemx @var{a} <= @var{b}
3770 True if @var{a} is less than or equal to @var{b}.
3771
3772 @cindex less than
3773 @cindex @code{LT}
3774 @cindex @code{<}
3775 @item @var{a} LT @var{b}
3776 @itemx @var{a} < @var{b}
3777 True if @var{a} is less than @var{b}.
3778
3779 @cindex greater than or equal to
3780 @cindex @code{GE}
3781 @cindex @code{>=}
3782 @item @var{a} GE @var{b}
3783 @itemx @var{a} >= @var{b}
3784 True if @var{a} is greater than or equal to @var{b}.
3785
3786 @cindex greater than
3787 @cindex @code{GT}
3788 @cindex @samp{>}
3789 @item @var{a} GT @var{b}
3790 @itemx @var{a} > @var{b}
3791 True if @var{a} is greater than @var{b}.
3792
3793 @cindex inequality, testing
3794 @cindex testing for inequality
3795 @cindex @code{NE}
3796 @cindex @code{~=}
3797 @cindex @code{<>}
3798 @item @var{a} NE @var{b}
3799 @itemx @var{a} ~= @var{b}
3800 @itemx @var{a} <> @var{b}
3801 True is @var{a} is not equal to @var{b}.
3802 @end table
3803
3804 @node Functions, Order of Operations, Relational Operators, Expressions
3805 @section Functions
3806 @cindex functions
3807
3808 @cindex mathematics
3809 @cindex operators
3810 @cindex parentheses
3811 @cindex @code{(}
3812 @cindex @code{)}
3813 @cindex names, of functions
3814 PSPP functions provide mathematical abilities above and beyond
3815 those possible using simple operators.  Functions have a common
3816 syntax: each is composed of a function name followed by a left
3817 parenthesis, one or more arguments, and a right parenthesis.  Function
3818 names are @strong{not} reserved; their names are specially treated
3819 only when followed by a left parenthesis: @code{EXP(10)} refers to the
3820 constant value @code{e} raised to the 10th power, but @code{EXP} by
3821 itself refers to the value of variable EXP.
3822
3823 The sections below describe each function in detail.
3824
3825 @menu
3826 * Advanced Mathematics::        EXP LG10 LN SQRT
3827 * Miscellaneous Mathematics::   ABS MOD MOD10 RND TRUNC
3828 * Trigonometry::                ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
3829 * Missing Value Functions::     MISSING NMISS NVALID SYSMIS VALUE
3830 * Pseudo-Random Numbers::       NORMAL UNIFORM
3831 * Set Membership::              ANY RANGE
3832 * Statistical Functions::       CFVAR MAX MEAN MIN SD SUM VARIANCE
3833 * String Functions::            CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER 
3834                                 RINDEX RPAD RTRIM STRING SUBSTR UPCASE
3835 * Time & Date::                 CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
3836 * Miscellaneous Functions::     LAG YRMODA
3837 * Functions Not Implemented::   CDF.xxx CDFNORM IDF.xxx NCDF.xxx PROBIT RV.xxx
3838 @end menu
3839
3840 @node Advanced Mathematics, Miscellaneous Mathematics, Functions, Functions
3841 @subsection Advanced Mathematical Functions
3842 @cindex mathematics, advanced
3843
3844 Advanced mathematical functions take numeric arguments and produce
3845 numeric results.
3846
3847 @deftypefn {Function} {} EXP (@var{exponent})
3848 Returns @i{e} (approximately 2.71828) raised to power @var{exponent}.
3849 @end deftypefn
3850
3851 @cindex logarithms
3852 @deftypefn {Function} {} LG10 (@var{number})
3853 Takes the base-10 logarithm of @var{number}.  If @var{number} is
3854 not positive, the result is system-missing.
3855 @end deftypefn
3856
3857 @deftypefn {Function} {} LN (@var{number})
3858 Takes the base-@i{e} logarithm of @var{number}.  If @var{number} is
3859 not positive, the result is system-missing.
3860 @end deftypefn
3861
3862 @cindex square roots
3863 @deftypefn {Function} {} SQRT (@var{number})
3864 Takes the square root of @var{number}.  If @var{number} is negative,
3865 the result is system-missing.
3866 @end deftypefn
3867
3868 @node Miscellaneous Mathematics, Trigonometry, Advanced Mathematics, Functions
3869 @subsection Miscellaneous Mathematical Functions
3870 @cindex mathematics, miscellaneous
3871
3872 Miscellaneous mathematical functions take numeric arguments and produce
3873 numeric results.
3874
3875 @cindex absolute value
3876 @deftypefn {Function} {} ABS (@var{number})
3877 Results in the absolute value of @var{number}.
3878 @end deftypefn
3879
3880 @cindex modulus
3881 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
3882 Returns the remainder (modulus) of @var{numerator} divided by
3883 @var{denominator}.  If @var{denominator} is 0, the result is
3884 system-missing.  However, if @var{numerator} is 0 and
3885 @var{denominator} is system-missing, the result is 0.
3886 @end deftypefn
3887
3888 @cindex modulus, by 10
3889 @deftypefn {Function} {} MOD10 (@var{number})
3890 Returns the remainder when @var{number} is divided by 10.  If
3891 @var{number} is negative, MOD10(@var{number}) is negative or zero.
3892 @end deftypefn
3893
3894 @cindex rounding
3895 @deftypefn {Function} {} RND (@var{number})
3896 Takes the absolute value of @var{number} and rounds it to an integer.
3897 Then, if @var{number} was negative originally, negates the result.
3898 @end deftypefn
3899
3900 @cindex truncation
3901 @deftypefn {Function} {} TRUNC (@var{number})
3902 Discards the fractional part of @var{number}; that is, rounds
3903 @var{number} towards zero.
3904 @end deftypefn
3905
3906 @node Trigonometry, Missing Value Functions, Miscellaneous Mathematics, Functions
3907 @subsection Trigonometric Functions
3908 @cindex trigonometry
3909
3910 Trigonometric functions take numeric arguments and produce numeric
3911 results.
3912
3913 @cindex arccosine
3914 @cindex inverse cosine
3915 @deftypefn {Function} {} ARCOS (@var{number})
3916 Takes the arccosine, in radians, of @var{number}.  Results in
3917 system-missing if @var{number} is not between -1 and 1.
3918 @end deftypefn
3919
3920 @cindex arcsine
3921 @cindex inverse sine
3922 @deftypefn {Function} {} ARSIN (@var{number})
3923 Takes the arcsine, in radians, of @var{number}.  Results in
3924 system-missing if @var{number} is not between -1 and 1 inclusive.
3925 @end deftypefn
3926
3927 @cindex arctangent
3928 @cindex inverse tangent
3929 @deftypefn {Function} {} ARTAN (@var{number})
3930 Takes the arctangent, in radians, of @var{number}.
3931 @end deftypefn
3932
3933 @cindex cosine
3934 @deftypefn {Function} {} COS (@var{angle})
3935 Takes the cosine of @var{angle} which should be in radians.
3936 @end deftypefn
3937
3938 @cindex sine
3939 @deftypefn {Function} {} SIN (@var{angle})
3940 Takes the sine of @var{angle} which should be in radians.
3941 @end deftypefn
3942
3943 @cindex tangent
3944 @deftypefn {Function} {} TAN (@var{angle})
3945 Takes the tangent of @var{angle} which should be in radians.
3946 Results in system-missing at values
3947 of @var{angle} that are too close to odd multiples of pi/2.
3948 Portability: none.
3949 @end deftypefn
3950
3951 @node Missing Value Functions, Pseudo-Random Numbers, Trigonometry, Functions
3952 @subsection Missing-Value Functions
3953 @cindex missing values
3954 @cindex values, missing
3955 @cindex functions, missing-value
3956
3957 Missing-value functions take various numeric arguments and yield
3958 various types of results.  Note that the normal rules of evaluation
3959 apply within expression arguments to these functions.  In particular,
3960 user-missing values for numeric variables are converted to
3961 system-missing values.
3962
3963 @deftypefn {Function} {} MISSING (@var{expr})
3964 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
3965 @end deftypefn
3966
3967 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
3968 Each argument must be a numeric expression.  Returns the number of
3969 system-missing values in the list.  As a special extension,
3970 the syntax @code{@var{var1} TO @var{var2}} may be used to refer to a
3971 range of variables; see @ref{Sets of Variables}, for more details.
3972 @end deftypefn
3973
3974 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
3975 Each argument must be a numeric expression.  Returns the number of
3976 values in the list that are not system-missing.  As a special extension,
3977 the syntax @code{@var{var1} TO @var{var2}} may be used to refer to a
3978 range of variables; see @ref{Sets of Variables}, for more details.
3979 @end deftypefn
3980
3981 @deftypefn {Function} {} SYSMIS (@var{expr})
3982 When @var{expr} is simply the name of a numeric variable, returns 1 if
3983 the variable has the system-missing value, 0 if it is user-missing or
3984 not missing.  If given @var{expr} takes another form, results in 1 if
3985 the value is system-missing, 0 otherwise.
3986 @end deftypefn
3987
3988 @deftypefn {Function} {} VALUE (@var{variable})
3989 Prevents the user-missing values of @var{variable} from being
3990 transformed into system-missing values, and always results in the
3991 actual value of @var{variable}, whether it is user-missing,
3992 system-missing or not missing at all.
3993 @end deftypefn
3994
3995 @node Pseudo-Random Numbers, Set Membership, Missing Value Functions, Functions
3996 @subsection Pseudo-Random Number Generation Functions
3997 @cindex random numbers
3998 @cindex pseudo-random numbers (see random numbers)
3999
4000 Pseudo-random number generation functions take numeric arguments and
4001 produce numeric results.
4002
4003 PSPP uses the alleged RC4 cipher as a pseudo-random number generator
4004 (PRNG).  The bytes output by this PRNG are system-independent for a
4005 given random seed, but differences in endianness and floating-point
4006 formats will make PRNG results differ from system to system.  RC4
4007 should produce high-quality random numbers for simulation purposes.
4008 (If you're concerned about the quality of the random number generator,
4009 well, you're using a statistical processing package---analyze it!)
4010
4011 PSPP's implementation of RC4 has not undergone any security auditing.
4012 Furthermore, various precautions that would be necessary for secure
4013 operation, such as secure seeding and discarding the first several
4014 bytes of output, have not been taken.  Therefore, PSPP's
4015 implementation of RC4 should not be used for security purposes.
4016
4017 @cindex random numbers, normally-distributed
4018 @deftypefn {Function} {} NORMAL (@var{number})
4019 Results in a random number.  Results from @code{NORMAL} are normally
4020 distributed with a mean of 0 and a standard deviation of @var{number}.
4021 @end deftypefn
4022
4023 @cindex random numbers, uniformly-distributed
4024 @deftypefn {Function} {} UNIFORM (@var{number})
4025 Results in a random number between 0 and @var{number}.  Results from
4026 @code{UNIFORM} are evenly distributed across its entire range.  There
4027 may be a maximum on the largest random number ever generated---this is
4028 often 
4029 @ifinfo 
4030 2**31-1 
4031 @end ifinfo
4032 @tex
4033 $2^{31}-1$
4034 @end tex
4035 (2,147,483,647), but it may be orders of magnitude
4036 higher or lower.
4037 @end deftypefn
4038
4039 @node Set Membership, Statistical Functions, Pseudo-Random Numbers, Functions
4040 @subsection Set-Membership Functions
4041 @cindex set membership
4042 @cindex membership, of set
4043
4044 Set membership functions determine whether a value is a member of a set.
4045 They take a set of numeric arguments or a set of string arguments, and
4046 produce Boolean results.
4047
4048 String comparisons are performed according to the rules given in
4049 @ref{Relational Operators}.
4050
4051 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
4052 Results in true if @var{value} is equal to any of the @var{set}
4053 values.  Otherwise, results in false.  If @var{value} is
4054 system-missing, returns system-missing.  System-missing values in
4055 @var{set} do not cause ANY to return system-missing.
4056 @end deftypefn
4057
4058 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
4059 Results in true if @var{value} is in any of the intervals bounded by
4060 @var{low} and @var{high} inclusive.  Otherwise, results in false.
4061 Each @var{low} must be less than or equal to its corresponding
4062 @var{high} value.  @var{low} and @var{high} must be given in pairs.
4063 If @var{value} is system-missing, returns system-missing.
4064 System-missing values in @var{set} do not cause RANGE to return
4065 system-missing.
4066 @end deftypefn
4067
4068 @node Statistical Functions, String Functions, Set Membership, Functions
4069 @subsection Statistical Functions
4070 @cindex functions, statistical
4071 @cindex statistics
4072
4073 Statistical functions compute descriptive statistics on a list of
4074 values.  Some statistics can be computed on numeric or string values;
4075 other can only be computed on numeric values.  Their results have the
4076 same type as their arguments.  The current case's weighting factor
4077 (@pxref{WEIGHT}) has no effect on statistical functions.
4078
4079 @cindex arguments, minimum valid
4080 @cindex minimum valid number of arguments
4081 With statistical functions it is possible to specify a minimum number of
4082 non-missing arguments for the function to be evaluated.  To do so,
4083 append a dot and the number to the function name.  For instance, to
4084 specify a minimum of three valid arguments to the MEAN function, use the
4085 name @code{MEAN.3}.
4086
4087 @cindex coefficient of variation
4088 @cindex variation, coefficient of
4089 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
4090 Results in the coefficient of variation of the values of @var{number}.
4091 This function requires at least two valid arguments to give a
4092 non-missing result.  (The coefficient of variation is the standard
4093 deviation divided by the mean.)
4094 @end deftypefn
4095
4096 @cindex maximum
4097 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
4098 Results in the value of the greatest @var{value}.  The @var{value}s may
4099 be numeric or string.  Although at least two arguments must be given,
4100 only one need be valid for MAX to give a non-missing result.
4101 @end deftypefn
4102
4103 @cindex mean
4104 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
4105 Results in the mean of the values of @var{number}.  Although at least
4106 two arguments must be given, only one need be valid for MEAN to give a
4107 non-missing result.
4108 @end deftypefn
4109
4110 @cindex minimum
4111 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
4112 Results in the value of the least @var{value}.  The @var{value}s may
4113 be numeric or string.  Although at least two arguments must be given,
4114 only one need be valid for MAX to give a non-missing result.
4115 @end deftypefn
4116
4117 @cindex standard deviation
4118 @cindex deviation, standard
4119 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
4120 Results in the standard deviation of the values of @var{number}.
4121 This function requires at least two valid arguments to give a
4122 non-missing result.
4123 @end deftypefn
4124
4125 @cindex sum
4126 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
4127 Results in the sum of the values of @var{number}.  Although at least two
4128 arguments must be given, only one need by valid for SUM to give a
4129 non-missing result.
4130 @end deftypefn
4131
4132 @cindex variance
4133 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
4134 Results in the variance of the values of @var{number}.  This function
4135 requires at least two valid arguments to give a non-missing result.
4136 @end deftypefn
4137
4138 @node String Functions, Time & Date, Statistical Functions, Functions
4139 @subsection String Functions
4140 @cindex functions, string
4141 @cindex string functions
4142
4143 String functions take various arguments and return various results.
4144
4145 @cindex concatenation
4146 @cindex strings, concatenation of
4147 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
4148 Returns a string consisting of each @var{string} in sequence.
4149 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
4150 The resultant string is truncated to a maximum of 255 characters.
4151 @end deftypefn
4152
4153 @cindex searching strings
4154 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
4155 Returns a positive integer indicating the position of the first
4156 occurrence @var{needle} in @var{haystack}.  Returns 0 if @var{haystack}
4157 does not contain @var{needle}.  Returns system-missing if @var{needle}
4158 is an empty string.
4159 @end deftypefn
4160
4161 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle}, @var{divisor})
4162 Divides @var{needle} into parts, each with length @var{divisor}.
4163 Searches @var{haystack} for the first occurrence of each part, and
4164 returns the smallest value.  Returns 0 if @var{haystack} does not
4165 contain any part in @var{needle}.  It is an error if @var{divisor}
4166 cannot be evenly divided into the length of @var{needle}.  Returns
4167 system-missing if @var{needle} is an empty string.
4168 @end deftypefn
4169
4170 @cindex strings, finding length of
4171 @deftypefn {Function} {} LENGTH (@var{string})
4172 Returns the number of characters in @var{string}.
4173 @end deftypefn
4174
4175 @cindex strings, case of
4176 @deftypefn {Function} {} LOWER (@var{string})
4177 Returns a string identical to @var{string} except that all uppercase
4178 letters are changed to lowercase letters.  The definitions of
4179 ``uppercase'' and ``lowercase'' are system-dependent.
4180 @end deftypefn
4181
4182 @cindex strings, padding
4183 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
4184 If @var{string} is at least @var{length} characters in length, returns
4185 @var{string} unchanged.  Otherwise, returns @var{string} padded with
4186 spaces on the left side to length @var{length}.  Returns an empty string
4187 if @var{length} is system-missing, negative, or greater than 255.
4188 @end deftypefn
4189
4190 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
4191 If @var{string} is at least @var{length} characters in length, returns
4192 @var{string} unchanged.  Otherwise, returns @var{string} padded with
4193 @var{padding} on the left side to length @var{length}.  Returns an empty
4194 string if @var{length} is system-missing, negative, or greater than 255, or
4195 if @var{padding} does not contain exactly one character.
4196 @end deftypefn
4197
4198 @cindex strings, trimming
4199 @cindex whitespace, trimming
4200 @deftypefn {Function} {} LTRIM (@var{string})
4201 Returns @var{string}, after removing leading spaces.  Other whitespace,
4202 such as tabs, carriage returns, line feeds, and vertical tabs, is not
4203 removed.
4204 @end deftypefn
4205
4206 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
4207 Returns @var{string}, after removing leading @var{padding} characters.
4208 If @var{padding} does not contain exactly one character, returns an
4209 empty string.
4210 @end deftypefn
4211
4212 @cindex numbers, converting from strings
4213 @cindex strings, converting to numbers
4214 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
4215 Returns the number produced when @var{string} is interpreted according
4216 to format specifier @var{format}.  If the format width @var{w} is less
4217 than the length of @var{string}, then only the first @var{w}
4218 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
4219 and @code{NUMBER("1234", F3.0)} both have value 123.  If @var{w} is
4220 greater than @var{string}'s length, then it is treated as if it were
4221 right-padded with spaces.  If @var{string} is not in the correct
4222 format for @var{format}, system-missing is returned.
4223 @end deftypefn
4224
4225 @cindex strings, searching backwards
4226 @deftypefn {Function} {} RINDEX (@var{string}, @var{format})
4227 Returns a positive integer indicating the position of the last
4228 occurrence of @var{needle} in @var{haystack}.  Returns 0 if
4229 @var{haystack} does not contain @var{needle}.  Returns system-missing if
4230 @var{needle} is an empty string.
4231 @end deftypefn
4232
4233 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{divisor})
4234 Divides @var{needle} into parts, each with length @var{divisor}.
4235 Searches @var{haystack} for the last occurrence of each part, and
4236 returns the largest value.  Returns 0 if @var{haystack} does not contain
4237 any part in @var{needle}.  It is an error if @var{divisor} cannot be
4238 evenly divided into the length of @var{needle}.  Returns system-missing
4239 if @var{needle} is an empty string.
4240 @end deftypefn
4241
4242 @cindex padding strings
4243 @cindex strings, padding
4244 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
4245 If @var{string} is at least @var{length} characters in length, returns
4246 @var{string} unchanged.  Otherwise, returns @var{string} padded with
4247 spaces on the right to length @var{length}.  Returns an empty string if
4248 @var{length} is system-missing, negative, or greater than 255.
4249 @end deftypefn
4250
4251 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
4252 If @var{string} is at least @var{length} characters in length, returns
4253 @var{string} unchanged.  Otherwise, returns @var{string} padded with
4254 @var{padding} on the right to length @var{length}.  Returns an empty
4255 string if @var{length} is system-missing, negative, or greater than 255,
4256 or if @var{padding} does not contain exactly one character.
4257 @end deftypefn
4258
4259 @cindex strings, trimming
4260 @cindex whitespace, trimming
4261 @deftypefn {Function} {} RTRIM (@var{string})
4262 Returns @var{string}, after removing trailing spaces.  Other types of
4263 whitespace are not removed.
4264 @end deftypefn
4265
4266 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
4267 Returns @var{string}, after removing trailing @var{padding} characters.
4268 If @var{padding} does not contain exactly one character, returns an
4269 empty string.
4270 @end deftypefn
4271
4272 @cindex strings, converting from numbers
4273 @cindex numbers, converting to strings
4274 @deftypefn {Function} {} STRING (@var{number}, @var{format})
4275 Returns a string corresponding to @var{number} in the format given by
4276 format specifier @var{format}.  For example, @code{STRING(123.56, F5.1)}
4277 has the value @code{"123.6"}.
4278 @end deftypefn
4279
4280 @cindex substrings
4281 @cindex strings, taking substrings of
4282 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
4283 Returns a string consisting of the value of @var{string} from position
4284 @var{start} onward.  Returns an empty string if @var{start} is system-missing
4285 or has a value less than 1 or greater than the number of characters in
4286 @var{string}.
4287 @end deftypefn
4288
4289 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
4290 Returns a string consisting of the first @var{count} characters from
4291 @var{string} beginning at position @var{start}.  Returns an empty string
4292 if @var{start} or @var{count} is system-missing, if @var{start} is less
4293 than 1 or greater than the number of characters in @var{string}, or if
4294 @var{count} is less than 1.  Returns a string shorter than @var{count}
4295 characters if @var{start} + @var{count} - 1 is greater than the number
4296 of characters in @var{string}.  Examples: @code{SUBSTR("abcdefg", 3, 2)}
4297 has value @code{"cd"}; @code{SUBSTR("Ben Pfaff", 5, 10)} has the value
4298 @code{"Pfaff"}.
4299 @end deftypefn
4300
4301 @cindex case conversion
4302 @cindex strings, case of
4303 @deftypefn {Function} {} UPCASE (@var{string})
4304 Returns @var{string}, changing lowercase letters to uppercase letters.
4305 @end deftypefn
4306
4307 @node Time & Date, Miscellaneous Functions, String Functions, Functions
4308 @subsection Time & Date Functions
4309 @cindex functions, time & date
4310 @cindex times
4311 @cindex dates
4312
4313 @cindex dates, legal range of
4314 The legal range of dates for use in PSPP is 15 Oct 1582
4315 through 31 Dec 19999.
4316
4317 @cindex arguments, invalid
4318 @cindex invalid arguments
4319 @quotation
4320 @strong{Please note:} Most time & date extraction functions will accept
4321 invalid arguments:
4322
4323 @itemize @bullet
4324 @item
4325 Negative numbers in PSPP time format.
4326 @item
4327 Numbers less than 86,400 in PSPP date format.
4328 @end itemize
4329
4330 However, sensible results are not guaranteed for these invalid values.
4331 The given equivalents for these functions are definitely not guaranteed
4332 for invalid values.
4333 @end quotation
4334
4335 @quotation
4336 @strong{Please note also:} The time & date construction
4337 functions @strong{do} produce reasonable and useful results for
4338 out-of-range values; these are not considered invalid.
4339 @end quotation
4340
4341 @menu
4342 * Time & Date Concepts::        How times & dates are defined and represented
4343 * Time Construction::           TIME.@{DAYS HMS@}
4344 * Time Extraction::             CTIME.@{DAYS HOURS MINUTES SECONDS@}
4345 * Date Construction::           DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
4346 * Date Extraction::             XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
4347                                        QUARTER SECOND TDAY TIME WEEK
4348                                        WKDAY YEAR@}
4349 @end menu
4350
4351 @node Time & Date Concepts, Time Construction, Time & Date, Time & Date
4352 @subsubsection How times & dates are defined and represented
4353
4354 @cindex time, concepts
4355 @cindex time, intervals
4356 Times and dates are handled by PSPP as single numbers.  A
4357 @dfn{time} is an interval.  PSPP measures times in seconds.
4358 Thus, the following intervals correspond with the numeric values given:
4359                 
4360 @example
4361           10 minutes                        600
4362           1 hour                          3,600
4363           1 day, 3 hours, 10 seconds     97,210
4364           40 days                     3,456,000
4365           10010 d, 14 min, 24 s     864,864,864
4366 @end example
4367
4368 @cindex dates, concepts
4369 @cindex time, instants of
4370 A @dfn{date}, on the other hand, is a particular instant in the past or
4371 the future.  PSPP represents a date as a number of seconds after the
4372 midnight that separated 8 Oct 1582 and 9 Oct 1582.  (Please note that 15
4373 Oct 1582 immediately followed 9 Oct 1582.)  Thus, the midnights before
4374 the dates given below correspond with the numeric PSPP dates given:
4375
4376 @example
4377               15 Oct 1582                86,400
4378                4 Jul 1776         6,113,318,400
4379                1 Jan 1900        10,010,390,400
4380                1 Oct 1978        12,495,427,200
4381               24 Aug 1995        13,028,601,600
4382 @end example
4383
4384 @cindex time, mathematical properties of
4385 @cindex mathematics, applied to times & dates
4386 @cindex dates, mathematical properties of
4387 @noindent
4388 Please note: 
4389
4390 @itemize @bullet
4391 @item
4392 A time may be added to, or subtracted from, a date, resulting in a date.
4393
4394 @item
4395 The difference of two dates may be taken, resulting in a time.  
4396
4397 @item 
4398 Two times may be added to, or subtracted from, each other, resulting in
4399 a time.
4400 @end itemize
4401
4402 (Adding two dates does not produce a useful result.)
4403
4404 Since times and dates are merely numbers, the ordinary addition and
4405 subtraction operators are employed for these purposes.
4406
4407 @quotation
4408 @strong{Please note:} Many dates and times have extremely large
4409 values---just look at the values above.  Thus, it is not a good idea to
4410 take powers of these values; also, the accuracy of some procedures may
4411 be affected.  If necessary, convert times or dates in seconds to some
4412 other unit, like days or years, before performing analysis.
4413 @end quotation
4414
4415 @node Time Construction, Time Extraction, Time & Date Concepts, Time & Date
4416 @subsubsection Functions that Produce Times
4417 @cindex times, constructing
4418 @cindex constructing times
4419
4420 These functions take numeric arguments and produce numeric results in
4421 PSPP time format.
4422
4423 @cindex days
4424 @cindex time, in days
4425 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
4426 Results in a time value corresponding to @var{ndays} days.
4427 (@code{TIME.DAYS(@var{x})} is equivalent to @code{@var{x} * 60 * 60 *
4428 24}.)
4429 @end deftypefn
4430
4431 @cindex hours-minutes-seconds
4432 @cindex time, in hours-minutes-seconds
4433 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
4434 Results in a time value corresponding to @var{nhours} hours, @var{nmins}
4435 minutes, and @var{nsecs} seconds.  (@code{TIME.HMS(@var{h}, @var{m},
4436 @var{s})} is equivalent to @code{@var{h}*60*60 + @var{m}*60 +
4437 @var{s}}.)
4438 @end deftypefn
4439
4440 @node Time Extraction, Date Construction, Time Construction, Time & Date
4441 @subsubsection Functions that Examine Times
4442 @cindex extraction, of time
4443 @cindex time examination
4444 @cindex examination, of times
4445 @cindex time, lengths of
4446
4447 These functions take numeric arguments in PSPP time format and
4448 give numeric results.
4449
4450 @cindex days
4451 @cindex time, in days
4452 @deftypefn {Function} {} CTIME.DAYS (@var{time})
4453 Results in the number of days and fractional days in @var{time}.
4454 (@code{CTIME.DAYS(@var{x})} is equivalent to @code{@var{x}/60/60/24}.)
4455 @end deftypefn
4456
4457 @cindex hours
4458 @cindex time, in hours
4459 @deftypefn {Function} {} CTIME.HOURS (@var{time})
4460 Results in the number of hours and fractional hours in @var{time}.
4461 (@code{CTIME.HOURS(@var{x})} is equivalent to @code{@var{x}/60/60}.)
4462 @end deftypefn
4463
4464 @cindex minutes
4465 @cindex time, in minutes
4466 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
4467 Results in the number of minutes and fractional minutes in @var{time}.
4468 (@code{CTIME.MINUTES(@var{x})} is equivalent to @code{@var{x}/60}.)
4469 @end deftypefn
4470
4471 @cindex seconds
4472 @cindex time, in seconds
4473 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
4474 Results in the number of seconds and fractional seconds in @var{time}.
4475 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
4476 equivalent to @code{@var{x}}.)
4477 @end deftypefn
4478
4479 @node Date Construction, Date Extraction, Time Extraction, Time & Date
4480 @subsubsection Functions that Produce Dates
4481 @cindex dates, constructing
4482 @cindex constructing dates
4483
4484 @cindex arguments, of date construction functions
4485 These functions take numeric arguments and give numeric results in the
4486 PSPP date format.  Arguments taken by these functions are:
4487
4488 @table @var
4489 @item day
4490 Refers to a day of the month between 1 and 31.
4491
4492 @item month
4493 Refers to a month of the year between 1 and 12.
4494
4495 @item quarter
4496 Refers to a quarter of the year between 1 and 4.  The quarters of the
4497 year begin on the first days of months 1, 4, 7, and 10.
4498
4499 @item week
4500 Refers to a week of the year between 1 and 53.
4501
4502 @item yday
4503 Refers to a day of the year between 1 and 366.
4504
4505 @item year
4506 Refers to a year between 1582 and 19999.
4507 @end table
4508
4509 @cindex arguments, invalid
4510 If these functions' arguments are out-of-range, they are correctly
4511 normalized before conversion to date format.  Non-integers are rounded
4512 toward zero.
4513
4514 @cindex day-month-year
4515 @cindex dates, day-month-year
4516 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
4517 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
4518 Results in a date value corresponding to the midnight before day
4519 @var{day} of month @var{month} of year @var{year}.
4520 @end deftypefn
4521
4522 @cindex month-year
4523 @cindex dates, month-year
4524 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
4525 Results in a date value corresponding to the midnight before the first
4526 day of month @var{month} of year @var{year}.
4527 @end deftypefn
4528
4529 @cindex quarter-year
4530 @cindex dates, quarter-year
4531 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
4532 Results in a date value corresponding to the midnight before the first
4533 day of quarter @var{quarter} of year @var{year}.
4534 @end deftypefn
4535
4536 @cindex week-year
4537 @cindex dates, week-year
4538 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
4539 Results in a date value corresponding to the midnight before the first
4540 day of week @var{week} of year @var{year}.
4541 @end deftypefn
4542
4543 @cindex year-day
4544 @cindex dates, year-day
4545 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
4546 Results in a date value corresponding to the midnight before day
4547 @var{yday} of year @var{year}.
4548 @end deftypefn
4549
4550 @node Date Extraction,  , Date Construction, Time & Date
4551 @subsubsection Functions that Examine Dates
4552 @cindex extraction, of dates
4553 @cindex date examination
4554
4555 @cindex arguments, of date extraction functions
4556 These functions take numeric arguments in PSPP date or time
4557 format and give numeric results.  These names are used for arguments:
4558
4559 @table @var
4560 @item date
4561 A numeric value in PSPP date format.
4562
4563 @item time
4564 A numeric value in PSPP time format.
4565
4566 @item time-or-date
4567 A numeric value in PSPP time or date format.
4568 @end table
4569
4570 @cindex days
4571 @cindex dates, in days
4572 @cindex time, in days
4573 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
4574 For a time, results in the time corresponding to the number of whole
4575 days @var{date-or-time} includes.  For a date, results in the date
4576 corresponding to the latest midnight at or before @var{date-or-time};
4577 that is, gives the date that @var{date-or-time} is in.
4578 (XDATE.DATE(@var{x}) is equivalent to TRUNC(@var{x}/86400)*86400.)
4579 Applying this function to a time is a non-portable feature.
4580 @end deftypefn
4581
4582 @cindex hours
4583 @cindex dates, in hours
4584 @cindex time, in hours
4585 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
4586 For a time, results in the number of whole hours beyond the number of
4587 whole days represented by @var{date-or-time}.  For a date, results in
4588 the hour (as an integer between 0 and 23) corresponding to
4589 @var{date-or-time}.  (XDATE.HOUR(@var{x}) is equivalent to
4590 MOD(TRUNC(@var{x}/3600),24))  Applying this function to a time is a
4591 non-portable feature.
4592 @end deftypefn
4593
4594 @cindex day of the year
4595 @cindex dates, day of the year
4596 @deftypefn {Function} {} XDATE.JDAY (@var{date})
4597 Results in the day of the year (as an integer between 1 and 366)
4598 corresponding to @var{date}.
4599 @end deftypefn
4600
4601 @cindex day of the month
4602 @cindex dates, day of the month
4603 @deftypefn {Function} {} XDATE.MDAY (@var{date})
4604 Results in the day of the month (as an integer between 1 and 31)
4605 corresponding to @var{date}.
4606 @end deftypefn
4607
4608 @cindex minutes
4609 @cindex dates, in minutes
4610 @cindex time, in minutes
4611 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
4612 Results in the number of minutes (as an integer between 0 and 59) after
4613 the last hour in @var{time-or-date}.  (XDATE.MINUTE(@var{x}) is
4614 equivalent to MOD(TRUNC(@var{x}/60),60)) Applying this function to a
4615 time is a non-portable feature.
4616 @end deftypefn
4617
4618 @cindex months
4619 @cindex dates, in months
4620 @deftypefn {Function} {} XDATE.MONTH (@var{date})
4621 Results in the month of the year (as an integer between 1 and 12)
4622 corresponding to @var{date}.
4623 @end deftypefn
4624
4625 @cindex quarters
4626 @cindex dates, in quarters
4627 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
4628 Results in the quarter of the year (as an integer between 1 and 4)
4629 corresponding to @var{date}.
4630 @end deftypefn
4631
4632 @cindex seconds
4633 @cindex dates, in seconds
4634 @cindex time, in seconds
4635 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
4636 Results in the number of whole seconds after the last whole minute (as
4637 an integer between 0 and 59) in @var{time-or-date}.
4638 (XDATE.SECOND(@var{x}) is equivalent to MOD(@var{x}, 60).)  Applying
4639 this function to a time is a non-portable feature.
4640 @end deftypefn
4641
4642 @cindex days
4643 @cindex times, in days
4644 @deftypefn {Function} {} XDATE.TDAY (@var{time})
4645 Results in the number of whole days (as an integer) in @var{time}.
4646 (XDATE.TDAY(@var{x}) is equivalent to TRUNC(@var{x}/86400).)
4647 @end deftypefn
4648
4649 @cindex time
4650 @cindex dates, time of day
4651 @deftypefn {Function} {} XDATE.TIME (@var{date})
4652 Results in the time of day at the instant corresponding to @var{date},
4653 in PSPP time format.  This is the number of seconds since
4654 midnight on the day corresponding to @var{date}.  (XDATE.TIME(@var{x}) is
4655 equivalent to TRUNC(@var{x}/86400)*86400.)
4656 @end deftypefn
4657
4658 @cindex week
4659 @cindex dates, in weeks
4660 @deftypefn {Function} {} XDATE.WEEK (@var{date})
4661 Results in the week of the year (as an integer between 1 and 53)
4662 corresponding to @var{date}.
4663 @end deftypefn
4664
4665 @cindex day of the week
4666 @cindex weekday
4667 @cindex dates, day of the week
4668 @cindex dates, in weekdays
4669 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
4670 Results in the day of week (as an integer between 1 and 7) corresponding
4671 to @var{date}.  The days of the week are:
4672
4673 @table @asis
4674 @item 1
4675 Sunday
4676 @item 2
4677 Monday
4678 @item 3
4679 Tuesday
4680 @item 4
4681 Wednesday
4682 @item 5
4683 Thursday
4684 @item 6
4685 Friday
4686 @item 7
4687 Saturday
4688 @end table
4689 @end deftypefn
4690
4691 @cindex years
4692 @cindex dates, in years
4693 @deftypefn {Function} {} XDATE.YEAR (@var{date})
4694 Returns the year (as an integer between 1582 and 19999) corresponding to
4695 @var{date}.
4696 @end deftypefn
4697
4698 @node Miscellaneous Functions, Functions Not Implemented, Time & Date, Functions
4699 @subsection Miscellaneous Functions
4700 @cindex functions, miscellaneous
4701
4702 Miscellaneous functions take various arguments and produce various
4703 results.
4704
4705 @cindex cross-case function
4706 @cindex function, cross-case
4707 @deftypefn {Function} {} LAG (@var{variable})
4708 @anchor{LAG}
4709 @var{variable} must be a numeric or string variable name.  @code{LAG}
4710 results in the value of that variable for the case before the current
4711 one.  In case-selection procedures, @code{LAG} results in the value of
4712 the variable for the last case selected.  Results in system-missing (for
4713 numeric variables) or blanks (for string variables) for the first case
4714 or before any cases are selected.
4715 @end deftypefn
4716
4717 @deftypefn {Function} {} LAG (@var{variable}, @var{ncases})
4718 @var{variable} must be a numeric or string variable name.  @var{ncases}
4719 must be a small positive constant integer, although there is no explicit
4720 limit.  (Use of a large value for @var{ncases} will increase memory
4721 consumption, since PSPP must keep @var{ncases} cases in memory.)
4722 @code{LAG (@var{variable}, @var{ncases}} results in the value of
4723 @var{variable} that is @var{ncases} before the case currently being
4724 processed.  See @code{LAG (@var{variable})} above for more details.
4725 @end deftypefn
4726
4727 @cindex date, Julian
4728 @cindex Julian date
4729 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
4730 @var{year} is a year between 0 and 199 or 1582 and 19999.  @var{month} is
4731 a month between 1 and 12.  @var{day} is a day between 1 and 31.  If
4732 @var{month} or @var{day} is out-of-range, it changes the next higher
4733 unit.  For instance, a @var{day} of 0 refers to the last day of the
4734 previous month, and a @var{month} of 13 refers to the first month of the
4735 next year.  @var{year} must be in range.  If @var{year} is between 0 and
4736 199, 1900 is added.  @var{year}, @var{month}, and @var{day} must all be
4737 integers.
4738
4739 @code{YRMODA} results in the number of days between 15 Oct 1582 and
4740 the date specified, plus one.  The date passed to @code{YRMODA} must be
4741 on or after 15 Oct 1582.  15 Oct 1582 has a value of 1.
4742 @end deftypefn
4743
4744 @node Functions Not Implemented,  , Miscellaneous Functions, Functions
4745 @subsection Functions Not Implemented
4746 @cindex functions, not implemented
4747 @cindex not implemented
4748 @cindex features, not implemented
4749
4750 These functions are not yet implemented and thus not yet documented,
4751 since it's a hassle.
4752
4753 @findex CDF.xxx
4754 @findex CDFNORM
4755 @findex IDF.xxx
4756 @findex NCDF.xxx
4757 @findex PROBIT
4758 @findex RV.xxx
4759
4760 @itemize @bullet
4761 @item
4762 @code{CDF.xxx}
4763 @item
4764 @code{CDFNORM}
4765 @item
4766 @code{IDF.xxx}
4767 @item
4768 @code{NCDF.xxx}
4769 @item
4770 @code{PROBIT}
4771 @item
4772 @code{RV.xxx}
4773 @end itemize
4774
4775 @node Order of Operations,  , Functions, Expressions
4776 @section Operator Precedence
4777 @cindex operator precedence
4778 @cindex precedence, operator
4779 @cindex order of operations
4780 @cindex operations, order of
4781
4782 The following table describes operator precedence.  Smaller-numbered
4783 levels in the table have higher precedence.  Within a level, operations
4784 are performed from left to right, except for level 2 (exponentiation),
4785 where operations are performed from right to left.  If an operator
4786 appears in the table in two places (@code{-}), the first occurrence is
4787 unary, the second is binary.
4788
4789 @enumerate
4790 @item
4791 @code{(  )}
4792 @item
4793 @code{**}
4794 @item
4795 @code{-}
4796 @item
4797 @code{*  /}
4798 @item
4799 @code{+  -}
4800 @item
4801 @code{EQ  GE  GT  LE  LT  NE}
4802 @item
4803 @code{AND  NOT  OR}
4804 @end enumerate
4805
4806 @node Data Input and Output, System and Portable Files, Expressions, Top
4807 @chapter Data Input and Output
4808 @cindex input
4809 @cindex output
4810 @cindex data
4811 @cindex cases
4812 @cindex observations
4813
4814 Data are the focus of the PSPP language.  
4815 Each datum  belongs to a @dfn{case} (also called an @dfn{observation}).
4816 Each case represents an individual or `experimental unit'.
4817 For example, in the results of a survey, the names of the respondents,
4818 their sex, age @i{etc}. and their responses are all data and the data
4819 pertaining to single respondent is a case.
4820 This chapter examines
4821 the PSPP commands for defining variables and reading and writing data.
4822
4823 @quotation
4824 @strong{Please note:} Data is not actually read until a procedure is
4825 executed.  These commands tell PSPP how to read data, but they
4826 do not @emph{cause} PSPP to read data.
4827 @end quotation
4828
4829 @menu
4830 * BEGIN DATA::                  Embed data within a syntax file.
4831 * CLEAR TRANSFORMATIONS::       Clear pending transformations.
4832 * DATA LIST::                   Fundamental data reading command.
4833 * END CASE::                    Output the current case.
4834 * END FILE::                    Terminate the current input program.
4835 * FILE HANDLE::                 Support for fixed-length records.
4836 * INPUT PROGRAM::               Support for complex input programs.
4837 * LIST::                        List cases in the active file.
4838 * MATRIX DATA::                 Read matrices in text format.
4839 * NEW FILE::                    Clear the active file and dictionary.
4840 * PRINT::                       Display values in print formats.
4841 * PRINT EJECT::                 Eject the current page then print.
4842 * PRINT SPACE::                 Print blank lines.
4843 * REREAD::                      Take another look at the previous input line.
4844 * REPEATING DATA::              Multiple cases on a single line.
4845 * WRITE::                       Display values in write formats.
4846 @end menu
4847
4848 @node BEGIN DATA, CLEAR TRANSFORMATIONS, Data Input and Output, Data Input and Output
4849 @section BEGIN DATA
4850 @vindex BEGIN DATA
4851 @vindex END DATA
4852 @cindex Embedding data in syntax files
4853 @cindex Data, embedding in syntax files
4854
4855 @display
4856 BEGIN DATA.
4857 @dots{}
4858 END DATA.
4859 @end display
4860
4861 @cmd{BEGIN DATA} and @cmd{END DATA} can be used to embed raw ASCII
4862 data in a PSPP syntax file.  @cmd{DATA LIST} or another input
4863 procedure must be used before @cmd{BEGIN DATA} (@pxref{DATA LIST}).
4864 @cmd{BEGIN DATA} and @cmd{END DATA} must be used together.  @cmd{END
4865 DATA} must appear by itself on a single line, with no leading
4866 whitespace and exactly one space between the words @code{END} and
4867 @code{DATA}, followed immediately by the terminal dot, like this:
4868
4869 @example
4870 END DATA.
4871 @end example
4872
4873 @node CLEAR TRANSFORMATIONS, DATA LIST, BEGIN DATA, Data Input and Output
4874 @section CLEAR TRANSFORMATIONS
4875 @vindex CLEAR TRANSFORMATIONS
4876
4877 @display
4878 CLEAR TRANSFORMATIONS.
4879 @end display
4880
4881 @cmd{CLEAR TRANSFORMATIONS} clears out all pending
4882 transformations.  It does not cancel the current input program.  It is
4883 valid only when PSPP is interactive, not in syntax files.
4884
4885 @node DATA LIST, END CASE, CLEAR TRANSFORMATIONS, Data Input and Output
4886 @section DATA LIST
4887 @vindex DATA LIST
4888 @cindex reading data from a file
4889 @cindex data, reading from a file
4890 @cindex data, embedding in syntax files
4891 @cindex embedding data in syntax files
4892
4893 Used to read text or binary data, @cmd{DATA LIST} is the most
4894 fundamental data-reading command.  Even the more sophisticated input
4895 methods use @cmd{DATA LIST} commands as a building block.
4896 Understanding @cmd{DATA LIST} is important to understanding how to use
4897 PSPP to read your data files.
4898
4899 There are two major variants of @cmd{DATA LIST}, which are fixed
4900 format and free format.  In addition, free format has a minor variant,
4901 list format, which is discussed in terms of its differences from vanilla
4902 free format.
4903
4904 Each form of @cmd{DATA LIST} is described in detail below.
4905
4906 @menu
4907 * DATA LIST FIXED::             Fixed columnar locations for data.
4908 * DATA LIST FREE::              Any spacing you like.
4909 * DATA LIST LIST::              Each case must be on a single line.
4910 @end menu
4911
4912 @node DATA LIST FIXED, DATA LIST FREE, DATA LIST, DATA LIST
4913 @subsection DATA LIST FIXED
4914 @vindex DATA LIST FIXED
4915 @cindex reading fixed-format data
4916 @cindex fixed-format data, reading
4917 @cindex data, fixed-format, reading
4918 @cindex embedding fixed-format data
4919
4920 @display
4921 DATA LIST [FIXED]
4922         @{TABLE,NOTABLE@}
4923         FILE='filename'
4924         RECORDS=record_count
4925         END=end_var
4926         /[line_no] var_spec@dots{}
4927
4928 where each var_spec takes one of the forms
4929         var_list start-end [type_spec]
4930         var_list (fortran_spec)
4931 @end display
4932
4933 @cmd{DATA LIST FIXED} is used to read data files that have values at fixed
4934 positions on each line of single-line or multiline records.  The
4935 keyword FIXED is optional.
4936
4937 The FILE subcommand must be used if input is to be taken from an
4938 external file.  It may be used to specify a filename as a string or a
4939 file handle (@pxref{FILE HANDLE}).  If the FILE subcommand is not used,
4940 then input is assumed to be specified within the command file using
4941 @cmd{BEGIN DATA}@dots{}@cmd{END DATA} (@pxref{BEGIN DATA}).
4942
4943 The optional RECORDS subcommand, which takes a single integer as an
4944 argument, is used to specify the number of lines per record.  If RECORDS
4945 is not specified, then the number of lines per record is calculated from
4946 the list of variable specifications later in @cmd{DATA LIST}.
4947
4948 The END subcommand is only useful in conjunction with @cmd{INPUT
4949 PROGRAM}.  @xref{INPUT PROGRAM}, for details.
4950
4951 @cmd{DATA LIST} can optionally output a table describing how the data file
4952 will be read.  The TABLE subcommand enables this output, and NOTABLE
4953 disables it.  The default is to output the table.
4954
4955 The list of variables to be read from the data list must come last.
4956 Each line in the data record is introduced by a slash (@samp{/}).
4957 Optionally, a line number may follow the slash.  Following, any number
4958 of variable specifications may be present.
4959
4960 Each variable specification consists of a list of variable names
4961 followed by a description of their location on the input line.  Sets of
4962 variables may specified using the @code{DATA LIST} TO convention
4963 (@pxref{Sets of
4964 Variables}).  There are two ways to specify the location of the variable
4965 on the line: PSPP style and FORTRAN style.
4966
4967 With PSPP style, the starting column and ending column for the field
4968 are specified after the variable name, separated by a dash (@samp{-}).
4969 For instance, the third through fifth columns on a line would be
4970 specified @samp{3-5}.  By default, variables are considered to be in
4971 @samp{F} format (@pxref{Input/Output Formats}).  (This default can be
4972 changed; see @ref{SET} for more information.)
4973
4974 When using PSPP style, to use a variable format other than the default,
4975 specify the format type in parentheses after the column numbers.  For
4976 instance, for alphanumeric @samp{A} format, use @samp{(A)}.  
4977
4978 In addition, implied decimal places can be specified in parentheses
4979 after the column numbers.  As an example, suppose that a data file has a
4980 field in which the characters @samp{1234} should be interpreted as
4981 having the value 12.34.  Then this field has two implied decimal places,
4982 and the corresponding specification would be @samp{(2)}.  If a field
4983 that has implied decimal places contains a decimal point, then the
4984 implied decimal places are not applied.
4985
4986 Changing the variable format and adding implied decimal places can be
4987 done together; for instance, @samp{(N,5)}.
4988
4989 When using PSPP style, the input and output width of each variable is
4990 computed from the field width.  The field width must be evenly divisible
4991 into the number of variables specified.
4992
4993 FORTRAN style is an altogether different approach to specifying field
4994 locations.  With this approach, a list of variable input format
4995 specifications, separated by commas, are placed after the variable names
4996 inside parentheses.  Each format specifier advances as many characters
4997 into the input line as it uses.
4998
4999 In addition to the standard format specifiers (@pxref{Input/Output
5000 Formats}), FORTRAN style defines some extensions:
5001
5002 @table @asis
5003 @item @code{X}
5004 Advance the current column on this line by one character position.
5005
5006 @item @code{T}@var{x}
5007 Set the current column on this line to column @var{x}, with column
5008 numbers considered to begin with 1 at the left margin.
5009
5010 @item @code{NEWREC}@var{x}
5011 Skip forward @var{x} lines in the current record, resetting the active
5012 column to the left margin.
5013
5014 @item Repeat count
5015 Any format specifier may be preceded by a number.  This causes the
5016 action of that format specifier to be repeated the specified number of
5017 times.
5018
5019 @item (@var{spec1}, @dots{}, @var{specN})
5020 Group the given specifiers together.  This is most useful when preceded
5021 by a repeat count.  Groups may be nested arbitrarily.
5022 @end table
5023
5024 FORTRAN and PSPP styles may be freely intermixed.  PSPP style leaves the
5025 active column immediately after the ending column specified.  Record
5026 motion using @code{NEWREC} in FORTRAN style also applies to later
5027 FORTRAN and PSPP specifiers.
5028  
5029 @menu
5030 * DATA LIST FIXED Examples::    Examples of DATA LIST FIXED.
5031 @end menu
5032
5033 @node DATA LIST FIXED Examples,  , DATA LIST FIXED, DATA LIST FIXED
5034 @unnumberedsubsubsec Examples
5035
5036 @enumerate
5037 @item
5038 @example
5039 DATA LIST TABLE /NAME 1-10 (A) INFO1 TO INFO3 12-17 (1).
5040
5041 BEGIN DATA.
5042 John Smith 102311
5043 Bob Arnold 122015
5044 Bill Yates  918 6
5045 END DATA.
5046 @end example
5047
5048 Defines the following variables:
5049
5050 @itemize @bullet
5051 @item
5052 @code{NAME}, a 10-character-wide long string variable, in columns 1
5053 through 10.
5054
5055 @item
5056 @code{INFO1}, a numeric variable, in columns 12 through 13.
5057
5058 @item
5059 @code{INFO2}, a numeric variable, in columns 14 through 15.
5060
5061 @item
5062 @code{INFO3}, a numeric variable, in columns 16 through 17.
5063 @end itemize
5064
5065 The @code{BEGIN DATA}/@code{END DATA} commands cause three cases to be
5066 defined:
5067
5068 @example
5069 Case   NAME         INFO1   INFO2   INFO3
5070    1   John Smith     10      23      11
5071    2   Bob Arnold     12      20      15
5072    3   Bill Yates      9      18       6
5073 @end example
5074
5075 The @code{TABLE} keyword causes PSPP to print out a table
5076 describing the four variables defined.
5077
5078 @item
5079 @example
5080 DAT LIS FIL="survey.dat"
5081         /ID 1-5 NAME 7-36 (A) SURNAME 38-67 (A) MINITIAL 69 (A)
5082         /Q01 TO Q50 7-56
5083         /.
5084 @end example
5085
5086 Defines the following variables:
5087
5088 @itemize @bullet
5089 @item
5090 @code{ID}, a numeric variable, in columns 1-5 of the first record.
5091
5092 @item
5093 @code{NAME}, a 30-character long string variable, in columns 7-36 of the
5094 first record.
5095
5096 @item
5097 @code{SURNAME}, a 30-character long string variable, in columns 38-67 of
5098 the first record.
5099
5100 @item
5101 @code{MINITIAL}, a 1-character short string variable, in column 69 of
5102 the first record.
5103
5104 @item
5105 Fifty variables @code{Q01}, @code{Q02}, @code{Q03}, @dots{}, @code{Q49},
5106 @code{Q50}, all numeric, @code{Q01} in column 7, @code{Q02} in column 8,
5107 @dots{}, @code{Q49} in column 55, @code{Q50} in column 56, all in the second
5108 record.
5109 @end itemize
5110
5111 Cases are separated by a blank record.
5112
5113 Data is read from file @file{survey.dat} in the current directory.
5114
5115 This example shows keywords abbreviated to their first 3 letters.
5116
5117 @end enumerate
5118
5119 @node DATA LIST FREE, DATA LIST LIST, DATA LIST FIXED, DATA LIST
5120 @subsection DATA LIST FREE
5121 @vindex DATA LIST FREE
5122
5123 @display
5124 DATA LIST FREE
5125         [(@{TAB,'c'@}, @dots{})]
5126         [@{NOTABLE,TABLE@}]
5127         FILE='filename'
5128         END=end_var
5129         /var_spec@dots{}
5130
5131 where each var_spec takes one of the forms
5132         var_list [(type_spec)]
5133         var_list *
5134 @end display
5135
5136 In free format, the input data is, by default, structured as a series
5137 of fields separated by spaces, tabs, commas, or line breaks.  Each
5138 field's content may be unquoted, or it may be quoted with a pairs of
5139 apostrophes (@samp{'}) or double quotes (@samp{"}).  Unquoted white
5140 space separates fields but is not part of any field.  Any mix of
5141 spaces, tabs, and line breaks is equivalent to a single space for the
5142 purpose of separating fields, but consecutive commas will skip a
5143 field.
5144
5145 Alternatively, delimiters can be specified explicitly, as a
5146 parenthesized, comma-separated list of single-character strings
5147 immediately following FREE.  The word TAB may also be used to specify
5148 a tab character as a delimiter.  When delimiters are specified
5149 explicitly, only the given characters, plus line breaks, separate
5150 fields.  Furthermore, leading spaces at the beginnings of fields are
5151 not trimmed, consecutive delimiters define empty fields, and no form
5152 of quoting is allowed.
5153
5154 The NOTABLE and TABLE subcommands are as in @cmd{DATA LIST FIXED} above.
5155 NOTABLE is the default.
5156
5157 The FILE and END subcommands are as in @cmd{DATA LIST FIXED} above.
5158
5159 The variables to be parsed are given as a single list of variable names.
5160 This list must be introduced by a single slash (@samp{/}).  The set of
5161 variable names may contain format specifications in parentheses
5162 (@pxref{Input/Output Formats}).  Format specifications apply to all
5163 variables back to the previous parenthesized format specification.  
5164
5165 In addition, an asterisk may be used to indicate that all variables
5166 preceding it are to have input/output format @samp{F8.0}.
5167
5168 Specified field widths are ignored on input, although all normal limits
5169 on field width apply, but they are honored on output.
5170
5171 @node DATA LIST LIST,  , DATA LIST FREE, DATA LIST
5172 @subsection DATA LIST LIST
5173 @vindex DATA LIST LIST
5174
5175 @display
5176 DATA LIST LIST
5177         [(@{TAB,'c'@}, @dots{})]
5178         [@{NOTABLE,TABLE@}]
5179         FILE='filename'
5180         END=end_var
5181         /var_spec@dots{}
5182
5183 where each var_spec takes one of the forms
5184         var_list [(type_spec)]
5185         var_list *
5186 @end display
5187
5188 With one exception, @cmd{DATA LIST LIST} is syntactically and
5189 semantically equivalent to @cmd{DATA LIST FREE}.  The exception is
5190 that each input line is expected to correspond to exactly one input
5191 record.  If more or fewer fields are found on an input line than
5192 expected, an appropriate diagnostic is issued.
5193
5194 @node END CASE, END FILE, DATA LIST, Data Input and Output
5195 @section END CASE
5196 @vindex END CASE
5197
5198 @display
5199 END CASE.
5200 @end display
5201
5202 @cmd{END CASE} is used only within @cmd{INPUT PROGRAM} to output the
5203 current case.  @xref{INPUT PROGRAM}, for details.
5204
5205 @node END FILE, FILE HANDLE, END CASE, Data Input and Output
5206 @section END FILE
5207 @vindex END FILE
5208
5209 @display
5210 END FILE.
5211 @end display
5212
5213 @cmd{END FILE} is used only within @cmd{INPUT PROGRAM} to terminate
5214 the current input program.  @xref{INPUT PROGRAM}.
5215
5216 @node FILE HANDLE, INPUT PROGRAM, END FILE, Data Input and Output
5217 @section FILE HANDLE
5218 @vindex FILE HANDLE
5219
5220 @display
5221 FILE HANDLE handle_name
5222         /NAME='filename'
5223         /MODE=@{CHARACTER,IMAGE@}
5224         /LRECL=rec_len
5225         /TABWIDTH=tab_width
5226 @end display
5227
5228 Use @cmd{FILE HANDLE} to associate a file handle name with a file and
5229 its attributes, so that later commands can refer to the file by its
5230 handle name.  Because names of text files can be specified directly on
5231 commands that access files, @cmd{FILE HANDLE} is only needed when a
5232 file is not an ordinary file containing lines of text.  However,
5233 @cmd{FILE HANDLE} may be used even for text files, and it may be
5234 easier to specify a file's name once and later refer to it by an
5235 abstract handle.
5236
5237 Specify the file handle name as an identifier.  Any given identifier may
5238 only appear once in a PSPP run.  File handles may not be reassigned to a
5239 different file.  The file handle name must immediately follow the @cmd{FILE
5240 HANDLE} command name.
5241
5242 The NAME subcommand specifies the name of the file associated with the
5243 handle.  It is the only required subcommand.
5244
5245 MODE specifies a file mode.  In CHARACTER mode, the default, the data
5246 file is opened in ANSI C text mode, so that local end of line
5247 conventions are followed, and each text line is read as one record.
5248 In CHARACTER mode, most input programs will expand tabs to spaces
5249 (@cmd{DATA LIST FREE} with explicitly specified delimiters is an
5250 exception).  By default, each tab is 4 characters wide, but an
5251 alternate width may be specified on TABWIDTH.  A tab width of 0
5252 suppresses tab expansion entirely.
5253
5254 By contrast, in BINARY mode, the data file is opened in ANSI C binary
5255 mode and records are a fixed length.  In BINARY mode, LRECL specifies
5256 the record length in bytes, with a default of 1024.  Tab characters
5257 are never expanded to spaces in binary mode.
5258
5259 @node INPUT PROGRAM, LIST, FILE HANDLE, Data Input and Output
5260 @section INPUT PROGRAM
5261 @vindex INPUT PROGRAM
5262
5263 @display
5264 INPUT PROGRAM.
5265 @dots{} input commands @dots{}
5266 END INPUT PROGRAM.
5267 @end display
5268
5269 @cmd{INPUT PROGRAM}@dots{}@cmd{END INPUT PROGRAM} specifies a
5270 complex input program.  By placing data input commands within @cmd{INPUT
5271 PROGRAM}, PSPP programs can take advantage of more complex file
5272 structures than available with only @cmd{DATA LIST}.
5273
5274 The first sort of extended input program is to simply put multiple @cmd{DATA
5275 LIST} commands within the @cmd{INPUT PROGRAM}.  This will cause all of
5276 the data
5277 files to be read in parallel.  Input will stop when end of file is
5278 reached on any of the data files.
5279
5280 Transformations, such as conditional and looping constructs, can also be
5281 included within @cmd{INPUT PROGRAM}.  These can be used to combine input
5282 from several data files in more complex ways.  However, input will still
5283 stop when end of file is reached on any of the data files.
5284
5285 To prevent @cmd{INPUT PROGRAM} from terminating at the first end of
5286 file, use
5287 the END subcommand on @cmd{DATA LIST}.  This subcommand takes a
5288 variable name,
5289 which should be a numeric scratch variable (@pxref{Scratch Variables}).
5290 (It need not be a scratch variable but otherwise the results can be
5291 surprising.)  The value of this variable is set to 0 when reading the
5292 data file, or 1 when end of file is encountered.
5293
5294 Two additional commands are useful in conjunction with @cmd{INPUT PROGRAM}.
5295 @cmd{END CASE} is the first.  Normally each loop through the
5296 @cmd{INPUT PROGRAM}
5297 structure produces one case.  @cmd{END CASE} controls exactly
5298 when cases are output.  When @cmd{END CASE} is used, looping from the end of
5299 @cmd{INPUT PROGRAM} to the beginning does not cause a case to be output.
5300
5301 @cmd{END FILE} is the second.  When the END subcommand is used on @cmd{DATA
5302 LIST}, there is no way for the @cmd{INPUT PROGRAM} construct to stop
5303 looping,
5304 so an infinite loop results.  @cmd{END FILE}, when executed,
5305 stops the flow of input data and passes out of the @cmd{INPUT PROGRAM}
5306 structure.
5307
5308 All this is very confusing.  A few examples should help to clarify.
5309
5310 @example
5311 INPUT PROGRAM.
5312         DATA LIST NOTABLE FILE='a.data'/X 1-10.
5313         DATA LIST NOTABLE FILE='b.data'/Y 1-10.
5314 END INPUT PROGRAM.
5315 LIST.
5316 @end example
5317
5318 The example above reads variable X from file @file{a.data} and variable
5319 Y from file @file{b.data}.  If one file is shorter than the other then
5320 the extra data in the longer file is ignored.
5321
5322 @example
5323 INPUT PROGRAM.
5324         NUMERIC #A #B.
5325         
5326         DO IF NOT #A.
5327                 DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
5328         END IF.
5329         DO IF NOT #B.
5330                 DATA LIST NOTABLE END=#B FILE='b.data'/Y 1-10.
5331         END IF.
5332         DO IF #A AND #B.
5333                 END FILE.
5334         END IF.
5335         END CASE.
5336 END INPUT PROGRAM.
5337 LIST.
5338 @end example
5339
5340 The above example reads variable X from @file{a.data} and variable Y from
5341 @file{b.data}.  If one file is shorter than the other then the missing
5342 field is set to the system-missing value alongside the present value for
5343 the remaining length of the longer file.
5344
5345 @example
5346 INPUT PROGRAM.
5347         NUMERIC #A #B.
5348
5349         DO IF #A.
5350                 DATA LIST NOTABLE END=#B FILE='b.data'/X 1-10.
5351                 DO IF #B.
5352                         END FILE.
5353                 ELSE.
5354                         END CASE.
5355                 END IF.
5356         ELSE.
5357                 DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
5358                 DO IF NOT #A.
5359                         END CASE.
5360                 END IF.
5361         END IF.
5362 END INPUT PROGRAM.
5363 LIST.
5364 @end example
5365
5366 The above example reads data from file @file{a.data}, then from
5367 @file{b.data}, and concatenates them into a single active file.
5368
5369 @example
5370 INPUT PROGRAM.
5371         NUMERIC #EOF.
5372
5373         LOOP IF NOT #EOF.
5374                 DATA LIST NOTABLE END=#EOF FILE='a.data'/X 1-10.
5375                 DO IF NOT #EOF.
5376                         END CASE.
5377                 END IF.
5378         END LOOP.
5379
5380         COMPUTE #EOF = 0.
5381         LOOP IF NOT #EOF.
5382                 DATA LIST NOTABLE END=#EOF FILE='b.data'/X 1-10.
5383                 DO IF NOT #EOF.
5384                         END CASE.
5385                 END IF.
5386         END LOOP.
5387
5388         END FILE.
5389 END INPUT PROGRAM.
5390 LIST.
5391 @end example
5392
5393 The above example does the same thing as the previous example, in a
5394 different way.
5395
5396 @example
5397 INPUT PROGRAM.
5398         LOOP #I=1 TO 50.
5399                 COMPUTE X=UNIFORM(10).
5400                 END CASE.
5401         END LOOP.
5402         END FILE.
5403 END INPUT PROGRAM.
5404 LIST/FORMAT=NUMBERED.
5405 @end example
5406
5407 The above example causes an active file to be created consisting of 50
5408 random variates between 0 and 10.
5409
5410 @node LIST, MATRIX DATA, INPUT PROGRAM, Data Input and Output
5411 @section LIST
5412 @vindex LIST
5413
5414 @display
5415 LIST
5416         /VARIABLES=var_list
5417         /CASES=FROM start_index TO end_index BY incr_index
5418         /FORMAT=@{UNNUMBERED,NUMBERED@} @{WRAP,SINGLE@} 
5419                 @{NOWEIGHT,WEIGHT@}
5420 @end display
5421
5422 The @cmd{LIST} procedure prints the values of specified variables to the
5423 listing file.
5424
5425 The VARIABLES subcommand specifies the variables whose values are to be
5426 printed.  Keyword VARIABLES is optional.  If VARIABLES subcommand is not
5427 specified then all variables in the active file are printed.
5428
5429 The CASES subcommand can be used to specify a subset of cases to be
5430 printed.  Specify FROM and the case number of the first case to print,
5431 TO and the case number of the last case to print, and BY and the number
5432 of cases to advance between printing cases, or any subset of those
5433 settings.  If CASES is not specified then all cases are printed.
5434
5435 The FORMAT subcommand can be used to change the output format.  NUMBERED
5436 will print case numbers along with each case; UNNUMBERED, the default,
5437 causes the case numbers to be omitted.  The WRAP and SINGLE settings are
5438 currently not used.  WEIGHT will cause case weights to be printed along
5439 with variable values; NOWEIGHT, the default, causes case weights to be
5440 omitted from the output.
5441
5442 Case numbers start from 1.  They are counted after all transformations
5443 have been considered.
5444
5445 @cmd{LIST} attempts to fit all the values on a single line.  If needed
5446 to make them fit, variable names are displayed vertically.  If values
5447 cannot fit on a single line, then a multi-line format will be used.
5448
5449 @cmd{LIST} is a procedure.  It causes the data to be read.
5450
5451 @node MATRIX DATA, NEW FILE, LIST, Data Input and Output
5452 @section MATRIX DATA
5453 @vindex MATRIX DATA
5454
5455 @display
5456 MATRIX DATA
5457         /VARIABLES=var_list
5458         /FILE='filename'
5459         /FORMAT=@{LIST,FREE@} @{LOWER,UPPER,FULL@} @{DIAGONAL,NODIAGONAL@}
5460         /SPLIT=@{new_var,var_list@}
5461         /FACTORS=var_list
5462         /CELLS=n_cells
5463         /N=n
5464         /CONTENTS=@{N_VECTOR,N_SCALAR,N_MATRIX,MEAN,STDDEV,COUNT,MSE,
5465                    DFE,MAT,COV,CORR,PROX@}
5466 @end display
5467
5468 @cmd{MATRIX DATA} command reads square matrices in one of several textual
5469 formats.  @cmd{MATRIX DATA} clears the dictionary and replaces it and
5470 reads a
5471 data file.
5472
5473 Use VARIABLES to specify the variables that form the rows and columns of
5474 the matrices.  You may not specify a variable named @code{VARNAME_}.  You
5475 should specify VARIABLES first.
5476
5477 Specify the file to read on FILE, either as a file name string or a file
5478 handle (@pxref{FILE HANDLE}).  If FILE is not specified then matrix data
5479 must immediately follow @cmd{MATRIX DATA} with a @cmd{BEGIN
5480 DATA}@dots{}@cmd{END DATA}
5481 construct (@pxref{BEGIN DATA}).
5482
5483 The FORMAT subcommand specifies how the matrices are formatted.  LIST,
5484 the default, indicates that there is one line per row of matrix data;
5485 FREE allows single matrix rows to be broken across multiple lines.  This
5486 is analogous to the difference between @cmd{DATA LIST FREE} and
5487 @cmd{DATA LIST LIST}
5488 (@pxref{DATA LIST}).  LOWER, the default, indicates that the lower
5489 triangle of the matrix is given; UPPER indicates the upper triangle; and
5490 FULL indicates that the entire matrix is given.  DIAGONAL, the default,
5491 indicates that the diagonal is part of the data; NODIAGONAL indicates
5492 that it is omitted.  DIAGONAL/NODIAGONAL have no effect when FULL is
5493 specified.
5494
5495 The SPLIT subcommand is used to specify @cmd{SPLIT FILE} variables for the
5496 input matrices (@pxref{SPLIT FILE}).  Specify either a single variable
5497 not specified on VARIABLES, or one or more variables that are specified
5498 on VARIABLES.  In the former case, the SPLIT values are not present in
5499 the data and ROWTYPE_ may not be specified on VARIABLES.  In the latter
5500 case, the SPLIT values are present in the data.
5501
5502 Specify a list of factor variables on FACTORS.  Factor variables must
5503 also be listed on VARIABLES.  Factor variables are used when there are
5504 some variables where, for each possible combination of their values,
5505 statistics on the matrix variables are included in the data.
5506
5507 If FACTORS is specified and ROWTYPE_ is not specified on VARIABLES, the
5508 CELLS subcommand is required.  Specify the number of factor variable
5509 combinations that are given.  For instance, if factor variable A has 2
5510 values and factor variable B has 3 values, specify 6.
5511
5512 The N subcommand specifies a population number of observations.  When N
5513 is specified, one N record is output for each @cmd{SPLIT FILE}.
5514
5515 Use CONTENTS to specify what sort of information the matrices include.
5516 Each possible option is described in more detail below.  When ROWTYPE_
5517 is specified on VARIABLES, CONTENTS is optional; otherwise, if CONTENTS
5518 is not specified then /CONTENTS=CORR is assumed.
5519
5520 @table @asis
5521 @item N
5522 @item N_VECTOR
5523 Number of observations as a vector, one value for each variable.
5524 @item N_SCALAR
5525 Number of observations as a single value.
5526 @item N_MATRIX
5527 Matrix of counts.
5528 @item MEAN
5529 Vector of means.
5530 @item STDDEV
5531 Vector of standard deviations.
5532 @item COUNT
5533 Vector of counts.
5534 @item MSE
5535 Vector of mean squared errors.
5536 @item DFE
5537 Vector of degrees of freedom.
5538 @item MAT
5539 Generic matrix.
5540 @item COV
5541 Covariance matrix.
5542 @item CORR
5543 Correlation matrix.
5544 @item PROX
5545 Proximities matrix.
5546 @end table
5547
5548 The exact semantics of the matrices read by @cmd{MATRIX DATA} are complex.
5549 Right now @cmd{MATRIX DATA} isn't too useful due to a lack of procedures
5550 accepting or producing related data, so these semantics aren't
5551 documented.  Later, they'll be described here in detail.
5552
5553 @node NEW FILE, PRINT, MATRIX DATA, Data Input and Output
5554 @section NEW FILE
5555 @vindex NEW FILE
5556
5557 @display
5558 NEW FILE.
5559 @end display
5560
5561 @cmd{NEW FILE} command clears the current active file.
5562
5563 @node PRINT, PRINT EJECT, NEW FILE, Data Input and Output
5564 @section PRINT
5565 @vindex PRINT
5566
5567 @display
5568 PRINT 
5569         OUTFILE='filename'
5570         RECORDS=n_lines
5571         @{NOTABLE,TABLE@}
5572         /[line_no] arg@dots{}
5573
5574 arg takes one of the following forms:
5575         'string' [start-end]
5576         var_list start-end [type_spec]
5577         var_list (fortran_spec)
5578         var_list *
5579 @end display
5580
5581 The @cmd{PRINT} transformation writes variable data to an output file.
5582 @cmd{PRINT} is executed when a procedure causes the data to be read.
5583 Follow @cmd{PRINT} by @cmd{EXECUTE} to print variable data without
5584 invoking a procedure (@pxref{EXECUTE}).
5585
5586 All @cmd{PRINT} subcommands are optional.
5587
5588 The OUTFILE subcommand specifies the file to receive the output.  The
5589 file may be a file name as a string or a file handle (@pxref{FILE
5590 HANDLE}).  If OUTFILE is not present then output will be sent to PSPP's
5591 output listing file.
5592
5593 The RECORDS subcommand specifies the number of lines to be output.  The
5594 number of lines may optionally be surrounded by parentheses.
5595
5596 TABLE will cause the PRINT command to output a table to the listing file
5597 that describes what it will print to the output file.  NOTABLE, the
5598 default, suppresses this output table.
5599
5600 Introduce the strings and variables to be printed with a slash
5601 (@samp{/}).  Optionally, the slash may be followed by a number
5602 indicating which output line will be specified.  In the absence of this
5603 line number, the next line number will be specified.  Multiple lines may
5604 be specified using multiple slashes with the intended output for a line
5605 following its respective slash.
5606
5607 Literal strings may be printed.  Specify the string itself.  Optionally
5608 the string may be followed by a column number or range of column
5609 numbers, specifying the location on the line for the string to be
5610 printed.  Otherwise, the string will be printed at the current position
5611 on the line.
5612
5613 Variables to be printed can be specified in the same ways as available
5614 for @cmd{DATA LIST FIXED} (@pxref{DATA LIST FIXED}).  In addition, a
5615 variable
5616 list may be followed by an asterisk (@samp{*}), which indicates that the
5617 variables should be printed in their dictionary print formats, separated
5618 by spaces.  A variable list followed by a slash or the end of command
5619 will be interpreted the same way.
5620
5621 If a FORTRAN type specification is used to move backwards on the current
5622 line, then text is written at that point on the line, the line will be
5623 truncated to that length, although additional text being added will
5624 again extend the line to that length.
5625
5626 @node PRINT EJECT, PRINT SPACE, PRINT, Data Input and Output
5627 @section PRINT EJECT
5628 @vindex PRINT EJECT
5629
5630 @display
5631 PRINT EJECT 
5632         OUTFILE='filename'
5633         RECORDS=n_lines
5634         @{NOTABLE,TABLE@}
5635         /[line_no] arg@dots{}
5636
5637 arg takes one of the following forms:
5638         'string' [start-end]
5639         var_list start-end [type_spec]
5640         var_list (fortran_spec)
5641         var_list *
5642 @end display
5643
5644 @cmd{PRINT EJECT} writes data to an output file.  Before the data is
5645 written, the current page in the listing file is ejected.
5646
5647 @xref{PRINT}, for more information on syntax and usage.
5648
5649 @node PRINT SPACE, REREAD, PRINT EJECT, Data Input and Output
5650 @section PRINT SPACE
5651 @vindex PRINT SPACE
5652
5653 @display
5654 PRINT SPACE OUTFILE='filename' n_lines.
5655 @end display
5656
5657 @cmd{PRINT SPACE} prints one or more blank lines to an output file.
5658
5659 The OUTFILE subcommand is optional.  It may be used to direct output to
5660 a file specified by file name as a string or file handle (@pxref{FILE
5661 HANDLE}).  If OUTFILE is not specified then output will be directed to
5662 the listing file.
5663
5664 n_lines is also optional.  If present, it is an expression
5665 (@pxref{Expressions}) specifying the number of blank lines to be
5666 printed.  The expression must evaluate to a nonnegative value.
5667
5668 @node REREAD, REPEATING DATA, PRINT SPACE, Data Input and Output
5669 @section REREAD
5670 @vindex REREAD
5671
5672 @display
5673 REREAD FILE=handle COLUMN=column.
5674 @end display
5675
5676 The @cmd{REREAD} transformation allows the previous input line in a
5677 data file
5678 already processed by @cmd{DATA LIST} or another input command to be re-read
5679 for further processing.
5680
5681 The FILE subcommand, which is optional, is used to specify the file to
5682 have its line re-read.  The file must be specified in the form of a file
5683 handle (@pxref{FILE HANDLE}).  If FILE is not specified then the last
5684 file specified on @cmd{DATA LIST} will be assumed (last file specified
5685 lexically, not in terms of flow-of-control).
5686
5687 By default, the line re-read is re-read in its entirety.  With the
5688 COLUMN subcommand, a prefix of the line can be exempted from
5689 re-reading.  Specify an expression (@pxref{Expressions}) evaluating to
5690 the first column that should be included in the re-read line.  Columns
5691 are numbered from 1 at the left margin.
5692
5693 Issuing @code{REREAD} multiple times will not back up in the data
5694 file.  Instead, it will re-read the same line multiple times.
5695
5696 @node REPEATING DATA, WRITE, REREAD, Data Input and Output
5697 @section REPEATING DATA
5698 @vindex REPEATING DATA
5699
5700 @display
5701 REPEATING DATA
5702         /STARTS=start-end
5703         /OCCURS=n_occurs
5704         /FILE='filename'
5705         /LENGTH=length
5706         /CONTINUED[=cont_start-cont_end]
5707         /ID=id_start-id_end=id_var
5708         /@{TABLE,NOTABLE@}
5709         /DATA=var_spec@dots{}
5710
5711 where each var_spec takes one of the forms
5712         var_list start-end [type_spec]
5713         var_list (fortran_spec)
5714 @end display
5715
5716 @cmd{REPEATING DATA} parses groups of data repeating in
5717 a uniform format, possibly with several groups on a single line.  Each
5718 group of data corresponds with one case.  @cmd{REPEATING DATA} may only be
5719 used within an @cmd{INPUT PROGRAM} structure (@pxref{INPUT PROGRAM}).
5720 When used with @cmd{DATA LIST}, it
5721 can be used to parse groups of cases that share a subset of variables
5722 but differ in their other data.
5723
5724 The STARTS subcommand is required.  Specify a range of columns, using
5725 literal numbers or numeric variable names.  This range specifies the
5726 columns on the first line that are used to contain groups of data.  The
5727 ending column is optional.  If it is not specified, then the record
5728 width of the input file is used.  For the inline file (@pxref{BEGIN
5729 DATA}) this is 80 columns; for a file with fixed record widths it is the
5730 record width; for other files it is 1024 characters by default.
5731
5732 The OCCURS subcommand is required.  It must be a number or the name of a
5733 numeric variable.  Its value is the number of groups present in the
5734 current record.
5735
5736 The DATA subcommand is required.  It must be the last subcommand
5737 specified.  It is used to specify the data present within each repeating
5738 group.  Column numbers are specified relative to the beginning of a
5739 group at column 1.  Data is specified in the same way as with @cmd{DATA LIST
5740 FIXED} (@pxref{DATA LIST FIXED}).
5741
5742 All other subcommands are optional.
5743
5744 FILE specifies the file to read, either a file name as a string or a
5745 file handle (@pxref{FILE HANDLE}).  If FILE is not present then the
5746 default is the last file handle used on @cmd{DATA LIST} (lexically, not in
5747 terms of flow of control).
5748
5749 By default @cmd{REPEATING DATA} will output a table describing how it will
5750 parse the input data.  Specifying NOTABLE will disable this behavior;
5751 specifying TABLE will explicitly enable it.
5752
5753 The LENGTH subcommand specifies the length in characters of each group.
5754 If it is not present then length is inferred from the DATA subcommand.
5755 LENGTH can be a number or a variable name.
5756
5757 Normally all the data groups are expected to be present on a single
5758 line.  Use the CONTINUED command to indicate that data can be continued
5759 onto additional lines.  If data on continuation lines starts at the left
5760 margin and continues through the entire field width, no column
5761 specifications are necessary on CONTINUED.  Otherwise, specify the
5762 possible range of columns in the same way as on STARTS.
5763
5764 When data groups are continued from line to line, it is easy
5765 for cases to get out of sync through careless hand editing.  The
5766 ID subcommand allows a case identifier to be present on each line of
5767 repeating data groups.  @cmd{REPEATING DATA} will check for the same
5768 identifier on each line and report mismatches.  Specify the range of
5769 columns that the identifier will occupy, followed by an equals sign
5770 (@samp{=}) and the identifier variable name.  The variable must already
5771 have been declared with @cmd{NUMERIC} or another command.
5772
5773 @cmd{REPEATING DATA} should be the last command given within an
5774 @cmd{INPUT PROGRAM}.  It should not be enclosed within a @cmd{LOOP}
5775 structure (@pxref{LOOP}).  Use @cmd{DATA LIST} before, not after,
5776 @cmd{REPEATING DATA}.
5777
5778 @node WRITE,  , REPEATING DATA, Data Input and Output
5779 @section WRITE
5780 @vindex WRITE
5781
5782 @display
5783 WRITE 
5784         OUTFILE='filename'
5785         RECORDS=n_lines
5786         @{NOTABLE,TABLE@}
5787         /[line_no] arg@dots{}
5788
5789 arg takes one of the following forms:
5790         'string' [start-end]
5791         var_list start-end [type_spec]
5792         var_list (fortran_spec)
5793         var_list *
5794 @end display
5795
5796 @code{WRITE} writes text or binary data to an output file.  
5797
5798 @xref{PRINT}, for more information on syntax and usage.  The main
5799 difference between @code{PRINT} and @code{WRITE} is that @cmd{WRITE}
5800 uses write formats by default, where PRINT uses print formats.
5801
5802 The sole additional difference is that if @cmd{WRITE} is used to send output
5803 to a binary file, carriage control characters will not be output.
5804 @xref{FILE HANDLE}, for information on how to declare a file as binary.
5805
5806 @node System and Portable Files, Variable Attributes, Data Input and Output, Top
5807 @chapter System Files and Portable Files
5808
5809 The commands in this chapter read, write, and examine system files and
5810 portable files.
5811
5812 @menu
5813 * APPLY DICTIONARY::            Apply system file dictionary to active file.
5814 * EXPORT::                      Write to a portable file.
5815 * GET::                         Read from a system file.
5816 * IMPORT::                      Read from a portable file.
5817 * MATCH FILES::                 Merge system files.
5818 * SAVE::                        Write to a system file.
5819 * SYSFILE INFO::                Display system file dictionary.
5820 * XSAVE::                       Write to a system file, as a transform.
5821 @end menu
5822
5823 @node APPLY DICTIONARY, EXPORT, System and Portable Files, System and Portable Files
5824 @section APPLY DICTIONARY
5825 @vindex APPLY DICTIONARY
5826
5827 @display
5828 APPLY DICTIONARY FROM='filename'.
5829 @end display
5830
5831 @cmd{APPLY DICTIONARY} applies the variable labels, value labels,
5832 and missing values from variables in a system file to corresponding
5833 variables in the active file.  In some cases it also updates the
5834 weighting variable.
5835
5836 Specify a system file with a file name string or as a file handle
5837 (@pxref{FILE HANDLE}).  The dictionary in the system file will be read,
5838 but it will not replace the active file dictionary.  The system file's
5839 data will not be read.
5840
5841 Only variables with names that exist in both the active file and the
5842 system file are considered.  Variables with the same name but different
5843 types (numeric, string) will cause an error message.  Otherwise, the
5844 system file variables' attributes will replace those in their matching
5845 active file variables, as described below.
5846
5847 If a system file variable has a variable label, then it will replace the
5848 active file variable's variable label.  If the system file variable does
5849 not have a variable label, then the active file variable's variable
5850 label, if any, will be retained.
5851
5852 If the active file variable is numeric or short string, then value
5853 labels and missing values, if any, will be copied to the active file
5854 variable.  If the system file variable does not have value labels or
5855 missing values, then those in the active file variable, if any, will not
5856 be disturbed.
5857
5858 Finally, weighting of the active file is updated (@pxref{WEIGHT}).  If
5859 the active file has a weighting variable, and the system file does not,
5860 or if the weighting variable in the system file does not exist in the
5861 active file, then the active file weighting variable, if any, is
5862 retained.  Otherwise, the weighting variable in the system file becomes
5863 the active file weighting variable.
5864
5865 @cmd{APPLY DICTIONARY} takes effect immediately.  It does not read the
5866 active
5867 file.  The system file is not modified.
5868
5869 @node EXPORT, GET, APPLY DICTIONARY, System and Portable Files
5870 @section EXPORT
5871 @vindex EXPORT
5872
5873 @display
5874 EXPORT
5875         /OUTFILE='filename'
5876         /DROP=var_list
5877         /KEEP=var_list
5878         /RENAME=(src_names=target_names)@dots{}
5879 @end display
5880
5881 The @cmd{EXPORT} procedure writes the active file dictionary and data to a
5882 specified portable file.
5883
5884 The OUTFILE subcommand, which is the only required subcommand, specifies
5885 the portable file to be written as a file name string or a file handle
5886 (@pxref{FILE HANDLE}).
5887
5888 DROP, KEEP, and RENAME follow the same format as the SAVE procedure
5889 (@pxref{SAVE}).
5890
5891 @cmd{EXPORT} is a procedure.  It causes the active file to be read.
5892
5893 @node GET, IMPORT, EXPORT, System and Portable Files
5894 @section GET
5895 @vindex GET
5896
5897 @display
5898 GET
5899         /FILE='filename'
5900         /DROP=var_list
5901         /KEEP=var_list
5902         /RENAME=(src_names=target_names)@dots{}
5903 @end display
5904
5905 @cmd{GET} clears the current dictionary and active file and
5906 replaces them with the dictionary and data from a specified system file.
5907
5908 The FILE subcommand is the only required subcommand.  Specify the system
5909 file to be read as a string file name or a file handle (@pxref{FILE
5910 HANDLE}).
5911
5912 By default, all the variables in a system file are read.  The DROP
5913 subcommand can be used to specify a list of variables that are not to be
5914 read.  By contrast, the KEEP subcommand can be used to specify variable
5915 that are to be read, with all other variables not read.
5916
5917 Normally variables in a system file retain the names that they were
5918 saved under.  Use the RENAME subcommand to change these names.  Specify,
5919 within parentheses, a list of variable names followed by an equals sign
5920 (@samp{=}) and the names that they should be renamed to.  Multiple
5921 parenthesized groups of variable names can be included on a single
5922 RENAME subcommand.  Variables' names may be swapped using a RENAME
5923 subcommand of the form @samp{/RENAME=(A B=B A)}.
5924
5925 Alternate syntax for the RENAME subcommand allows the parentheses to be
5926 eliminated.  When this is done, only a single variable may be renamed at
5927 once.  For instance, @samp{/RENAME=A=B}.  This alternate syntax is
5928 deprecated.
5929
5930 DROP, KEEP, and RENAME are performed in left-to-right order.  They
5931 each may be present any number of times.  @cmd{GET} never modifies a
5932 system file on disk.  Only the active file read from the system file
5933 is affected by these subcommands.
5934
5935 @cmd{GET} does not cause the data to be read, only the dictionary.  The data
5936 is read later, when a procedure is executed.
5937
5938 @node IMPORT, MATCH FILES, GET, System and Portable Files
5939 @section IMPORT
5940 @vindex IMPORT
5941
5942 @display
5943 IMPORT
5944         /FILE='filename'
5945         /TYPE=@{COMM,TAPE@}
5946         /DROP=var_list
5947         /KEEP=var_list
5948         /RENAME=(src_names=target_names)@dots{}
5949 @end display
5950
5951 The @cmd{IMPORT} transformation clears the active file dictionary and
5952 data and
5953 replaces them with a dictionary and data from a portable file on disk.
5954
5955 The FILE subcommand, which is the only required subcommand, specifies
5956 the portable file to be read as a file name string or a file handle
5957 (@pxref{FILE HANDLE}).
5958
5959 The TYPE subcommand is currently not used.
5960
5961 DROP, KEEP, and RENAME follow the syntax used by @cmd{GET} (@pxref{GET}).
5962
5963 @cmd{IMPORT} does not cause the data to be read, only the dictionary.  The
5964 data is read later, when a procedure is executed.
5965
5966 @node MATCH FILES, SAVE, IMPORT, System and Portable Files
5967 @section MATCH FILES
5968 @vindex MATCH FILES
5969
5970 @display
5971 MATCH FILES
5972         /BY var_list
5973         /@{FILE,TABLE@}=@{*,'filename'@}
5974         /DROP=var_list
5975         /KEEP=var_list
5976         /RENAME=(src_names=target_names)@dots{}
5977         /IN=var_name
5978         /FIRST=var_name
5979         /LAST=var_name
5980         /MAP
5981 @end display
5982
5983 @cmd{MATCH FILES} merges one or more system files, optionally
5984 including the active file.  Records with the same values for BY
5985 variables are combined into a single record.  Records with different
5986 values are output in order.  Thus, multiple sorted system files are
5987 combined into a single sorted system file based on the value of the BY
5988 variables.  The results of the merge become the new active file.
5989
5990 The BY subcommand specifies a list of variables that are used to match
5991 records from each of the system files.  Variables specified must exist
5992 in all the files specified on FILE and TABLE.  BY should usually be
5993 specified.  If TABLE is used then BY is required.
5994
5995 Specify FILE with a system file as a file name string or file handle
5996 (@pxref{FILE HANDLE}), or with an asterisk (@samp{*}) to
5997 indicate the current active file.  The files specified on FILE are
5998 merged together based on the BY variables, or combined case-by-case if
5999 BY is not specified.  Normally at least two FILE subcommands should be
6000 specified.
6001
6002 Specify TABLE with a system file to use it as a @dfn{table
6003 lookup file}.  Records in table lookup files are not used up after
6004 they've been used once.  This means that data in table lookup files can
6005 correspond to any number of records in FILE files.  Table lookup files
6006 correspond to lookup tables in traditional relational database systems.
6007 It is incorrect to have records with duplicate BY values in table lookup
6008 files.
6009
6010 Any number of FILE and TABLE subcommands may be specified.  Each
6011 instance of FILE or TABLE can be followed by DROP, KEEP, and/or RENAME
6012 subcommands.  These take the same form as the corresponding subcommands
6013 of @cmd{GET} (@pxref{GET}), and perform the same functions.
6014
6015 Variables belonging to files that are not present for the current case
6016 are set to the system-missing value for numeric variables or spaces for
6017 string variables.
6018
6019 IN, FIRST, LAST, and MAP are currently not used.
6020
6021 @cmd{MATCH FILES} may not be specified following @cmd{TEMPORARY}
6022 (@pxref{TEMPORARY}) if the active file is used as an input source.
6023
6024 @node SAVE, SYSFILE INFO, MATCH FILES, System and Portable Files
6025 @section SAVE
6026 @vindex SAVE
6027
6028 @display
6029 SAVE
6030         /OUTFILE='filename'
6031         /@{COMPRESSED,UNCOMPRESSED@}
6032         /DROP=var_list
6033         /KEEP=var_list
6034         /RENAME=(src_names=target_names)@dots{}
6035 @end display
6036
6037 The @cmd{SAVE} procedure causes the dictionary and data in the active
6038 file to
6039 be written to a system file.
6040
6041 FILE is the only required subcommand.  Specify the system
6042 file to be written as a string file name or a file handle (@pxref{FILE
6043 HANDLE}).
6044
6045 The COMPRESS and UNCOMPRESS subcommand determine whether the saved
6046 system file is compressed.  By default, system files are compressed.
6047 This default can be changed with the SET command (@pxref{SET}).
6048
6049 By default, all the variables in the active file dictionary are written
6050 to the system file.  The DROP subcommand can be used to specify a list
6051 of variables not to be written.  In contrast, KEEP specifies variables
6052 to be written, with all variables not specified not written.
6053
6054 Normally variables are saved to a system file under the same names they
6055 have in the active file.  Use the RENAME subcommand to change these names.
6056 Specify, within parentheses, a list of variable names followed by an
6057 equals sign (@samp{=}) and the names that they should be renamed to.
6058 Multiple parenthesized groups of variable names can be included on a
6059 single RENAME subcommand.  Variables' names may be swapped using a
6060 RENAME subcommand of the form @samp{/RENAME=(A B=B A)}.
6061
6062 Alternate syntax for the RENAME subcommand allows the parentheses to be
6063 eliminated.  When this is done, only a single variable may be renamed at
6064 once.  For instance, @samp{/RENAME=A=B}.  This alternate syntax is
6065 deprecated.
6066
6067 DROP, KEEP, and RENAME are performed in left-to-right order.  They
6068 each may be present any number of times.  @cmd{SAVE} never modifies
6069 the active file.  DROP, KEEP, and RENAME only affect the system file
6070 written to disk.
6071
6072 @cmd{SAVE} causes the data to be read.  It is a procedure.
6073
6074 @node SYSFILE INFO, XSAVE, SAVE, System and Portable Files
6075 @section SYSFILE INFO
6076 @vindex SYSFILE INFO
6077
6078 @display 
6079 SYSFILE INFO FILE='filename'.
6080 @end display
6081
6082 @cmd{SYSFILE INFO} reads the dictionary in a system file and
6083 displays the information in its dictionary.
6084
6085 Specify a file name or file handle.  @cmd{SYSFILE INFO} reads that file as
6086 a system file and displays information on its dictionary.
6087
6088 @cmd{SYSFILE INFO} does not affect the current active file.
6089
6090 @node XSAVE,  , SYSFILE INFO, System and Portable Files
6091 @section XSAVE
6092 @vindex XSAVE
6093
6094 @display
6095 XSAVE
6096         /FILE='filename'
6097         /@{COMPRESSED,UNCOMPRESSED@}
6098         /DROP=var_list
6099         /KEEP=var_list
6100         /RENAME=(src_names=target_names)@dots{}
6101 @end display
6102
6103 The @cmd{XSAVE} transformation writes the active file dictionary and
6104 data to a
6105 system file stored on disk.
6106
6107 @cmd{XSAVE} is a transformation, not a procedure.  It is executed when the
6108 data is read by a procedure or procedure-like command.  In all other
6109 respects, @cmd{XSAVE} is identical to @cmd{SAVE}.  @xref{SAVE}, for
6110 more information
6111 on syntax and usage.
6112
6113 @node Variable Attributes, Data Manipulation, System and Portable Files, Top
6114 @chapter Manipulating variables
6115
6116 The variables in the active file dictionary are important.  There are
6117 several utility functions for examining and adjusting them.
6118
6119 @menu
6120 * ADD VALUE LABELS::            Add value labels to variables.
6121 * DISPLAY::                     Display variable names & descriptions.
6122 * DISPLAY VECTORS::             Display a list of vectors.
6123 * FORMATS::                     Set print and write formats.
6124 * LEAVE::                       Don't clear variables between cases.
6125 * MISSING VALUES::              Set missing values for variables.
6126 * MODIFY VARS::                 Rename, reorder, and drop variables.
6127 * NUMERIC::                     Create new numeric variables.
6128 * PRINT FORMATS::               Set variable print formats.
6129 * RENAME VARIABLES::            Rename variables.
6130 * VALUE LABELS::                Set value labels for variables.
6131 * STRING::                      Create new string variables.
6132 * VARIABLE LABELS::             Set variable labels for variables.
6133 * VECTOR::                      Declare an array of variables.
6134 * WRITE FORMATS::               Set variable write formats.
6135 @end menu
6136
6137 @node ADD VALUE LABELS, DISPLAY, Variable Attributes, Variable Attributes
6138 @section ADD VALUE LABELS
6139 @vindex ADD VALUE LABELS
6140
6141 @display 
6142 ADD VALUE LABELS
6143         /var_list value 'label' [value 'label']@dots{}
6144 @end display
6145
6146 @cmd{ADD VALUE LABELS} has the same syntax and purpose as @cmd{VALUE
6147 LABELS} (@pxref{VALUE LABELS}), but it does not clear value
6148 labels from the variables before adding the ones specified.
6149
6150 @node DISPLAY, DISPLAY VECTORS, ADD VALUE LABELS, Variable Attributes
6151 @section DISPLAY
6152 @vindex DISPLAY
6153
6154 @display
6155 DISPLAY @{NAMES,INDEX,LABELS,VARIABLES,DICTIONARY,SCRATCH@}
6156         [SORTED] [var_list]
6157 @end display
6158
6159 @cmd{DISPLAY} displays requested information on variables.  Variables can
6160 optionally be sorted alphabetically.  The entire dictionary or just
6161 specified variables can be described.
6162
6163 One of the following keywords can be present:
6164
6165 @table @asis
6166 @item NAMES
6167 The variables' names are displayed.
6168
6169 @item INDEX
6170 The variables' names are displayed along with a value describing their
6171 position within the active file dictionary.
6172
6173 @item LABELS
6174 Variable names, positions, and variable labels are displayed.
6175
6176 @item VARIABLES
6177 Variable names, positions, print and write formats, and missing values
6178 are displayed.
6179
6180 @item DICTIONARY
6181 Variable names, positions, print and write formats, missing values,
6182 variable labels, and value labels are displayed.
6183
6184 @item SCRATCH
6185 Varible names are displayed, for scratch variables only (@pxref{Scratch
6186 Variables}).
6187 @end table
6188
6189 If SORTED is specified, then the variables are displayed in ascending
6190 order based on their names; otherwise, they are displayed in the order
6191 that they occur in the active file dictionary.
6192
6193 @node DISPLAY VECTORS, FORMATS, DISPLAY, Variable Attributes
6194 @section DISPLAY VECTORS
6195 @vindex DISPLAY VECTORS
6196
6197 @display
6198 DISPLAY VECTORS.
6199 @end display
6200
6201 @cmd{DISPLAY VECTORS} lists all the currently declared vectors.
6202
6203 @node FORMATS, LEAVE, DISPLAY VECTORS, Variable Attributes
6204 @section FORMATS
6205 @vindex FORMATS
6206
6207 @display
6208 FORMATS var_list (fmt_spec).
6209 @end display
6210
6211 @cmd{FORMATS} set both print and write formats for the specified
6212 variables to the specified format specification.  @xref{Input/Output
6213 Formats}.
6214
6215 Specify a list of variables followed by a format specification in
6216 parentheses.  The print and write formats of the specified variables
6217 will be changed.
6218
6219 Additional lists of variables and formats may be included if they are
6220 delimited by a slash (@samp{/}).
6221
6222 @cmd{FORMATS} takes effect immediately.  It is not affected by
6223 conditional and looping structures such as @cmd{DO IF} or @cmd{LOOP}.
6224
6225 @node LEAVE, MISSING VALUES, FORMATS, Variable Attributes
6226 @section LEAVE
6227 @vindex LEAVE
6228
6229 @display
6230 LEAVE var_list.
6231 @end display
6232
6233 @cmd{LEAVE} prevents the specified variables from being
6234 reinitialized whenever a new case is processed.
6235
6236 Normally, when a data file is processed, every variable in the active
6237 file is initialized to the system-missing value or spaces at the
6238 beginning of processing for each case.  When a variable has been
6239 specified on @cmd{LEAVE}, this is not the case.  Instead, that variable is
6240 initialized to 0 (not system-missing) or spaces for the first case.
6241 After that, it retains its value between cases.
6242
6243 This becomes useful for counters.  For instance, in the example below
6244 the variable SUM maintains a running total of the values in the ITEM
6245 variable.
6246
6247 @example
6248 DATA LIST /ITEM 1-3.
6249 COMPUTE SUM=SUM+ITEM.
6250 PRINT /ITEM SUM.
6251 LEAVE SUM
6252 BEGIN DATA.
6253 123
6254 404
6255 555
6256 999
6257 END DATA.
6258 @end example
6259
6260 @noindent Partial output from this example:
6261
6262 @example
6263 123   123.00
6264 404   527.00
6265 555  1082.00
6266 999  2081.00
6267 @end example
6268
6269 It is best to use @cmd{LEAVE} command immediately before invoking a
6270 procedure command, because the left status of variables is reset by
6271 certain transformations---for instance, @cmd{COMPUTE} and @cmd{IF}.
6272 Left status is also reset by all procedure invocations.
6273
6274 @node MISSING VALUES, MODIFY VARS, LEAVE, Variable Attributes
6275 @section MISSING VALUES
6276 @vindex MISSING VALUES
6277
6278 @display
6279 MISSING VALUES var_list (missing_values).
6280
6281 missing_values takes one of the following forms:
6282         num1
6283         num1, num2
6284         num1, num2, num3
6285         num1 THRU num2
6286         num1 THRU num2, num3
6287         string1
6288         string1, string2
6289         string1, string2, string3
6290 As part of a range, LO or LOWEST may take the place of num1;
6291 HI or HIGHEST may take the place of num2.
6292 @end display
6293
6294 @cmd{MISSING VALUES} sets user-missing values for numeric and
6295 short string variables.  Long string variables may not have missing
6296 values.
6297
6298 Specify a list of variables, followed by a list of their user-missing
6299 values in parentheses.  Up to three discrete values may be given, or,
6300 for numeric variables only, a range of values optionally accompanied by
6301 a single discrete value.  Ranges may be open-ended on one end, indicated
6302 through the use of the keyword LO or LOWEST or HI or HIGHEST.
6303
6304 The @cmd{MISSING VALUES} command takes effect immediately.  It is not
6305 affected by conditional and looping constructs such as @cmd{DO IF} or
6306 @cmd{LOOP}.
6307
6308 @node MODIFY VARS, NUMERIC, MISSING VALUES, Variable Attributes
6309 @section MODIFY VARS
6310 @vindex MODIFY VARS
6311
6312 @display 
6313 MODIFY VARS
6314         /REORDER=@{FORWARD,BACKWARD@} @{POSITIONAL,ALPHA@} (var_list)@dots{}
6315         /RENAME=(old_names=new_names)@dots{}
6316         /@{DROP,KEEP@}=var_list
6317         /MAP    
6318 @end display
6319
6320 @cmd{MODIFY VARS} reorders, renames, and deletes variables in the
6321 active file.
6322
6323 At least one subcommand must be specified, and no subcommand may be
6324 specified more than once.  DROP and KEEP may not both be specified.
6325
6326 The REORDER subcommand changes the order of variables in the active
6327 file.  Specify one or more lists of variable names in parentheses.  By
6328 default, each list of variables is rearranged into the specified order.
6329 To put the variables into the reverse of the specified order, put
6330 keyword BACKWARD before the parentheses.  To put them into alphabetical
6331 order in the dictionary, specify keyword ALPHA before the parentheses.
6332 BACKWARD and ALPHA may also be combined.
6333
6334 To rename variables in the active file, specify RENAME, an equals sign
6335 (@samp{=}), and lists of the old variable names and new variable names
6336 separated by another equals sign within parentheses.  There must be the
6337 same number of old and new variable names.  Each old variable is renamed to
6338 the corresponding new variable name.  Multiple parenthesized groups of
6339 variables may be specified.
6340
6341 The DROP subcommand deletes a specified list of variables from the
6342 active file.
6343
6344 The KEEP subcommand keeps the specified list of variables in the active
6345 file.  Any unlisted variables are deleted from the active file.
6346
6347 MAP is currently ignored.
6348
6349 If either DROP or KEEP is specified, the data is read; otherwise it is
6350 not.
6351
6352 @cmd{MODIFY VARS} may not be specified following @cmd{TEMPORARY}
6353 (@pxref{TEMPORARY}).
6354
6355 @node NUMERIC, PRINT FORMATS, MODIFY VARS, Variable Attributes
6356 @section NUMERIC
6357 @vindex NUMERIC
6358
6359 @display
6360 NUMERIC /var_list [(fmt_spec)].
6361 @end display
6362
6363 @cmd{NUMERIC} explicitly declares new numeric variables, optionally
6364 setting their output formats.
6365
6366 Specify a slash (@samp{/}), followed by the names of the new numeric
6367 variables.  If you wish to set their output formats, follow their names
6368 by an output format specification in parentheses (@pxref{Input/Output
6369 Formats}); otherwise, the default is F8.2.
6370
6371 Variables created with @cmd{NUMERIC} are initialized to the
6372 system-missing value.
6373
6374 @node PRINT FORMATS, RENAME VARIABLES, NUMERIC, Variable Attributes
6375 @section PRINT FORMATS
6376 @vindex PRINT FORMATS
6377
6378 @display
6379 PRINT FORMATS var_list (fmt_spec).
6380 @end display
6381
6382 @cmd{PRINT FORMATS} sets the print formats for the specified
6383 variables to the specified format specification.
6384
6385 Its syntax is identical to that of @cmd{FORMATS} (@pxref{FORMATS}),
6386 but @cmd{PRINT FORMATS} sets only print formats, not write formats.
6387
6388 @node RENAME VARIABLES, VALUE LABELS, PRINT FORMATS, Variable Attributes
6389 @section RENAME VARIABLES
6390 @vindex RENAME VARIABLES
6391
6392 @display
6393 RENAME VARIABLES (old_names=new_names)@dots{} .
6394 @end display
6395
6396 @cmd{RENAME VARIABLES} changes the names of variables in the active
6397 file.  Specify lists of the old variable names and new
6398 variable names, separated by an equals sign (@samp{=}), within
6399 parentheses.  There must be the same number of old and new variable
6400 names.  Each old variable is renamed to the corresponding new variable
6401 name.  Multiple parenthesized groups of variables may be specified.
6402
6403 @cmd{RENAME VARIABLES} takes effect immediately.  It does not cause the data
6404 to be read.
6405
6406 @cmd{RENAME VARIABLES} may not be specified following @cmd{TEMPORARY}
6407 (@pxref{TEMPORARY}).
6408
6409 @node VALUE LABELS, STRING, RENAME VARIABLES, Variable Attributes
6410 @section VALUE LABELS
6411 @vindex VALUE LABELS
6412
6413 @display 
6414 VALUE LABELS
6415         /var_list value 'label' [value 'label']@dots{}
6416 @end display
6417
6418 @cmd{VALUE LABELS} allows values of numeric and short string
6419 variables to be associated with labels.  In this way, a short value can
6420 stand for a long value.
6421
6422 To set up value labels for a set of variables, specify the
6423 variable names after a slash (@samp{/}), followed by a list of values
6424 and their associated labels, separated by spaces.  Long string
6425 variables may not be specified.
6426
6427 Before @cmd{VALUE LABELS} is executed, any existing value labels
6428 are cleared from the variables specified.  Use @cmd{ADD VALUE LABELS}
6429 (@pxref{ADD VALUE LABELS}) to add value labels without clearing those
6430 already present.
6431
6432 @node STRING, VARIABLE LABELS, VALUE LABELS, Variable Attributes
6433 @section STRING
6434 @vindex STRING
6435
6436 @display
6437 STRING /var_list (fmt_spec).
6438 @end display
6439
6440 @cmd{STRING} creates new string variables for use in
6441 transformations.
6442
6443 Specify a slash (@samp{/}), followed by the names of the string
6444 variables to create and the desired output format specification in
6445 parentheses (@pxref{Input/Output Formats}).  Variable widths are
6446 implicitly derived from the specified output formats.
6447
6448 Created variables are initialized to spaces.
6449
6450 @node VARIABLE LABELS, VECTOR, STRING, Variable Attributes
6451 @section VARIABLE LABELS
6452 @vindex VARIABLE LABELS
6453
6454 @display
6455 VARIABLE LABELS
6456         /var_list 'var_label'.
6457 @end display
6458
6459 @cmd{VARIABLE LABELS} associates explanatory names
6460 with variables.  This name, called a @dfn{variable label}, is displayed by
6461 statistical procedures.
6462
6463 To assign a variable label to a group of variables, specify a slash
6464 (@samp{/}), followed by the list of variable names and the variable
6465 label as a string.
6466
6467 @node VECTOR, WRITE FORMATS, VARIABLE LABELS, Variable Attributes
6468 @section VECTOR
6469 @vindex VECTOR
6470
6471 @display
6472 Two possible syntaxes:
6473         VECTOR vec_name=var_list.
6474         VECTOR vec_name_list(count).
6475 @end display
6476
6477 @cmd{VECTOR} allows a group of variables to be accessed as if they
6478 were consecutive members of an array with a vector(index) notation.
6479
6480 To make a vector out of a set of existing variables, specify a name for
6481 the vector followed by an equals sign (@samp{=}) and the variables that
6482 belong in the vector.
6483
6484 To make a vector and create variables at the same time, specify one or
6485 more vector names followed by a count in parentheses.  This will cause
6486 variables named @code{@var{vec}1} through @code{@var{vec}@var{count}}
6487 to be created as numeric variables with print and write format F8.2.
6488 Variable names including numeric suffixes may not exceed 8 characters
6489 in length, and none of the variables may exist prior to @cmd{VECTOR}.
6490
6491 All the variables in a vector must be the same type.
6492
6493 Vectors created with @cmd{VECTOR} disappear after any procedure or
6494 procedure-like command is executed.  The variables contained in the
6495 vectors remain, unless they are scratch variables (@pxref{Scratch
6496 Variables}).
6497
6498 Variables within a vector may be references in expressions using
6499 @code{vector(index)} syntax.
6500
6501 @node WRITE FORMATS,  , VECTOR, Variable Attributes
6502 @section WRITE FORMATS
6503 @vindex WRITE FORMATS
6504
6505 @display
6506 WRITE FORMATS var_list (fmt_spec).
6507 @end display
6508
6509 @cmd{WRITE FORMATS} sets the write formats for the specified variables
6510 to the specified format specification.  Its syntax is identical to
6511 that of FORMATS (@pxref{FORMATS}), but @cmd{WRITE FORMATS} sets only
6512 write formats, not print formats.
6513
6514 @node Data Manipulation, Data Selection, Variable Attributes, Top
6515 @chapter Data transformations
6516 @cindex transformations
6517
6518 The PSPP procedures examined in this chapter manipulate data and
6519 prepare the active file for later analyses.  They do not produce output,
6520 as a rule.
6521
6522 @menu
6523 * AGGREGATE::                   Summarize multiple cases into a single case.
6524 * AUTORECODE::                  Automatic recoding of variables.
6525 * COMPUTE::                     Assigning a variable a calculated value.
6526 * COUNT::                       Counting variables with particular values.
6527 * FLIP::                        Exchange variables with cases.
6528 * IF::                          Conditionally assigning a calculated value.
6529 * RECODE::                      Mapping values from one set to another.
6530 * SORT CASES::                  Sort the active file.
6531 @end menu
6532
6533 @node AGGREGATE, AUTORECODE, Data Manipulation, Data Manipulation
6534 @section AGGREGATE
6535 @vindex AGGREGATE
6536
6537 @display
6538 AGGREGATE
6539         /BREAK=var_list
6540         /PRESORTED
6541         /OUTFILE=@{*,'filename'@}
6542         /DOCUMENT
6543         /MISSING=COLUMNWISE
6544         /dest_vars=agr_func(src_vars, args@dots{})@dots{}
6545 @end display
6546
6547 @cmd{AGGREGATE} summarizes groups of cases into single cases.
6548 Cases are divided into groups that have the same values for one or more
6549 variables called @dfn{break variables}.  Several functions are available
6550 for summarizing case contents.
6551
6552 At least one break variable must be specified on BREAK, the only
6553 required subcommand.  The values of these variables are used to divide
6554 the active file into groups to be summarized.  In addition, at least
6555 one @var{dest_var} must be specified.
6556
6557 By default, the active file is sorted based on the break variables
6558 before aggregation takes place.  If the active file is already sorted
6559 or otherwise grouped in terms of the break variables, specify
6560 PRESORTED to save time.
6561
6562 The OUTFILE subcommand specifies a system file by file name string or
6563 file handle (@pxref{FILE HANDLE}).  The aggregated cases are written to
6564 this file.  If OUTFILE is not specified, or if @samp{*} is specified,
6565 then the aggregated cases replace the active file.
6566
6567 Specify DOCUMENT to copy the documents from the active file into the
6568 aggregate file (@pxref{DOCUMENT}).  Otherwise, the aggregate file will
6569 not contain any documents, even if the aggregate file replaces the
6570 active file.
6571
6572 One or more sets of aggregation variables must be specified.  Each set
6573 comprises a list of aggregation variables, an equals sign (@samp{=}),
6574 the name of an aggregation function (see the list below), and a list
6575 of source variables in parentheses.  Some aggregation functions expect
6576 additional arguments following the source variable names.
6577
6578 Each set must have exactly as many source variables as aggregation
6579 variables.  Each aggregation variable receives the results of applying
6580 the specified aggregation function to the corresponding source
6581 variable.  Most aggregation functions may be applied to numeric and
6582 short and long string variables.  Others, marked below, are restricted
6583 to numeric values.
6584
6585 The available aggregation functions are as follows:
6586
6587 @table @asis
6588 @item SUM(var_name)
6589 Sum.  Limited to numeric values.
6590 @item MEAN(var_name)
6591 Arithmetic mean.  Limited to numeric values.
6592 @item SD(var_name)
6593 Standard deviation of the mean.  Limited to numeric values.
6594 @item MAX(var_name)
6595 Maximum value.
6596 @item MIN(var_name)
6597 Minimum value.
6598 @item FGT(var_name, value)
6599 @itemx PGT(var_name, value)
6600 Fraction between 0 and 1, or percentage between 0 and 100, respectively,
6601 of values greater than the specified constant.
6602 @item FLT(var_name, value)
6603 @itemx PLT(var_name, value)
6604 Fraction or percentage, respectively, of values less than the specified
6605 constant.
6606 @item FIN(var_name, low, high)
6607 @itemx PIN(var_name, low, high)
6608 Fraction or percentage, respectively, of values within the specified
6609 inclusive range of constants.
6610 @item FOUT(var_name, low, high)
6611 @itemx POUT(var_name, low, high)
6612 Fraction or percentage, respectively, of values strictly outside the
6613 specified range of constants.
6614 @item N(var_name)
6615 Number of non-missing values.
6616 @item N
6617 Number of cases aggregated to form this group.  Don't supply a source
6618 variable for this aggregation function.
6619 @item NU(var_name)
6620 Number of non-missing values.  Each case is considered to have a weight
6621 of 1, regardless of the current weighting variable (@pxref{WEIGHT}).
6622 @item NU
6623 Number of cases aggregated to form this group.  Each case is considered
6624 to have a weight of 1, regardless of the current weighting variable.
6625 @item NMISS(var_name)
6626 Number of missing values.
6627 @item NUMISS(var_name)
6628 Number of missing values.  Each case is considered to have a weight of
6629 1, regardless of the current weighting variable.
6630 @item FIRST(var_name)
6631 First value in this group.
6632 @item LAST(var_name)
6633 Last value in this group.
6634 @end table
6635
6636 Aggregation functions compare string values in terms of internal
6637 character codes.  On most modern computers, this is a form of ASCII.
6638
6639 The aggregation functions listed above exclude all user-missing values
6640 from calculations.  To include user-missing values, insert a period
6641 (@samp{.}) between the function name and left parenthesis
6642 (e.g.@: @samp{SUM.}).
6643
6644 Normally, only a single case (for SD and SD., two cases) need be
6645 non-missing in each group for the aggregate variable to be
6646 non-missing.  Specifying /MISSING=COLUMNWISE inverts this behavior, so
6647 that the aggregate variable becomes missing if any aggregated value is
6648 missing.
6649
6650 @cmd{AGGREGATE} both ignores and cancels the current @cmd{SPLIT FILE}
6651 settings (@pxref{SPLIT FILE}).
6652
6653 @node AUTORECODE, COMPUTE, AGGREGATE, Data Manipulation
6654 @section AUTORECODE
6655 @vindex AUTORECODE
6656
6657 @display
6658 AUTORECODE VARIABLES=src_vars INTO dest_vars
6659         /DESCENDING
6660         /PRINT
6661 @end display
6662
6663 The @cmd{AUTORECODE} procedure considers the @var{n} values that a variable
6664 takes on and maps them onto values 1@dots{}@var{n} on a new numeric
6665 variable.
6666
6667 Subcommand VARIABLES is the only required subcommand and must come
6668 first.  Specify VARIABLES, an equals sign (@samp{=}), a list of source
6669 variables, INTO, and a list of target variables.  There must the same
6670 number of source and target variables.  The target variables must not
6671 already exist.
6672
6673 By default, increasing values of a source variable (for a string, this
6674 is based on character code comparisons) are recoded to increasing values
6675 of its target variable.  To cause increasing values of a source variable
6676 to be recoded to decreasing values of its target variable (@var{n} down
6677 to 1), specify DESCENDING.
6678
6679 PRINT is currently ignored.
6680
6681 @cmd{AUTORECODE} is a procedure.  It causes the data to be read.
6682
6683 @node COMPUTE, COUNT, AUTORECODE, Data Manipulation
6684 @section COMPUTE
6685 @vindex COMPUTE
6686
6687 @display
6688 COMPUTE variable = expression.
6689   or
6690 COMPUTE vector(index) = expression.
6691 @end display
6692
6693 @cmd{COMPUTE} assigns the value of an expression to a target
6694 variable.  For each case, the expression is evaluated and its value
6695 assigned to the target variable.  Numeric and short and long string
6696 variables may be assigned.  When a string expression's width differs
6697 from the target variable's width, the string result of the expression
6698 is truncated or padded with spaces on the right as necessary.  The
6699 expression and variable types must match.
6700
6701 For numeric variables only, the target variable need not already
6702 exist.  Numeric variables created by @cmd{COMPUTE} are assigned an
6703 @code{F8.2} output format.  String variables must be declared before
6704 they can be used as targets for @cmd{COMPUTE}.
6705
6706 The target variable may be specified as an element of a vector
6707 (@pxref{VECTOR}).  In this case, a vector index expression must be
6708 specified in parentheses following the vector name.  The index
6709 expression must evaluate to a numeric value that, after rounding down
6710 to the nearest integer, is a valid index for the named vector.
6711
6712 Using @cmd{COMPUTE} to assign to a variable specified on @cmd{LEAVE}
6713 (@pxref{LEAVE}) resets the variable's left state.  Therefore,
6714 @code{LEAVE} should be specified following @cmd{COMPUTE}, not before.
6715
6716 @cmd{COMPUTE} is a transformation.  It does not cause the active file to be
6717 read.
6718
6719 When @cmd{COMPUTE} is specified following @cmd{TEMPORARY}
6720 (@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
6721 (@pxref{LAG}).
6722
6723 @node COUNT, FLIP, COMPUTE, Data Manipulation
6724 @section COUNT
6725 @vindex COUNT
6726
6727 @display
6728 COUNT var_name = var@dots{} (value@dots{}).
6729
6730 Each value takes one of the following forms:
6731         number
6732         string
6733         num1 THRU num2
6734         MISSING
6735         SYSMIS
6736 In addition, num1 and num2 can be LO or LOWEST, or HI or HIGHEST,
6737 respectively.
6738 @end display
6739
6740 @cmd{COUNT} creates or replaces a numeric @dfn{target} variable that
6741 counts the occurrence of a @dfn{criterion} value or set of values over
6742 one or more @dfn{test} variables for each case.
6743
6744 The target variable values are always nonnegative integers.  They are
6745 never missing.  The target variable is assigned an F8.2 output format.
6746 @xref{Input/Output Formats}.  Any variables, including long and short
6747 string variables, may be test variables.
6748
6749 User-missing values of test variables are treated just like any other
6750 values.  They are @strong{not} treated as system-missing values.
6751 User-missing values that are criterion values or inside ranges of
6752 criterion values are counted as any other values.  However (for numeric
6753 variables), keyword MISSING may be used to refer to all system-
6754 and user-missing values.
6755
6756 @cmd{COUNT} target variables are assigned values in the order
6757 specified.  In the command @code{COUNT A=A B(1) /B=A B(2).}, the
6758 following actions occur:
6759
6760 @itemize @minus
6761 @item
6762 The number of occurrences of 1 between @code{A} and @code{B} is counted.
6763
6764 @item
6765 @code{A} is assigned this value.
6766
6767 @item
6768 The number of occurrences of 1 between @code{B} and the @strong{new}
6769 value of @code{A} is counted.
6770
6771 @item
6772 @code{B} is assigned this value.
6773 @end itemize
6774
6775 Despite this ordering, all @cmd{COUNT} criterion variables must exist
6776 before the procedure is executed---they may not be created as target
6777 variables earlier in the command!  Break such a command into two
6778 separate commands.
6779
6780 The examples below may help to clarify.
6781
6782 @enumerate A
6783 @item
6784 Assuming @code{Q0}, @code{Q2}, @dots{}, @code{Q9} are numeric variables,
6785 the following commands:
6786
6787 @enumerate
6788 @item
6789 Count the number of times the value 1 occurs through these variables
6790 for each case and assigns the count to variable @code{QCOUNT}.  
6791
6792 @item
6793 Print out the total number of times the value 1 occurs throughout
6794 @emph{all} cases using @cmd{DESCRIPTIVES}.  @xref{DESCRIPTIVES}, for
6795 details.
6796 @end enumerate
6797
6798 @example
6799 COUNT QCOUNT=Q0 TO Q9(1).
6800 DESCRIPTIVES QCOUNT /STATISTICS=SUM.
6801 @end example
6802
6803 @item
6804 Given these same variables, the following commands:
6805
6806 @enumerate
6807 @item
6808 Count the number of valid values of these variables for each case and
6809 assigns the count to variable @code{QVALID}.
6810
6811 @item
6812 Multiplies each value of @code{QVALID} by 10 to obtain a percentage of
6813 valid values, using @cmd{COMPUTE}.  @xref{COMPUTE}, for details.
6814
6815 @item
6816 Print out the percentage of valid values across all cases, using
6817 @cmd{DESCRIPTIVES}.  @xref{DESCRIPTIVES}, for details.
6818 @end enumerate
6819
6820 @example
6821 COUNT QVALID=Q0 TO Q9 (LO THRU HI).
6822 COMPUTE QVALID=QVALID*10.
6823 DESCRIPTIVES QVALID /STATISTICS=MEAN.
6824 @end example
6825 @end enumerate
6826
6827 @node FLIP, IF, COUNT, Data Manipulation
6828 @section FLIP
6829 @vindex FLIP
6830
6831 @display
6832 FLIP /VARIABLES=var_list /NEWNAMES=var_name.
6833 @end display
6834
6835 @cmd{FLIP} transposes rows and columns in the active file.  It
6836 causes cases to be swapped with variables, and vice versa.
6837
6838 All variables in the transposed active file are numeric.  String
6839 variables take on the system-missing value in the transposed file.
6840
6841 No subcommands are required.  The VARIABLES subcommand specifies
6842 variables that will be transformed into cases.  Variables not specified
6843 are discarded.  By default, all variables are selected for
6844 transposition.
6845
6846 The variables specified by NEWNAMES, which must be a string variable, is
6847 used to give names to the variables created by @cmd{FLIP}.  If
6848 NEWNAMES is not
6849 specified then the default is a variable named CASE_LBL, if it exists.
6850 If it does not then the variables created by FLIP are named VAR000
6851 through VAR999, then VAR1000, VAR1001, and so on.
6852
6853 When a NEWNAMES variable is available, the names must be canonicalized
6854 before becoming variable names.  Invalid characters are replaced by
6855 letter @samp{V} in the first position, or by @samp{_} in subsequent
6856 positions.  If the name thus generated is not unique, then numeric
6857 extensions are added, starting with 1, until a unique name is found or
6858 there are no remaining possibilities.  If the latter occurs then the
6859 FLIP operation aborts.
6860
6861 The resultant dictionary contains a CASE_LBL variable, which stores the
6862 names of the variables in the dictionary before the transposition.  If
6863 the active file is subsequently transposed using @cmd{FLIP}, this
6864 variable can
6865 be used to recreate the original variable names.
6866
6867 FLIP honors N OF CASES.  It ignores TEMPORARY, so that ``temporary''
6868 transformations become permanent.
6869
6870 @node IF, RECODE, FLIP, Data Manipulation
6871 @section IF
6872 @vindex IF
6873
6874 @display
6875 IF condition variable=expression.
6876   or
6877 IF condition vector(index)=expression.
6878 @end display
6879
6880 The @cmd{IF} transformation conditionally assigns the value of a target
6881 expression to a target variable, based on the truth of a test
6882 expression.
6883
6884 Specify a boolean-valued expression (@pxref{Expressions}) to be tested
6885 following the IF keyword.  This expression is evaluated for each case.
6886 If the value is true, then the value of the expression is computed and
6887 assigned to the specified variable.  If the value is false or missing,
6888 nothing is done.  Numeric and short and long string variables may be
6889 assigned.  When a string expression's width differs from the target
6890 variable's width, the string result of the expression is truncated or
6891 padded with spaces on the right as necessary.  The expression and
6892 variable types must match.
6893
6894 The target variable may be specified as an element of a vector
6895 (@pxref{VECTOR}).  In this case, a vector index expression must be
6896 specified in parentheses following the vector name.  The index
6897 expression must evaluate to a numeric value that, after rounding down
6898 to the nearest integer, is a valid index for the named vector.
6899
6900 Using @cmd{IF} to assign to a variable specified on @cmd{LEAVE}
6901 (@pxref{LEAVE}) resets the variable's left state.  Therefore,
6902 @code{LEAVE} should be specified following @cmd{IF}, not before.
6903
6904 When @cmd{IF} is specified following @cmd{TEMPORARY}
6905 (@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
6906 (@pxref{LAG}).
6907
6908 @node RECODE, SORT CASES, IF, Data Manipulation
6909 @section RECODE
6910 @vindex RECODE
6911
6912 @display
6913 RECODE var_list (src_value@dots{}=dest_value)@dots{} [INTO var_list].
6914
6915 src_value may take the following forms:
6916         number
6917         string
6918         num1 THRU num2
6919         MISSING
6920         SYSMIS
6921         ELSE
6922 Open-ended ranges may be specified using LO or LOWEST for num1
6923 or HI or HIGHEST for num2.
6924
6925 dest_value may take the following forms:
6926         num
6927         string
6928         SYSMIS
6929         COPY
6930 @end display
6931
6932 @cmd{RECODE} translates data from one range of values to
6933 another, via flexible user-specified mappings.  Data may be remapped
6934 in-place or copied to new variables.  Numeric, short string, and long
6935 string data can be recoded.
6936
6937 Specify the list of source variables, followed by one or more mapping
6938 specifications each enclosed in parentheses.  If the data is to be
6939 copied to new variables, specify INTO, then the list of target
6940 variables.  String target variables must already have been declared
6941 using @cmd{STRING} or another transformation, but numeric target
6942 variables can
6943 be created on the fly.  There must be exactly as many target variables
6944 as source variables.  Each source variable is remapped into its
6945 corresponding target variable.
6946
6947 When INTO is not used, the input and output variables must be of the
6948 same type.  Otherwise, string values can be recoded into numeric values,
6949 and vice versa.  When this is done and there is no mapping for a
6950 particular value, either a value consisting of all spaces or the
6951 system-missing value is assigned, depending on variable type.
6952
6953 Mappings are considered from left to right.  The first src_value that
6954 matches the value of the source variable causes the target variable to
6955 receive the value indicated by the dest_value.  Literal number, string,
6956 and range src_value's should be self-explanatory.  MISSING as a
6957 src_value matches any user- or system-missing value.  SYSMIS matches the
6958 system missing value only.  ELSE is a catch-all that matches anything.
6959 It should be the last src_value specified.
6960
6961 Numeric and string dest_value's should also be self-explanatory.  COPY
6962 causes the input values to be copied to the output.  This is only value
6963 if the source and target variables are of the same type.  SYSMIS
6964 indicates the system-missing value.
6965
6966 If the source variables are strings and the target variables are
6967 numeric, then there is one additional mapping available: (CONVERT),
6968 which must be the last specified mapping.  CONVERT causes a number
6969 specified as a string to be converted to a numeric value.  If the string
6970 cannot be parsed as a number, then the system-missing value is assigned.
6971
6972 Multiple recodings can be specified on a single @cmd{RECODE} invocation.
6973 Introduce additional recodings with a slash (@samp{/}) to
6974 separate them from the previous recodings.
6975
6976 @node SORT CASES,  , RECODE, Data Manipulation
6977 @section SORT CASES
6978 @vindex SORT CASES
6979
6980 @display
6981 SORT CASES BY var_list.
6982 @end display
6983
6984 @cmd{SORT CASES} sorts the active file by the values of one or more
6985 variables.
6986
6987 Specify BY and a list of variables to sort by.  By default, variables
6988 are sorted in ascending order.  To override sort order, specify (D) or
6989 (DOWN) after a list of variables to get descending order, or (A) or (UP)
6990 for ascending order.  These apply to the entire list of variables
6991 preceding them.
6992
6993 @cmd{SORT CASES} is a procedure.  It causes the data to be read.
6994
6995 @cmd{SORT CASES} attempts to sort the entire active file in main memory.
6996 If main memory is exhausted, it falls back to a merge sort algorithm that
6997 involves writing and reading numerous temporary files.
6998
6999 @cmd{SORT CASES} may not be specified following TEMPORARY.  
7000
7001 @node Data Selection, Conditionals and Looping, Data Manipulation, Top
7002 @chapter Selecting data for analysis
7003
7004 This chapter documents PSPP commands that temporarily or permanently
7005 select data records from the active file for analysis.
7006
7007 @menu
7008 * FILTER::                      Exclude cases based on a variable.
7009 * N OF CASES::                  Limit the size of the active file.
7010 * PROCESS IF::                  Temporarily excluding cases.
7011 * SAMPLE::                      Select a specified proportion of cases.
7012 * SELECT IF::                   Permanently delete selected cases.
7013 * SPLIT FILE::                  Do multiple analyses with one command.
7014 * TEMPORARY::                   Make transformations' effects temporary.
7015 * WEIGHT::                      Weight cases by a variable.
7016 @end menu
7017
7018 @node FILTER, N OF CASES, Data Selection, Data Selection
7019 @section FILTER
7020 @vindex FILTER
7021
7022 @display
7023 FILTER BY var_name.
7024 FILTER OFF.
7025 @end display
7026
7027 @cmd{FILTER} allows a boolean-valued variable to be used to select
7028 cases from the data stream for processing.
7029
7030 To set up filtering, specify BY and a variable name.  Keyword
7031 BY is optional but recommended.  Cases which have a zero or system- or
7032 user-missing value are excluded from analysis, but not deleted from the
7033 data stream.  Cases with other values are analyzed.
7034 To filter based on a different condition, use
7035 transformations such as @cmd{COMPUTE} or @cmd{RECODE} to compute a
7036 filter variable of the required form, then specify that variable on
7037 @cmd{FILTER}.
7038
7039 @code{FILTER OFF} turns off case filtering.
7040
7041 Filtering takes place immediately before cases pass to a procedure for
7042 analysis.  Only one filter variable may be active at a time.  Normally,
7043 case filtering continues until it is explicitly turned off with @code{FILTER
7044 OFF}.  However, if @cmd{FILTER} is placed after TEMPORARY, it filters only
7045 the next procedure or procedure-like command.
7046
7047 @node N OF CASES, PROCESS IF, FILTER, Data Selection
7048 @section N OF CASES
7049 @vindex N OF CASES
7050
7051 @display
7052 N [OF CASES] num_of_cases [ESTIMATED].
7053 @end display
7054
7055 Sometimes you may want to disregard cases of your input.  @cmd{N} can
7056 do this.  @code{N 100} tells PSPP to disregard all cases after the
7057 first 100.
7058
7059 If the value specified for @cmd{N} is greater than the number of cases
7060 read in, the value is ignored.
7061
7062 @cmd{N} does not discard cases or prevent them from being read.  It
7063 just causes cases beyond the last one specified to be ignored by data
7064 analysis commands.
7065
7066 A later @cmd{N} command can increase or decrease the number of cases
7067 selected.  (To select all the cases without knowing how many there are,
7068 specify a very high number: 100000 or whatever you think is large enough.)
7069
7070 Transformation procedures performed after @cmd{N} is executed
7071 @emph{do} cause cases to be discarded.
7072
7073 @cmd{SAMPLE}, @cmd{PROCESS IF}, and @cmd{SELECT IF} have
7074 precedence over @cmd{N}---the same results are obtained by both of the
7075 following fragments, given the same random number seeds:
7076
7077 @example
7078 @i{@dots{}set up, read in data@dots{}}
7079 N 100.
7080 SAMPLE .5.
7081 @i{@dots{}analyze data@dots{}}
7082
7083 @i{@dots{}set up, read in data@dots{}}  
7084 SAMPLE .5.
7085 N 100.
7086 @i{@dots{}analyze data@dots{}}
7087 @end example
7088
7089 Both fragments above first randomly sample approximately half of the
7090 cases, then select the first 100 of those sampled.
7091
7092 @cmd{N} with the @code{ESTIMATED} keyword gives an
7093 estimated number of cases before @cmd{DATA LIST} or another command to
7094 read in data.  @code{ESTIMATED} never limits the number of cases
7095 processed by procedures.  PSPP currently does not make use of
7096 case count estimates.
7097
7098 When @cmd{N} is specified after @cmd{TEMPORARY}, it affects only
7099 the next procedure (@pxref{TEMPORARY}).
7100
7101 @node PROCESS IF, SAMPLE, N OF CASES, Data Selection
7102 @section PROCESS IF
7103 @vindex PROCESS IF
7104
7105 @example
7106 PROCESS IF expression.
7107 @end example
7108
7109 @cmd{PROCESS IF} temporarily eliminates cases from the
7110 data stream.  Its effects are active only through the execution of the
7111 next procedure or procedure-like command.
7112
7113 Specify a boolean expression (@pxref{Expressions}).  If the value of the
7114 expression is true for a particular case, the case will be analyzed.  If
7115 the expression has a false or missing value, then the case will be
7116 deleted from the data stream for this procedure only.
7117
7118 Regardless of its placement relative to other commands, @cmd{PROCESS IF}
7119 always takes effect immediately before data passes to the procedure.
7120 Only one @cmd{PROCESS IF} command may be in effect at any given time.
7121
7122 The effects of @cmd{PROCESS IF} are similar, but not identical, to the
7123 effects of executing @cmd{TEMPORARY}, then @cmd{SELECT IF}
7124 (@pxref{SELECT IF}).
7125
7126 The filtering performed by @cmd{PROCESS IF} takes place immediately
7127 before cases pass to a procedure for analysis.  Because @cmd{PROCESS
7128 IF} affects only a single procedure, its placement relative to
7129 @cmd{TEMPORARY} is unimportant.
7130
7131 @cmd{PROCESS IF} is deprecated.  It is included for compatibility with
7132 old command files.  New syntax files should use @cmd{SELECT IF} or
7133 @cmd{FILTER} instead.
7134
7135 @node SAMPLE, SELECT IF, PROCESS IF, Data Selection
7136 @section SAMPLE
7137 @vindex SAMPLE
7138
7139 @display
7140 SAMPLE num1 [FROM num2].
7141 @end display
7142
7143 @cmd{SAMPLE} randomly samples a proportion of the cases in the active
7144 file.  Unless it follows @cmd{TEMPORARY}, it operates as a
7145 transformation, permanently removing cases from the active file.
7146
7147 The proportion to sample can be expressed as a single number between 0
7148 and 1.  If @code{k} is the number specified, and @code{N} is the number
7149 of currently-selected cases in the active file, then after
7150 @code{SAMPLE @var{k}.}, approximately @code{k*N} cases will be
7151 selected.
7152
7153 The proportion to sample can also be specified in the style @code{SAMPLE
7154 @var{m} FROM @var{N}}.  With this style, cases are selected as follows:
7155
7156 @enumerate
7157 @item
7158 If @var{N} is equal to the number of currently-selected cases in the
7159 active file, exactly @var{m} cases will be selected.
7160
7161 @item
7162 If @var{N} is greater than the number of currently-selected cases in the
7163 active file, an equivalent proportion of cases will be selected.
7164
7165 @item
7166 If @var{N} is less than the number of currently-selected cases in the
7167 active, exactly @var{m} cases will be selected @emph{from the first
7168 @var{N} cases in the active file.}
7169 @end enumerate
7170
7171 @cmd{SAMPLE} and @cmd{SELECT IF} are performed in
7172 the order specified by the syntax file.
7173
7174 @cmd{SAMPLE} is always performed before @code{N OF CASES}, regardless
7175 of ordering in the syntax file (@pxref{N OF CASES}).
7176
7177 The same values for @cmd{SAMPLE} may result in different samples.  To
7178 obtain the same sample, use the @code{SET} command to set the random
7179 number seed to the same value before each @cmd{SAMPLE}.  Different
7180 samples may still result when the file is processed on systems with
7181 differing endianness or floating-point formats.  By default, the
7182 random number seed is based on the system time.
7183
7184 @node SELECT IF, SPLIT FILE, SAMPLE, Data Selection
7185 @section SELECT IF
7186 @vindex SELECT IF
7187
7188 @display
7189 SELECT IF expression.
7190 @end display
7191
7192 @cmd{SELECT IF} selects cases for analysis based on the value of a
7193 boolean expression.  Cases not selected are permanently eliminated
7194 from the active file, unless @cmd{TEMPORARY} is in effect
7195 (@pxref{TEMPORARY}).
7196
7197 Specify a boolean expression (@pxref{Expressions}).  If the value of the
7198 expression is true for a particular case, the case will be analyzed.  If
7199 the expression has a false or missing value, then the case will be
7200 deleted from the data stream.
7201
7202 Place @cmd{SELECT IF} as early in the command file as
7203 possible.  Cases that are deleted early can be processed more
7204 efficiently in time and space.
7205
7206 When @cmd{SELECT IF} is specified following @cmd{TEMPORARY}
7207 (@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
7208 (@pxref{LAG}).
7209
7210 @node SPLIT FILE, TEMPORARY, SELECT IF, Data Selection
7211 @section SPLIT FILE
7212 @vindex SPLIT FILE
7213
7214 @display
7215 Two possible syntaxes:
7216         SPLIT FILE BY var_list.
7217         SPLIT FILE OFF.
7218 @end display
7219
7220 @cmd{SPLIT FILE} allows multiple sets of data present in one data
7221 file to be analyzed separately using single statistical procedure
7222 commands.
7223
7224 Specify a list of variable names to analyze multiple sets of
7225 data separately.  Groups of cases having the same values for these
7226 variables are analyzed by statistical procedure commands as one group.
7227 An independent analysis is carried out for each group of cases, and the
7228 variable values for the group are printed along with the analysis.
7229
7230 Specify OFF to disable @cmd{SPLIT FILE} and resume analysis of the
7231 entire active file as a single group of data.
7232
7233 When @cmd{SPLIT FILE} is specified after @cmd{TEMPORARY}, it affects only
7234 the next procedure (@pxref{TEMPORARY}).
7235
7236 @node TEMPORARY, WEIGHT, SPLIT FILE, Data Selection
7237 @section TEMPORARY
7238 @vindex TEMPORARY
7239
7240 @display
7241 TEMPORARY.
7242 @end display
7243
7244 @cmd{TEMPORARY} is used to make the effects of transformations
7245 following its execution temporary.  These transformations will
7246 affect only the execution of the next procedure or procedure-like
7247 command.  Their effects will not be saved to the active file.
7248
7249 The only specification on @cmd{TEMPORARY} is the command name.
7250
7251 @cmd{TEMPORARY} may not appear within a @cmd{DO IF} or @cmd{LOOP}
7252 construct.  It may appear only once between procedures and
7253 procedure-like commands.
7254
7255 Scratch variables cannot be used following @cmd{TEMPORARY}.
7256
7257 An example may help to clarify:
7258
7259 @example
7260 DATA LIST /X 1-2.
7261 BEGIN DATA.
7262  2
7263  4
7264 10
7265 15
7266 20
7267 24
7268 END DATA.
7269 COMPUTE X=X/2.
7270 TEMPORARY.
7271 COMPUTE X=X+3.
7272 DESCRIPTIVES X.
7273 DESCRIPTIVES X.
7274 @end example
7275
7276 The data read by the first @cmd{DESCRIPTIVES} are 4, 5, 8,
7277 10.5, 13, 15.  The data read by the first @cmd{DESCRIPTIVES} are 1, 2,
7278 5, 7.5, 10, 12.
7279
7280 @node WEIGHT,  , TEMPORARY, Data Selection
7281 @section WEIGHT
7282 @vindex WEIGHT
7283
7284 @display
7285 WEIGHT BY var_name.
7286 WEIGHT OFF.
7287 @end display
7288
7289 @cmd{WEIGHT} assigns cases varying weights,
7290 changing the frequency distribution of the active file.  Execution of
7291 @cmd{WEIGHT} is delayed until data have been read.
7292
7293 If a variable name is specified, @cmd{WEIGHT} causes the values of that
7294 variable to be used as weighting factors for subsequent statistical
7295 procedures.  Use of keyword BY is optional but recommended.  Weighting
7296 variables must be numeric.  Scratch variables may not be used for
7297 weighting (@pxref{Scratch Variables}).
7298
7299 When OFF is specified, subsequent statistical procedures will weight all
7300 cases equally.
7301
7302 A positive integer weighting factor @var{w} on a case will yield the
7303 same statistical output as would replicating the case @var{w} times.
7304 A weighting factor of 0 is treated for statistical purposes as if the
7305 case did not exist in the input.  Weighting values need not be
7306 integers, but negative and system-missing values for the weighting
7307 variable are interpreted as weighting factors of 0.  User-missing
7308 values are not treated specially.
7309
7310 When @cmd{WEIGHT} is specified after @cmd{TEMPORARY}, it affects only
7311 the next procedure (@pxref{TEMPORARY}).
7312
7313 @cmd{WEIGHT} does not cause cases in the active file to be replicated in
7314 memory.
7315
7316 @node Conditionals and Looping, Statistics, Data Selection, Top
7317 @chapter Conditional and Looping Constructs
7318 @cindex conditionals
7319 @cindex loops
7320 @cindex flow of control
7321 @cindex control flow
7322
7323 This chapter documents PSPP commands used for conditional execution,
7324 looping, and flow of control.
7325
7326 @menu
7327 * BREAK::                       Exit a loop.
7328 * DO IF::                       Conditionally execute a block of code.
7329 * DO REPEAT::                   Textually repeat a code block.
7330 * LOOP::                        Repeat a block of code.
7331 @end menu
7332
7333 @node BREAK, DO IF, Conditionals and Looping, Conditionals and Looping
7334 @section BREAK
7335 @vindex BREAK
7336
7337 @display
7338 BREAK.
7339 @end display
7340
7341 @cmd{BREAK} terminates execution of the innermost currently executing
7342 @cmd{LOOP} construct.
7343
7344 @cmd{BREAK} is allowed only inside @cmd{LOOP}@dots{}@cmd{END LOOP}.
7345 @xref{LOOP}, for more details.
7346
7347 @node DO IF, DO REPEAT, BREAK, Conditionals and Looping
7348 @section DO IF
7349 @vindex DO IF
7350
7351 @display
7352 DO IF condition.
7353         @dots{}
7354 [ELSE IF condition.
7355         @dots{}
7356 ]@dots{}
7357 [ELSE.
7358         @dots{}]
7359 END IF.
7360 @end display
7361
7362 @cmd{DO IF} allows one of several sets of transformations to be
7363 executed, depending on user-specified conditions.
7364
7365 If the specified boolean expression evaluates as true, then the block
7366 of code following @cmd{DO IF} is executed.  If it evaluates as
7367 missing, then
7368 none of the code blocks is executed.  If it is false, then
7369 the boolean expression on the first @cmd{ELSE IF}, if present, is tested in
7370 turn, with the same rules applied.  If all expressions evaluate to
7371 false, then the @cmd{ELSE} code block is executed, if it is present.
7372
7373 When @cmd{DO IF} or @cmd{ELSE IF} is specified following @cmd{TEMPORARY}
7374 (@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
7375 (@pxref{LAG}).
7376
7377 @node DO REPEAT, LOOP, DO IF, Conditionals and Looping
7378 @section DO REPEAT
7379 @vindex DO REPEAT
7380
7381 @display
7382 DO REPEAT repvar_name=expansion@dots{}.
7383         @dots{}
7384 END REPEAT [PRINT].
7385
7386 expansion takes one of the following forms:
7387         var_list
7388         num_or_range@dots{}
7389         'string'@dots{}
7390
7391 num_or_range takes one of the following forms:
7392         number
7393         num1 TO num2
7394 @end display
7395
7396 @cmd{DO REPEAT} repeats a block of code, textually substituting
7397 different variables, numbers, or strings into the block with each
7398 repetition.
7399
7400 Specify a repeat variable name followed by an equals sign (@samp{=}) and
7401 the list of replacements.  Replacements can be a list of variables
7402 (which may be existing variables or new variables or a combination
7403 thereof), of numbers, or of strings.  When new variable names are
7404 specified, @cmd{DO REPEAT} creates them as numeric variables.  When numbers
7405 are specified, runs of integers may be indicated with TO notation, for
7406 instance @samp{1 TO 5} and @samp{1 2 3 4 5} would be equivalent.  There
7407 is no equivalent notation for string values.
7408
7409 Multiple repeat variables can be specified.  When this is done, each
7410 variable must have the same number of replacements.
7411
7412 The code within @cmd{DO REPEAT} is repeated as many times as there are
7413 replacements for each variable.  The first time, the first value for
7414 each repeat variable is substituted; the second time, the second value
7415 for each repeat variable is substituted; and so on.
7416
7417 Repeat variable substitutions work like macros.  They take place
7418 anywhere in a line that the repeat variable name occurs as a token,
7419 including command and subcommand names.  For this reason it is not a
7420 good idea to select words commonly used in command and subcommand names
7421 as repeat variable identifiers.
7422
7423 If PRINT is specified on @cmd{END REPEAT}, the commands after substitutions
7424 are made are printed to the listing file, prefixed by a plus sign
7425 (@samp{+}).
7426
7427 @node LOOP,  , DO REPEAT, Conditionals and Looping
7428 @section LOOP
7429 @vindex LOOP
7430
7431 @display
7432 LOOP [index_var=start TO end [BY incr]] [IF condition].
7433         @dots{}
7434 END LOOP [IF condition].
7435 @end display
7436
7437 @cmd{LOOP} iterates a group of commands.  A number of
7438 termination options are offered.
7439
7440 Specify index_var to make that variable count from one value to
7441 another by a particular increment.  index_var must be a pre-existing
7442 numeric variable.  start, end, and incr are numeric expressions
7443 (@pxref{Expressions}.)  
7444
7445 During the first iteration, index_var is set to the value of start.
7446 During each successive iteration, index_var is increased by the value of
7447 incr.  If end > start, then the loop terminates when index_var > end;
7448 otherwise it terminates when index_var < end.  If incr is not specified
7449 then it defaults to +1 or -1 as appropriate.
7450
7451 If end > start and incr < 0, or if end < start and incr > 0, then the
7452 loop is never executed.  index_var is nevertheless set to the value of
7453 start.
7454
7455 Modifying index_var within the loop is allowed, but it has no effect on
7456 the value of index_var in the next iteration.
7457
7458 Specify a boolean expression for the condition on @cmd{LOOP} to
7459 cause the loop to be executed only if the condition is true.  If the
7460 condition is false or missing before the loop contents are executed the
7461 first time, the loop contents are not executed at all.
7462
7463 If index and condition clauses are both present on @cmd{LOOP}, the index
7464 clause is always evaluated first.
7465
7466 Specify a boolean expression for the condition on @cmd{END LOOP} to cause
7467 the loop to terminate if the condition is not true after the enclosed
7468 code block is executed.  The condition is evaluated at the end of the
7469 loop, not at the beginning.
7470
7471 If the index clause and both condition clauses are not present, then the
7472 loop is executed MXLOOPS (@pxref{SET}) times.
7473
7474 @cmd{BREAK} also terminates @cmd{LOOP} execution (@pxref{BREAK}).
7475
7476 When @cmd{LOOP} or @cmd{END LOOP} is specified following @cmd{TEMPORARY}
7477 (@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
7478 (@pxref{LAG}).
7479
7480 @node Statistics, Utilities, Conditionals and Looping, Top
7481 @chapter Statistics
7482
7483 This chapter documents the statistical procedures that PSPP supports so
7484 far.
7485
7486 @menu
7487 * DESCRIPTIVES::                Descriptive statistics.
7488 * FREQUENCIES::                 Frequency tables.
7489 * CROSSTABS::                   Crosstabulation tables.
7490 * T-TEST::                      Test Hypotheses about means.
7491 @end menu
7492
7493 @node DESCRIPTIVES, FREQUENCIES, Statistics, Statistics
7494 @section DESCRIPTIVES
7495
7496 @vindex DESCRIPTIVES
7497 @display
7498 DESCRIPTIVES
7499         /VARIABLES=var_list
7500         /MISSING=@{VARIABLE,LISTWISE@} @{INCLUDE,NOINCLUDE@}
7501         /FORMAT=@{LABELS,NOLABELS@} @{NOINDEX,INDEX@} @{LINE,SERIAL@}
7502         /SAVE
7503         /STATISTICS=@{ALL,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,
7504                      SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,DEFAULT,
7505                      SESKEWNESS,SEKURTOSIS@}
7506         /SORT=@{NONE,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,SKEWNESS,
7507                RANGE,MINIMUM,MAXIMUM,SUM,SESKEWNESS,SEKURTOSIS,NAME@}
7508               @{A,D@}
7509 @end display
7510
7511 The @cmd{DESCRIPTIVES} procedure reads the active file and outputs
7512 descriptive
7513 statistics requested by the user.  In addition, it can optionally
7514 compute Z-scores.
7515
7516 The VARIABLES subcommand, which is required, specifies the list of
7517 variables to be analyzed.  Keyword VARIABLES is optional.
7518
7519 All other subcommands are optional:
7520
7521 The MISSING subcommand determines the handling of missing variables.  If
7522 INCLUDE is set, then user-missing values are included in the
7523 calculations.  If NOINCLUDE is set, which is the default, user-missing
7524 values are excluded.  If VARIABLE is set, then missing values are
7525 excluded on a variable by variable basis; if LISTWISE is set, then
7526 the entire case is excluded whenever any value in that case has a
7527 system-missing or, if INCLUDE is set, user-missing value.
7528
7529 The FORMAT subcommand affects the output format.  Currently the
7530 LABELS/NOLABELS and NOINDEX/INDEX settings are not used.  When SERIAL is
7531 set, both valid and missing number of cases are listed in the output;
7532 when NOSERIAL is set, only valid cases are listed.
7533
7534 The SAVE subcommand causes @cmd{DESCRIPTIVES} to calculate Z scores for all
7535 the specified variables.  The Z scores are saved to new variables.
7536 Variable names are generated by trying first the original variable name
7537 with Z prepended and truncated to a maximum of 8 characters, then the
7538 names ZSC000 through ZSC999, STDZ00 through STDZ09, ZZZZ00 through
7539 ZZZZ09, ZQZQ00 through ZQZQ09, in that sequence.  In addition, Z score
7540 variable names can be specified explicitly on VARIABLES in the variable
7541 list by enclosing them in parentheses after each variable.
7542
7543 The STATISTICS subcommand specifies the statistics to be displayed:
7544
7545 @table @code
7546 @item ALL
7547 All of the statistics below.
7548 @item MEAN
7549 Arithmetic mean.
7550 @item SEMEAN
7551 Standard error of the mean.
7552 @item STDDEV
7553 Standard deviation.
7554 @item VARIANCE
7555 Variance.
7556 @item KURTOSIS
7557 Kurtosis and standard error of the kurtosis.
7558 @item SKEWNESS
7559 Skewness and standard error of the skewness.
7560 @item RANGE
7561 Range.
7562 @item MINIMUM
7563 Minimum value.
7564 @item MAXIMUM
7565 Maximum value.
7566 @item SUM
7567 Sum.
7568 @item DEFAULT
7569 Mean, standard deviation of the mean, minimum, maximum.
7570 @item SEKURTOSIS
7571 Standard error of the kurtosis.
7572 @item SESKEWNESS
7573 Standard error of the skewness.
7574 @end table
7575
7576 The SORT subcommand specifies how the statistics should be sorted.  Most
7577 of the possible values should be self-explanatory.  NAME causes the
7578 statistics to be sorted by name.  By default, the statistics are listed
7579 in the order that they are specified on the VARIABLES subcommand.  The A
7580 and D settings request an ascending or descending sort order,
7581 respectively.
7582
7583 @node FREQUENCIES, CROSSTABS, DESCRIPTIVES, Statistics
7584 @section FREQUENCIES
7585
7586 @vindex FREQUENCIES
7587 @display
7588 FREQUENCIES
7589         /VARIABLES=var_list
7590         /FORMAT=@{TABLE,NOTABLE,LIMIT(limit)@}
7591                 @{STANDARD,CONDENSE,ONEPAGE[(onepage_limit)]@}
7592                 @{LABELS,NOLABELS@}
7593                 @{AVALUE,DVALUE,AFREQ,DFREQ@}
7594                 @{SINGLE,DOUBLE@}
7595                 @{OLDPAGE,NEWPAGE@}
7596         /MISSING=@{EXCLUDE,INCLUDE@}
7597         /STATISTICS=@{DEFAULT,MEAN,SEMEAN,MEDIAN,MODE,STDDEV,VARIANCE,
7598                      KURTOSIS,SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,
7599                      SESKEWNESS,SEKURTOSIS,ALL,NONE@}
7600         /NTILES=ntiles
7601         /PERCENTILES=percent@dots{}
7602
7603 (These options are not currently implemented.)
7604         /BARCHART=@dots{}
7605         /HISTOGRAM=@dots{}
7606         /HBAR=@dots{}
7607         /GROUPED=@dots{}
7608
7609 (Integer mode.)
7610         /VARIABLES=var_list (low,high)@dots{}
7611 @end display
7612
7613 The @cmd{FREQUENCIES} procedure outputs frequency tables for specified
7614 variables.
7615 @cmd{FREQUENCIES} can also calculate and display descriptive statistics
7616 (including median and mode) and percentiles.
7617
7618 In the future, @cmd{FREQUENCIES} will also support graphical output in the
7619 form of bar charts and histograms.  In addition, it will be able to
7620 support percentiles for grouped data.
7621
7622 The VARIABLES subcommand is the only required subcommand.  Specify the
7623 variables to be analyzed.  In most cases, this is all that is required.
7624 This is known as @dfn{general mode}.
7625
7626 Occasionally, one may want to invoke a special mode called @dfn{integer
7627 mode}.  Normally, in general mode, PSPP will automatically determine
7628 what values occur in the data.  In integer mode, the user specifies the
7629 range of values that the data assumes.  To invoke this mode, specify a
7630 range of data values in parentheses, separated by a comma.  Data values
7631 inside the range are truncated to the nearest integer, then assigned to
7632 that value.  If values occur outside this range, they are discarded.
7633
7634 The FORMAT subcommand controls the output format.  It has several
7635 possible settings:  
7636
7637 @itemize @bullet
7638 @item
7639 TABLE, the default, causes a frequency table to be output for every
7640 variable specified.  NOTABLE prevents them from being output.  LIMIT
7641 with a numeric argument causes them to be output except when there are
7642 more than the specified number of values in the table.
7643
7644 @item
7645 STANDARD frequency tables contain more complete information, but also to
7646 take up more space on the printed page.  CONDENSE frequency tables are
7647 less informative but take up less space.  ONEPAGE with a numeric
7648 argument will output standard frequency tables if there are the
7649 specified number of values or less, condensed tables otherwise.  ONEPAGE
7650 without an argument defaults to a threshold of 50 values.
7651
7652 @item
7653 LABELS causes value labels to be displayed in STANDARD frequency
7654 tables.  NOLABLES prevents this.
7655
7656 @item
7657 Normally frequency tables are sorted in ascending order by value.  This
7658 is AVALUE.  DVALUE tables are sorted in descending order by value.
7659 AFREQ and DFREQ tables are sorted in ascending and descending order,
7660 respectively, by frequency count.
7661
7662 @item
7663 SINGLE spaced frequency tables are closely spaced.  DOUBLE spaced
7664 frequency tables have wider spacing.
7665
7666 @item
7667 OLDPAGE and NEWPAGE are not currently used.
7668 @end itemize
7669
7670 The MISSING subcommand controls the handling of user-missing values.
7671 When EXCLUDE, the default, is set, user-missing values are not included
7672 in frequency tables or statistics.  When INCLUDE is set, user-missing
7673 are included.  System-missing values are never included in statistics,
7674 but are listed in frequency tables.
7675
7676 The available STATISTICS are the same as available in @cmd{DESCRIPTIVES}
7677 (@pxref{DESCRIPTIVES}), with the addition of MEDIAN, the data's median
7678 value, and MODE, the mode.  (If there are multiple modes, the smallest
7679 value is reported.)  By default, the mean, standard deviation of the
7680 mean, minimum, and maximum are reported for each variable.
7681
7682 PERCENTILES causes the specified percentiles to be reported.
7683 The percentiles should  be presented at a list of numbers between 0
7684 and 100 inclusive.  
7685 The NTILES subcommand causes the percentiles to be reported at the
7686 boundaries of the data set divided into the specified number of ranges.
7687 For instance, @code{/NTILES=4} would cause quartiles to be reported.
7688
7689
7690 @node CROSSTABS, T-TEST, FREQUENCIES, Statistics
7691 @section CROSSTABS
7692
7693 @vindex CROSSTABS
7694 @display
7695 CROSSTABS
7696         /TABLES=var_list BY var_list [BY var_list]@dots{}
7697         /MISSING=@{TABLE,INCLUDE,REPORT@}
7698         /WRITE=@{NONE,CELLS,ALL@}
7699         /FORMAT=@{TABLES,NOTABLES@}
7700                 @{LABELS,NOLABELS,NOVALLABS@}
7701                 @{PIVOT,NOPIVOT@}
7702                 @{AVALUE,DVALUE@}
7703                 @{NOINDEX,INDEX@}
7704                 @{BOX,NOBOX@}
7705         /CELLS=@{COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
7706                 ASRESIDUAL,ALL,NONE@}
7707         /STATISTICS=@{CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
7708                      KAPPA,ETA,CORR,ALL,NONE@}
7709         
7710 (Integer mode.)
7711         /VARIABLES=var_list (low,high)@dots{}
7712 @end display
7713
7714 The @cmd{CROSSTABS} procedure displays crosstabulation
7715 tables requested by the user.  It can calculate several statistics for
7716 each cell in the crosstabulation tables.  In addition, a number of
7717 statistics can be calculated for each table itself.
7718
7719 The TABLES subcommand is used to specify the tables to be reported.  Any
7720 number of dimensions is permitted, and any number of variables per
7721 dimension is allowed.  The TABLES subcommand may be repeated as many
7722 times as needed.  This is the only required subcommand in @dfn{general
7723 mode}.  
7724
7725 Occasionally, one may want to invoke a special mode called @dfn{integer
7726 mode}.  Normally, in general mode, PSPP automatically determines
7727 what values occur in the data.  In integer mode, the user specifies the
7728 range of values that the data assumes.  To invoke this mode, specify the
7729 VARIABLES subcommand, giving a range of data values in parentheses for
7730 each variable to be used on the TABLES subcommand.  Data values inside
7731 the range are truncated to the nearest integer, then assigned to that
7732 value.  If values occur outside this range, they are discarded.  When it
7733 is present, the VARIABLES subcommand must precede the TABLES
7734 subcommand.
7735
7736 In general mode, numeric and string variables may be specified on
7737 TABLES.  Although long string variables are allowed, only their
7738 initial short-string parts are used.  In integer mode, only numeric
7739 variables are allowed.
7740
7741 The MISSING subcommand determines the handling of user-missing values.
7742 When set to TABLE, the default, missing values are dropped on a table by
7743 table basis.  When set to INCLUDE, user-missing values are included in
7744 tables and statistics.  When set to REPORT, which is allowed only in
7745 integer mode, user-missing values are included in tables but marked with
7746 an @samp{M} (for ``missing'') and excluded from statistical
7747 calculations.
7748
7749 Currently the WRITE subcommand is ignored.
7750
7751 The FORMAT subcommand controls the characteristics of the
7752 crosstabulation tables to be displayed.  It has a number of possible
7753 settings:
7754
7755 @itemize @bullet
7756 @item
7757 TABLES, the default, causes crosstabulation tables to be output.
7758 NOTABLES suppresses them.
7759
7760 @item
7761 LABELS, the default, allows variable labels and value labels to appear
7762 in the output.  NOLABELS suppresses them.  NOVALLABS displays variable
7763 labels but suppresses value labels.
7764
7765 @item
7766 PIVOT, the default, causes each TABLES subcommand to be displayed in a
7767 pivot table format.  NOPIVOT causes the old-style crosstabulation format
7768 to be used.
7769
7770 @item
7771 AVALUE, the default, causes values to be sorted in ascending order.
7772 DVALUE asserts a descending sort order.
7773
7774 @item
7775 INDEX/NOINDEX is currently ignored.
7776
7777 @item
7778 BOX/NOBOX is currently ignored.
7779 @end itemize
7780
7781 The CELLS subcommand controls the contents of each cell in the displayed
7782 crosstabulation table.  The possible settings are:
7783
7784 @table @asis
7785 @item COUNT
7786 Frequency count.
7787 @item ROW
7788 Row percent.
7789 @item COLUMN
7790 Column percent.
7791 @item TOTAL
7792 Table percent.
7793 @item EXPECTED
7794 Expected value.
7795 @item RESIDUAL 
7796 Residual.
7797 @item SRESIDUAL
7798 Standardized residual.
7799 @item ASRESIDUAL
7800 Adjusted standardized residual.
7801 @item ALL
7802 All of the above.
7803 @item NONE
7804 Suppress cells entirely.
7805 @end table
7806
7807 @samp{/CELLS} without any settings specified requests COUNT, ROW,
7808 COLUMN, and TOTAL.  If CELLS is not specified at all then only COUNT
7809 will be selected.
7810
7811 The STATISTICS subcommand selects statistics for computation:
7812
7813 @table @asis
7814 @item CHISQ
7815 Pearson chi-square, likelihood ratio, Fisher's exact test, continuity
7816 correction, linear-by-linear association.
7817 @item PHI
7818 Phi.
7819 @item CC
7820 Contingency coefficient.
7821 @item LAMBDA
7822 Lambda.
7823 @item UC
7824 Uncertainty coefficient.
7825 @item BTAU
7826 Tau-b.
7827 @item CTAU
7828 Tau-c.
7829 @item RISK
7830 Risk estimate.
7831 @item GAMMA
7832 Gamma.
7833 @item D
7834 Somers' D.
7835 @item KAPPA
7836 Cohen's Kappa.
7837 @item ETA
7838 Eta.
7839 @item CORR
7840 Spearman correlation, Pearson's r.
7841 @item ALL
7842 All of the above.
7843 @item NONE
7844 No statistics.
7845 @end table
7846
7847 Selected statistics are only calculated when appropriate for the
7848 statistic.  Certain statistics require tables of a particular size, and
7849 some statistics are calculated only in integer mode.
7850
7851 @samp{/STATISTICS} without any settings selects CHISQ.  If the
7852 STATISTICS subcommand is not given, no statistics are calculated.
7853
7854 @strong{Please note:} Currently the implementation of CROSSTABS has the
7855 followings bugs:
7856
7857 @itemize @bullet
7858 @item
7859 Pearson's R (but not Spearman) is off a little.
7860 @item
7861 T values for Spearman's R and Pearson's R are wrong.
7862 @item
7863 Significance of symmetric and directional measures is not calculated.
7864 @item
7865 Asymmetric ASEs and T values for lambda are wrong.
7866 @item
7867 ASE of Goodman and Kruskal's tau is not calculated.
7868 @item
7869 ASE of symmetric somers' d is wrong.
7870 @item
7871 Approximate T of uncertainty coefficient is wrong.
7872 @end itemize
7873
7874 Fixes for any of these deficiencies would be welcomed.
7875
7876 @node T-TEST,  , CROSSTABS, Statistics
7877 @comment  node-name,  next,  previous,  up
7878 @section T-TEST
7879
7880 @vindex T-TEST
7881 @display
7882 T-TEST
7883         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
7884         /CRITERIA=CIN(confidence)
7885
7886
7887 (One Sample mode.)
7888         TESTVAL=test_value
7889         /VARIABLES=var_list
7890
7891
7892 (Independent Samples mode.)
7893         GROUPS=var(value1 [, value2])
7894         /VARIABLES=var_list
7895
7896
7897 (Paired Samples mode.)
7898         PAIRS=var_list [WITH var_list [(PAIRED)] ]
7899
7900 @end display
7901
7902
7903 The @cmd{T-TEST} procedure outputs tables used in testing hypotheses about 
7904 means.  
7905 It operates in one of three modes:
7906 @itemize
7907 @item One Sample mode.
7908 @item Independent Groups mode.
7909 @item Paired mode.
7910 @end itemize
7911
7912 @noindent
7913 Each of these modes are described in more detail below.
7914 There are two optional subcommands which are common to all modes.
7915
7916 The @cmd{/CRITERIA} subcommand tells PSPP the confidence interval used
7917 in the tests.  The default value is 0.95.
7918
7919
7920 The @cmd{MISSING} subcommand determines the handling of missing
7921 variables.  
7922 If INCLUDE is set, then user-missing values are included in the
7923 calculations, but system-missing values are not.
7924 If EXCLUDE is set, which is the default, user-missing
7925 values are excluded as well as system-missing values. 
7926 This is the default.
7927
7928 If LISTWISE is set, then the entire case is excluded from analysis
7929 whenever any variable  specified in the @cmd{/VARIABLES}, @cmd{/PAIRS} or 
7930 @cmd{/GROUPS} subcommands contains a missing value.   
7931 If ANALYSIS is set, then missing values are excluded only in the analysis for
7932 which they would be needed. This is the default.
7933
7934
7935 @menu
7936 * One Sample Mode::             Testing against a hypothesised mean
7937 * Independent Samples Mode::    Testing two independent groups for equal mean
7938 * Paired Samples Mode::         Testing two interdependent groups for equal mean
7939 @end menu
7940
7941 @node One Sample Mode, Independent Samples Mode, T-TEST, T-TEST
7942 @subsection One Sample Mode
7943
7944 The @cmd{TESTVAL} subcommand invokes the One Sample mode.
7945 This mode is used to test a population mean against a hypothesised
7946 mean. 
7947 The value given to the @cmd{TESTVAL} subcommand is the value against
7948 which you wish to test.
7949 In this mode, you must also use the @cmd{/VARIABLES} subcommand to
7950 tell PSPP which variables you wish to test.
7951
7952 @node Independent Samples Mode, Paired Samples Mode, One Sample Mode, T-TEST
7953 @comment  node-name,  next,  previous,  up
7954 @subsection Independent Samples Mode
7955
7956 The @cmd{GROUPS} subcommand invokes Independent Samples mode or
7957 `Groups' mode. 
7958 This mode is used to test whether two groups of values have the
7959 same population mean.
7960 In this mode, you must also use the @cmd{/VARIABLES} subcommand to
7961 tell PSPP the dependent variables you wish to test.
7962
7963 The variable given in the @cmd{GROUPS} subcommand is the independent
7964 variable which determines to which group the samples belong.
7965 The values in parentheses are the specific values of the independent
7966 variable for each group.
7967 If the parentheses are omitted and no values are given, the default values 
7968 of 1.0 and 2.0 are assumed.
7969
7970 If the independent variable is numeric, 
7971 it is acceptable to specify only one value inside the parentheses.
7972 If you do this, cases where the independent variable is
7973 less than  or equal to this value belong to the first group, and cases
7974 greater than this value belong to the second group.
7975 When using this form of the @cmd{GROUPS} subcommand, missing values in
7976 the independent variable are excluded on a listwise basis, regardless
7977 of whether @cmd{/MISSING=LISTWISE} was specified.
7978
7979
7980 @node Paired Samples Mode,  , Independent Samples Mode, T-TEST
7981 @comment  node-name,  next,  previous,  up
7982 @subsection Paired Samples Mode
7983
7984 The @cmd{PAIRS} subcommand introduces Paired Samples mode.
7985 Use this mode when repeated measures have been taken from the same
7986 samples.
7987 If the the @code{WITH} keyword is omitted, then tables for all
7988 combinations of variables given in the @cmd{PAIRS} subcommand are
7989 generated. 
7990 If the @code{WITH} keyword is given, and the @code{(PAIRED)} keyword
7991 is also given, then the number of variables preceding @code{WITH}
7992 must be the same as the number following it.
7993 In this case, tables for each respective pair of variables are
7994 generated.
7995 In the event that the @code{WITH} keyword is given, but the
7996 @code{(PAIRED)} keyword is omitted, then tables for each combination
7997 of variable preceding @code{WITH} against variable following
7998 @code{WITH} are generated.
7999
8000
8001 @node Utilities, Not Implemented, Statistics, Top
8002 @chapter Utilities
8003
8004 Commands that don't fit any other category are placed here.
8005
8006 Most of these commands are not affected by commands like @cmd{IF} and
8007 @cmd{LOOP}:
8008 they take effect only once, unconditionally, at the time that they are
8009 encountered in the input.
8010
8011 @menu
8012 * COMMENT::                     Document your syntax file.
8013 * DOCUMENT::                    Document the active file.
8014 * DISPLAY DOCUMENTS::           Display active file documents.
8015 * DISPLAY FILE LABEL::          Display the active file label.
8016 * DROP DOCUMENTS::              Remove documents from the active file.
8017 * ERASE::                       Erase a file.
8018 * EXECUTE::                     Execute pending transformations.
8019 * FILE LABEL::                  Set the active file's label.
8020 * FINISH::                      Terminate the PSPP session.
8021 * HOST::                        Temporarily return to the operating system.
8022 * INCLUDE::                     Include a file within the current one.
8023 * QUIT::                        Terminate the PSPP session.
8024 * SET::                         Adjust PSPP runtime parameters.
8025 * SHOW::                        Display runtime parameters.
8026 * SUBTITLE::                    Provide a document subtitle.
8027 * TITLE::                       Provide a document title.
8028 @end menu
8029
8030 @node COMMENT, DOCUMENT, Utilities, Utilities
8031 @section COMMENT
8032 @vindex COMMENT
8033 @vindex *
8034
8035 @display 
8036 Two possibles syntaxes:
8037         COMMENT comment text @dots{} .
8038         *comment text @dots{} .
8039 @end display
8040
8041 @cmd{COMMENT} is ignored.  It is used to provide information to
8042 the author and other readers of the PSPP syntax file.  
8043
8044 @cmd{COMMENT} can extend over any number of lines.  Don't forget to
8045 terminate it with a dot or a blank line.
8046
8047 @node DOCUMENT, DISPLAY DOCUMENTS, COMMENT, Utilities
8048 @section DOCUMENT
8049 @vindex DOCUMENT
8050
8051 @display
8052 DOCUMENT documentary_text.
8053 @end display
8054
8055 @cmd{DOCUMENT} adds one or more lines of descriptive commentary to the
8056 active file.  Documents added in this way are saved to system files.
8057 They can be viewed using @cmd{SYSFILE INFO} or @cmd{DISPLAY
8058 DOCUMENTS}.  They can be removed from the active file with @cmd{DROP
8059 DOCUMENTS}.
8060
8061 Specify the documentary text following the DOCUMENT keyword.  You can
8062 extend the documentary text over as many lines as necessary.  Lines are
8063 truncated at 80 characters width.  Don't forget to terminate
8064 the command with a dot or a blank line.
8065
8066 @node DISPLAY DOCUMENTS, DISPLAY FILE LABEL, DOCUMENT, Utilities
8067 @section DISPLAY DOCUMENTS
8068 @vindex DISPLAY DOCUMENTS
8069
8070 @display
8071 DISPLAY DOCUMENTS.
8072 @end display
8073
8074 @cmd{DISPLAY DOCUMENTS} displays the documents in the active file.  Each
8075 document is preceded by a line giving the time and date that it was
8076 added.  @xref{DOCUMENT}.
8077
8078 @node DISPLAY FILE LABEL, DROP DOCUMENTS, DISPLAY DOCUMENTS, Utilities
8079 @section DISPLAY FILE LABEL
8080 @vindex DISPLAY FILE LABEL
8081
8082 @display
8083 DISPLAY FILE LABEL.
8084 @end display
8085
8086 @cmd{DISPLAY FILE LABEL} displays the file label contained in the
8087 active file,
8088 if any.  @xref{FILE LABEL}.
8089
8090 @node DROP DOCUMENTS, ERASE, DISPLAY FILE LABEL, Utilities
8091 @section DROP DOCUMENTS
8092 @vindex DROP DOCUMENTS
8093
8094 @display
8095 DROP DOCUMENTS.
8096 @end display
8097
8098 @cmd{DROP DOCUMENTS} removes all documents from the active file.
8099 New documents can be added with @cmd{DOCUMENT} (@pxref{DOCUMENT}).
8100
8101 @cmd{DROP DOCUMENTS} changes only the active file.  It does not modify any
8102 system files stored on disk.
8103
8104
8105 @node ERASE, EXECUTE, DROP DOCUMENTS, Utilities
8106 @comment  node-name,  next,  previous,  up
8107 @section ERASE
8108 @vindex ERASE
8109
8110 @display
8111 ERASE FILE file_name.
8112 @end display
8113
8114 @cmd{ERASE FILE} deletes a file from the local filesystem.
8115 file_name must be quoted.
8116 This command cannot be used if the SAFER setting is active.
8117
8118
8119 @node EXECUTE, FILE LABEL, ERASE, Utilities
8120 @section EXECUTE
8121 @vindex EXECUTE
8122
8123 @display
8124 EXECUTE.
8125 @end display
8126
8127 @cmd{EXECUTE} causes the active file to be read and all pending
8128 transformations to be executed.
8129
8130 @node FILE LABEL, FINISH, EXECUTE, Utilities
8131 @section FILE LABEL
8132 @vindex FILE LABEL
8133
8134 @display
8135 FILE LABEL file_label.
8136 @end display
8137
8138 @cmd{FILE LABEL} provides a title for the active file.  This
8139 title will be saved into system files and portable files that are
8140 created during this PSPP run.
8141
8142 file_label need not be quoted.  If quotes are
8143 included, they become part of the file label.
8144
8145 @node FINISH, HOST, FILE LABEL, Utilities
8146 @section FINISH
8147 @vindex FINISH
8148
8149 @display
8150 FINISH.
8151 @end display
8152
8153 @cmd{FINISH} terminates the current PSPP session and returns
8154 control to the operating system.
8155
8156 This command is not valid in interactive mode.
8157
8158 @node HOST, INCLUDE, FINISH, Utilities
8159 @comment  node-name,  next,  previous,  up
8160 @section HOST
8161 @vindex HOST
8162
8163 @display
8164 HOST.
8165 @end display
8166
8167 @cmd{HOST} suspends the current PSPP session and temporarily returns control 
8168 to the operating system.
8169 This command cannot be used if the SAFER setting is active.
8170
8171
8172 @node INCLUDE, QUIT, HOST, Utilities
8173 @section INCLUDE
8174 @vindex INCLUDE
8175 @vindex @@
8176
8177 @display
8178 Two possible syntaxes:
8179         INCLUDE 'filename'.
8180         @@filename.
8181 @end display
8182
8183 @cmd{INCLUDE} causes the PSPP command processor to read an
8184 additional command file as if it were included bodily in the current
8185 command file.
8186
8187 Include files may be nested to any depth, up to the limit of available
8188 memory.
8189
8190 @node QUIT, SET, INCLUDE, Utilities
8191 @section QUIT
8192 @vindex QUIT
8193
8194 @display
8195 Two possible syntaxes:
8196         QUIT.
8197         EXIT.
8198 @end display
8199
8200 @cmd{QUIT} terminates the current PSPP session and returns control
8201 to the operating system.  
8202
8203 This command is not valid within a command file.
8204
8205 @node SET, SHOW, QUIT, Utilities
8206 @section SET
8207 @vindex SET
8208
8209 @display
8210 SET
8211
8212 (data input)
8213         /BLANKS=@{SYSMIS,'.',number@}
8214         /DECIMAL=@{DOT,COMMA@}
8215         /FORMAT=fmt_spec
8216
8217 (program input)
8218         /ENDCMD='.'
8219         /NULLINE=@{ON,OFF@}
8220
8221 (interaction)
8222         /CPROMPT='cprompt_string'
8223         /DPROMPT='dprompt_string'
8224         /ERRORBREAK=@{OFF,ON@}
8225         /MXERRS=max_errs
8226         /MXWARNS=max_warnings
8227         /PROMPT='prompt'
8228         /VIEWLENGTH=@{MINIMUM,MEDIAN,MAXIMUM,n_lines@}
8229         /VIEWWIDTH=n_characters
8230
8231 (program execution)
8232         /MEXPAND=@{ON,OFF@}
8233         /MITERATE=max_iterations
8234         /MNEST=max_nest
8235         /MPRINT=@{ON,OFF@}
8236         /MXLOOPS=max_loops
8237         /SEED=@{RANDOM,seed_value@}
8238         /UNDEFINED=@{WARN,NOWARN@}
8239
8240 (data output)
8241         /CC@{A,B,C,D,E@}=@{'npre,pre,suf,nsuf','npre.pre.suf.nsuf'@}
8242         /DECIMAL=@{DOT,COMMA@}
8243         /FORMAT=fmt_spec
8244
8245 (output routing)
8246         /ECHO=@{ON,OFF@}
8247         /ERRORS=@{ON,OFF,TERMINAL,LISTING,BOTH,NONE@}
8248         /INCLUDE=@{ON,OFF@}
8249         /MESSAGES=@{ON,OFF,TERMINAL,LISTING,BOTH,NONE@}
8250         /PRINTBACK=@{ON,OFF@}
8251         /RESULTS=@{ON,OFF,TERMINAL,LISTING,BOTH,NONE@}
8252
8253 (output activation)
8254         /LISTING=@{ON,OFF@}
8255         /PRINTER=@{ON,OFF@}
8256         /SCREEN=@{ON,OFF@}
8257
8258 (output driver options)
8259         /HEADERS=@{NO,YES,BLANK@}
8260         /LENGTH=@{NONE,length_in_lines@}
8261         /LISTING=filename
8262         /MORE=@{ON,OFF@}
8263         /PAGER=@{OFF,"pager_name"@}
8264         /WIDTH=@{NARROW,WIDTH,n_characters@}
8265
8266 (logging)
8267         /JOURNAL=@{ON,OFF@} [filename]
8268         /LOG=@{ON,OFF@} [filename]
8269
8270 (system files)
8271         /COMPRESSION=@{ON,OFF@}
8272         /SCOMPRESSION=@{ON,OFF@}
8273
8274 (security)
8275         /SAFER=ON
8276
8277 (obsolete settings accepted for compatibility, but ignored)
8278         /AUTOMENU=@{ON,OFF@}
8279         /BEEP=@{ON,OFF@}
8280         /BLOCK='c'
8281         /BOXSTRING=@{'xxx','xxxxxxxxxxx'@}
8282         /CASE=@{UPPER,UPLOW@}
8283         /COLOR=@dots{}
8284         /CPI=cpi_value
8285         /DISK=@{ON,OFF@}
8286         /EJECT=@{ON,OFF@}
8287         /HELPWINDOWS=@{ON,OFF@}
8288         /HIGHRES=@{ON,OFF@}
8289         /HISTOGRAM='c'
8290         /LOWRES=@{AUTO,ON,OFF@}
8291         /LPI=lpi_value
8292         /MENUS=@{STANDARD,EXTENDED@}
8293         /MXMEMORY=max_memory
8294         /PTRANSLATE=@{ON,OFF@}
8295         /RCOLORS=@dots{}
8296         /RUNREVIEW=@{AUTO,MANUAL@}
8297         /SCRIPTTAB='c'
8298         /TB1=@{'xxx','xxxxxxxxxxx'@}
8299         /TBFONTS='string'
8300         /WORKDEV=drive_letter
8301         /WORKSPACE=workspace_size
8302         /XSORT=@{YES,NO@}
8303 @end display
8304
8305 @cmd{SET} allows the user to adjust several parameters relating to
8306 PSPP's execution.  Since there are many subcommands to this command, its
8307 subcommands will be examined in groups.
8308
8309 On subcommands that take boolean values, ON and YES are synonym, and
8310 as are OFF and NO, when used as subcommand values.
8311
8312 The data input subcommands affect the way that data is read from data
8313 files.  The data input subcommands are
8314
8315 @table @asis
8316 @item BLANKS
8317 This is the value assigned to an item data item that is empty or
8318 contains only whitespace.  An argument of SYSMIS or '.' will cause the
8319 system-missing value to be assigned to null items.  This is the
8320 default.  Any real value may be assigned.
8321
8322 @item DECIMAL
8323 The default DOT setting causes the decimal point character to be
8324 @samp{.}.  A setting of COMMA causes the decimal point character to be
8325 @samp{,}.
8326
8327 @item FORMAT
8328 Allows the default numeric input/output format to be specified.  The
8329 default is F8.2.  @xref{Input/Output Formats}.
8330 @end table
8331
8332 Program input subcommands affect the way that programs are parsed when
8333 they are typed interactively or run from a script.  They are
8334
8335 @table @asis
8336 @item ENDCMD
8337 This is a single character indicating the end of a command.  The default
8338 is @samp{.}.  Don't change this.
8339
8340 @item NULLINE
8341 Whether a blank line is interpreted as ending the current command.  The
8342 default is ON.
8343 @end table
8344
8345 Interaction subcommands affect the way that PSPP interacts with an
8346 online user.  The interaction subcommands are
8347
8348 @table @asis
8349 @item CPROMPT
8350 The command continuation prompt.  The default is @samp{    > }.
8351
8352 @item DPROMPT
8353 Prompt used when expecting data input within @cmd{BEGIN DATA} (@pxref{BEGIN
8354 DATA}).  The default is @samp{data> }.
8355
8356 @item ERRORBREAK
8357 Whether an error causes PSPP to stop processing the current command
8358 file after finishing the current command.  The default is OFF.
8359
8360 @item MXERRS
8361 The maximum number of errors before PSPP halts processing of the current
8362 command file.  The default is 50.
8363
8364 @item MXWARNS
8365 The maximum number of warnings + errors before PSPP halts processing the
8366 current command file.  The default is 100.
8367
8368 @item PROMPT
8369 The command prompt.  The default is @samp{PSPP> }.
8370
8371 @item VIEWLENGTH
8372 The length of the screen in lines.  MINIMUM means 25 lines, MEDIAN and
8373 MAXIMUM mean 43 lines.  Otherwise specify the number of lines.  Normally
8374 PSPP should auto-detect your screen size so this shouldn't have to be
8375 used.
8376
8377 @item VIEWWIDTH
8378 The width of the screen in characters.  Normally 80 or 132.
8379 @end table
8380
8381 Program execution subcommands control the way that PSPP commands
8382 execute.  The program execution subcommands are
8383
8384 @table @asis
8385 @item MEXPAND
8386 @itemx MITERATE
8387 @itemx MNEST
8388 @itemx MPRINT
8389 Currently not used.
8390
8391 @item MXLOOPS
8392 The maximum number of iterations for an uncontrolled loop (@pxref{LOOP}).
8393
8394 @item SEED
8395 The initial pseudo-random number seed.  Set to a real number or to
8396 RANDOM, which will obtain an initial seed from the current time of day.
8397
8398 @item UNDEFINED
8399 Currently not used.
8400 @end table
8401
8402 Data output subcommands affect the format of output data.  These
8403 subcommands are
8404
8405 @table @asis
8406 @item CCA
8407 @itemx CCB
8408 @itemx CCC
8409 @itemx CCD
8410 @itemx CCE
8411 Set up custom currency formats.  The argument is a string which must
8412 contain exactly three commas or exactly three periods.  If commas, then
8413 the grouping character for the currency format is @samp{,}, and the
8414 decimal point character is @samp{.}; if periods, then the situation is
8415 reversed.  
8416
8417 The commas or periods divide the string into four fields, which are, in
8418 order, the negative prefix, prefix, suffix, and negative suffix.  When a
8419 value is formatted using the custom currency format, the prefix precedes
8420 the value formatted and the suffix follows it.  In addition, if the
8421 value is negative, the negative prefix precedes the prefix and the
8422 negative suffix follows the suffix.
8423
8424 @item DECIMAL
8425 The default DOT setting causes the decimal point character to be
8426 @samp{.}.  A setting of COMMA causes the decimal point character to be
8427 @samp{,}.
8428
8429 @item FORMAT
8430 Allows the default numeric input/output format to be specified.  The
8431 default is F8.2.  @xref{Input/Output Formats}.
8432 @end table
8433
8434 Output routing subcommands affect where the output of transformations
8435 and procedures is sent.  These subcommands are
8436
8437 @table @asis
8438 @item ECHO
8439
8440 If turned on, commands are written to the listing file as they are read
8441 from command files.  The default is OFF.
8442
8443 @itemx ERRORS
8444 @itemx INCLUDE
8445 @itemx MESSAGES
8446 @item PRINTBACK
8447 @item RESULTS
8448 Currently not used.
8449 @end table
8450
8451 Output activation subcommands affect whether output devices of
8452 particular types are enabled.  These subcommands are
8453
8454 @table @asis
8455 @item LISTING
8456 Enable or disable listing devices.
8457
8458 @item PRINTER
8459 Enable or disable printer devices.
8460
8461 @item SCREEN
8462 Enable or disable screen devices.
8463 @end table
8464
8465 Output driver option subcommands affect output drivers' settings.  These
8466 subcommands are
8467
8468 @table @asis
8469 @item HEADERS
8470 @itemx LENGTH
8471 @itemx LISTING
8472 @itemx MORE
8473 @itemx PAGER 
8474 @itemx WIDTH
8475 Currently not used.
8476 @end table
8477
8478 Logging subcommands affect logging of commands executed to external
8479 files.  These subcommands are
8480
8481 @table @asis
8482 @item JOURNAL
8483 @item LOG
8484 Not currently used.
8485 @end table
8486
8487 System file subcommands affect the default format of system files
8488 produced by PSPP.  These subcommands are
8489
8490 @table @asis
8491 @item COMPRESSION
8492 Not currently used.
8493
8494 @item SCOMPRESSION
8495 Whether system files created by @cmd{SAVE} or @cmd{XSAVE} are
8496 compressed by default.  The default is ON.
8497 @end table
8498
8499 Security subcommands affect the operations that commands are allowed to
8500 perform.  The security subcommands are
8501
8502 @table @asis
8503 @item SAFER
8504 When set, this setting cannot ever be reset, for obvious security
8505 reasons.  Setting this option disables the following operations:
8506
8507 @itemize @bullet
8508 @item
8509 The ERASE command.
8510 @item
8511 The HOST command.
8512 @item
8513 Pipe filenames (filenames beginning or ending with @samp{|}).
8514 @end itemize
8515
8516 Be aware that this setting does not guarantee safety (commands can still
8517 overwrite files, for instance) but it is an improvement.
8518 @end table
8519
8520 @node SHOW, SUBTITLE, SET, Utilities
8521 @comment  node-name,  next,  previous,  up
8522 @section SHOW
8523 @vindex SHOW
8524
8525 @display
8526 SHOW
8527         /@var{subcommand}
8528         
8529 @end display
8530
8531 @cmd{SHOW} can be used to display the current state of PSPP's
8532 execution parameters.  All of the parameters which can be changed 
8533 using  @code{SET} @xref{SET}, can be examined using @cmd{SHOW}, by
8534 using a subcommand with the same name.
8535 In addition, @code{SHOW} supports the following subcommands:
8536
8537 @table @code
8538 @item WARRANTY
8539 Show details of the lack of warranty for PSPP.
8540 @item COPYING
8541 Display the terms of PSPP's copyright licence @ref{License}.
8542 @end table
8543
8544
8545
8546 @node SUBTITLE, TITLE, SHOW, Utilities
8547 @section SUBTITLE
8548 @vindex SUBTITLE
8549
8550 @display
8551 SUBTITLE 'subtitle_string'.
8552   or
8553 SUBTITLE subtitle_string.
8554 @end display
8555
8556 @cmd{SUBTITLE} provides a subtitle to a particular PSPP
8557 run.  This subtitle appears at the top of each output page below the
8558 title, if headers are enabled on the output device.
8559
8560 Specify a subtitle as a string in quotes.  The alternate syntax that did
8561 not require quotes is now obsolete.  If it is used then the subtitle is
8562 converted to all uppercase.
8563
8564 @node TITLE,  , SUBTITLE, Utilities
8565 @section TITLE
8566 @vindex TITLE
8567
8568 @display
8569 TITLE 'title_string'.
8570   or
8571 TITLE title_string.
8572 @end display
8573
8574 @cmd{TITLE} provides a title to a particular PSPP run.
8575 This title appears at the top of each output page, if headers are enabled
8576 on the output device.
8577
8578 Specify a title as a string in quotes.  The alternate syntax that did
8579 not require quotes is now obsolete.  If it is used then the title is
8580 converted to all uppercase.
8581
8582 @node Not Implemented, Data File Format, Utilities, Top
8583 @chapter Not Implemented
8584
8585 This chapter lists parts of the PSPP language that are not yet
8586 implemented.
8587
8588 The following transformations and utilities are not yet implemented, but
8589 they will be supported in a later release.
8590
8591 @itemize @bullet
8592 @item
8593 ADD FILES
8594 @item
8595 ANOVA
8596 @item
8597 DEFINE
8598 @item
8599 FILE TYPE
8600 @item
8601 GET SAS
8602 @item
8603 GET TRANSLATE
8604 @item
8605 MCONVERT
8606 @item
8607 PLOT
8608 @item
8609 PRESERVE
8610 @item
8611 PROCEDURE OUTPUT
8612 @item
8613 RESTORE
8614 @item
8615 SAVE TRANSLATE
8616 @item
8617 SHOW
8618 @item
8619 UPDATE
8620 @end itemize
8621
8622 The following transformations and utilities are not implemented.  There
8623 are no plans to support them in future releases.  Contributions to
8624 implement them will still be accepted.
8625
8626 @itemize @bullet
8627 @item
8628 EDIT
8629 @item
8630 GET DATABASE
8631 @item
8632 GET OSIRIS
8633 @item
8634 GET SCSS
8635 @item
8636 GSET
8637 @item
8638 HELP
8639 @item
8640 INFO
8641 @item
8642 INPUT MATRIX
8643 @item
8644 KEYED DATA LIST
8645 @item
8646 NUMBERED and UNNUMBERED
8647 @item
8648 OPTIONS
8649 @item
8650 REVIEW
8651 @item
8652 SAVE SCSS
8653 @item
8654 SPSS MANAGER
8655 @item
8656 STATISTICS
8657 @end itemize
8658
8659 @node Data File Format, Portable File Format, Not Implemented, Top
8660 @chapter Data File Format
8661
8662 PSPP necessarily uses the same format for system files as do the
8663 products with which it is compatible.  This chapter is a description of
8664 that format.
8665
8666 There are three data types used in system files: 32-bit integers, 64-bit
8667 floating points, and 1-byte characters.  In this document these will
8668 simply be referred to as @code{int32}, @code{flt64}, and @code{char},
8669 the names that are used in the PSPP source code.  Every field of type
8670 @code{int32} or @code{flt64} is aligned on a 32-bit boundary.
8671
8672 The endianness of data in PSPP system files is not specified.  System
8673 files output on a computer of a particular endianness will have the
8674 endianness of that computer.  However, PSPP can read files of either
8675 endianness, regardless of its host computer's endianness.  PSPP
8676 translates endianness for both integer and floating point numbers.
8677
8678 Floating point formats are also not specified.  PSPP does not
8679 translate between floating point formats.  This is unlikely to be a
8680 problem as all modern computer architectures use IEEE 754 format for
8681 floating point representation.
8682
8683 The PSPP system-missing value is represented by the largest possible
8684 negative number in the floating point format; in C, this is most likely
8685 @code{-DBL_MAX}.  There are two other important values used in missing
8686 values: @code{HIGHEST} and @code{LOWEST}.  These are represented by the
8687 largest possible positive number (probably @code{DBL_MAX}) and the
8688 second-largest negative number.  The latter must be determined in a
8689 system-dependent manner; in IEEE 754 format it is represented by value
8690 @code{0xffeffffffffffffe}.
8691
8692 System files are divided into records.  Each record begins with an
8693 @code{int32} giving a numeric record type.  Individual record types are
8694 described below:
8695
8696 @menu
8697 * File Header Record::          
8698 * Variable Record::             
8699 * Value Label Record::          
8700 * Value Label Variable Record::  
8701 * Document Record::             
8702 * Machine int32 Info Record::   
8703 * Machine flt64 Info Record::   
8704 * Miscellaneous Informational Records::  
8705 * Dictionary Termination Record::  
8706 * Data Record::                 
8707 @end menu
8708
8709 @node File Header Record, Variable Record, Data File Format, Data File Format
8710 @section File Header Record
8711
8712 The file header is always the first record in the file.
8713
8714 @example
8715 struct sysfile_header
8716   @{
8717     char                rec_type[4];
8718     char                prod_name[60];
8719     int32               layout_code;
8720     int32               case_size;
8721     int32               compressed;
8722     int32               weight_index;
8723     int32               ncases;
8724     flt64               bias;
8725     char                creation_date[9];
8726     char                creation_time[8];
8727     char                file_label[64];
8728     char                padding[3];
8729   @};
8730 @end example
8731
8732 @table @code
8733 @item char rec_type[4];
8734 Record type code.  Always set to @samp{$FL2}.  This is the only record
8735 for which the record type is not of type @code{int32}.
8736
8737 @item char prod_name[60];
8738 Product identification string.  This always begins with the characters
8739 @samp{@@(#) SPSS DATA FILE}.  PSPP uses the remaining characters to
8740 give its version and the operating system name; for example, @samp{GNU
8741 pspp 0.1.4 - sparc-sun-solaris2.5.2}.  The string is truncated if it
8742 would be longer than 60 characters; otherwise it is padded on the right
8743 with spaces.
8744
8745 @item int32 layout_code;
8746 Always set to 2.  PSPP reads this value to determine the
8747 file's endianness.
8748
8749 @item int32 case_size;
8750 Number of data elements per case.  This is the number of variables,
8751 except that long string variables add extra data elements (one for every
8752 8 characters after the first 8).
8753
8754 @item int32 compressed;
8755 Set to 1 if the data in the file is compressed, 0 otherwise.
8756
8757 @item int32 weight_index;
8758 If one of the variables in the data set is used as a weighting variable,
8759 set to the index of that variable.  Otherwise, set to 0.
8760
8761 @item int32 ncases;
8762 Set to the number of cases in the file if it is known, or -1 otherwise.
8763
8764 In the general case it is not possible to determine the number of cases
8765 that will be output to a system file at the time that the header is
8766 written.  The way that this is dealt with is by writing the entire
8767 system file, including the header, then seeking back to the beginning of
8768 the file and writing just the @code{ncases} field.  For `files' in which
8769 this is not valid, the seek operation fails.  In this case,
8770 @code{ncases} remains -1.
8771
8772 @item flt64 bias;
8773 Compression bias.  Always set to 100.  The significance of this value is
8774 that only numbers between @code{(1 - bias)} and @code{(251 - bias)} can
8775 be compressed.
8776
8777 @item char creation_date[9];
8778 Set to the date of creation of the system file, in @samp{dd mmm yy}
8779 format, with the month as standard English abbreviations, using an
8780 initial capital letter and following with lowercase.  If the date is not
8781 available then this field is arbitrarily set to @samp{01 Jan 70}.
8782
8783 @item char creation_time[8];
8784 Set to the time of creation of the system file, in @samp{hh:mm:ss}
8785 format and using 24-hour time.  If the time is not available then this
8786 field is arbitrarily set to @samp{00:00:00}.
8787
8788 @item char file_label[64];
8789 Set the the file label declared by the user, if any.  Padded on the
8790 right with spaces.
8791
8792 @item char padding[3];
8793 Ignored padding bytes to make the structure a multiple of 32 bits in
8794 length.  Set to zeros.
8795 @end table
8796
8797 @node Variable Record, Value Label Record, File Header Record, Data File Format
8798 @section Variable Record
8799
8800 Immediately following the header must come the variable records.  There
8801 must be one variable record for every variable and every 8 characters in
8802 a long string beyond the first 8; i.e., there must be exactly as many
8803 variable records as the value specified for @code{case_size} in the file
8804 header record.
8805
8806 @example
8807 struct sysfile_variable
8808   @{
8809     int32               rec_type;
8810     int32               type;
8811     int32               has_var_label;
8812     int32               n_missing_values;
8813     int32               print;
8814     int32               write;
8815     char                name[8];
8816
8817     /* The following two fields are present 
8818        only if has_var_label is 1. */
8819     int32               label_len;
8820     char                label[/* variable length */];
8821
8822     /* The following field is present only
8823        if n_missing_values is not 0. */
8824     flt64               missing_values[/* variable length*/];
8825   @};
8826 @end example
8827
8828 @table @code
8829 @item int32 rec_type;
8830 Record type code.  Always set to 2.
8831
8832 @item int32 type;
8833 Variable type code.  Set to 0 for a numeric variable.  For a short
8834 string variable or the first part of a long string variable, this is set
8835 to the width of the string.  For the second and subsequent parts of a
8836 long string variable, set to -1, and the remaining fields in the
8837 structure are ignored.
8838
8839 @item int32 has_var_label;
8840 If this variable has a variable label, set to 1; otherwise, set to 0.
8841
8842 @item int32 n_missing_values;
8843 If the variable has no missing values, set to 0.  If the variable has
8844 one, two, or three discrete missing values, set to 1, 2, or 3,
8845 respectively.  If the variable has a range for missing variables, set to
8846 -2; if the variable has a range for missing variables plus a single
8847 discrete value, set to -3.
8848
8849 @item int32 print;
8850 Print format for this variable.  See below.
8851
8852 @item int32 write;
8853 Write format for this variable.  See below.
8854
8855 @item char name[8];
8856 Variable name.  The variable name must begin with a capital letter or
8857 the at-sign (@samp{@@}).  Subsequent characters may also be octothorpes
8858 (@samp{#}), dollar signs (@samp{$}), underscores (@samp{_}), or full
8859 stops (@samp{.}).  The variable name is padded on the right with spaces.
8860
8861 @item int32 label_len;
8862 This field is present only if @code{has_var_label} is set to 1.  It is
8863 set to the length, in characters, of the variable label, which must be a
8864 number between 0 and 120.
8865
8866 @item char label[/* variable length */];
8867 This field is present only if @code{has_var_label} is set to 1.  It has
8868 length @code{label_len}, rounded up to the nearest multiple of 32 bits.
8869 The first @code{label_len} characters are the variable's variable label.
8870
8871 @item flt64 missing_values[/* variable length */];
8872 This field is present only if @code{n_missing_values} is not 0.  It has
8873 the same number of elements as the absolute value of
8874 @code{n_missing_values}.  For discrete missing values, each element
8875 represents one missing value.  When a range is present, the first
8876 element denotes the minimum value in the range, and the second element
8877 denotes the maximum value in the range.  When a range plus a value are
8878 present, the third element denotes the additional discrete missing
8879 value.  HIGHEST and LOWEST are indicated as described in the chapter
8880 introduction.
8881 @end table
8882
8883 The @code{print} and @code{write} members of sysfile_variable are output
8884 formats coded into @code{int32} types.  The LSB (least-significant byte)
8885 of the @code{int32} represents the number of decimal places, and the
8886 next two bytes in order of increasing significance represent field width
8887 and format type, respectively.  The MSB (most-significant byte) is not
8888 used and should be set to zero.
8889
8890 Format types are defined as follows:
8891 @table @asis
8892 @item 0
8893 Not used.
8894 @item 1
8895 @code{A}
8896 @item 2
8897 @code{AHEX}
8898 @item 3
8899 @code{COMMA}
8900 @item 4
8901 @code{DOLLAR}
8902 @item 5
8903 @code{F}
8904 @item 6
8905 @code{IB}
8906 @item 7
8907 @code{PIBHEX}
8908 @item 8
8909 @code{P}
8910 @item 9
8911 @code{PIB}
8912 @item 10
8913 @code{PK}
8914 @item 11
8915 @code{RB}
8916 @item 12
8917 @code{RBHEX}
8918 @item 13
8919 Not used.
8920 @item 14
8921 Not used.
8922 @item 15
8923 @code{Z}
8924 @item 16
8925 @code{N}
8926 @item 17
8927 @code{E}
8928 @item 18
8929 Not used.
8930 @item 19
8931 Not used.
8932 @item 20
8933 @code{DATE}
8934 @item 21
8935 @code{TIME}
8936 @item 22
8937 @code{DATETIME}
8938 @item 23
8939 @code{ADATE}
8940 @item 24
8941 @code{JDATE}
8942 @item 25
8943 @code{DTIME}
8944 @item 26
8945 @code{WKDAY}
8946 @item 27
8947 @code{MONTH}
8948 @item 28
8949 @code{MOYR}
8950 @item 29
8951 @code{QYR}
8952 @item 30
8953 @code{WKYR}
8954 @item 31
8955 @code{PCT}
8956 @item 32
8957 @code{DOT}
8958 @item 33
8959 @code{CCA}
8960 @item 34
8961 @code{CCB}
8962 @item 35
8963 @code{CCC}
8964 @item 36
8965 @code{CCD}
8966 @item 37
8967 @code{CCE}
8968 @item 38
8969 @code{EDATE}
8970 @item 39
8971 @code{SDATE}
8972 @end table
8973
8974 @node Value Label Record, Value Label Variable Record, Variable Record, Data File Format
8975 @section Value Label Record
8976
8977 Value label records must follow the variable records and must precede
8978 the header termination record.  Other than this, they may appear
8979 anywhere in the system file.  Every value label record must be
8980 immediately followed by a label variable record, described below.
8981
8982 Value label records begin with @code{rec_type}, an @code{int32} value
8983 set to the record type of 3.  This is followed by @code{count}, an
8984 @code{int32} value set to the number of value labels present in this
8985 record.
8986
8987 These two fields are followed by a series of @code{count} tuples.  Each
8988 tuple is divided into two fields, the value and the label.  The first of
8989 these, the value, is composed of a 64-bit value, which is either a
8990 @code{flt64} value or up to 8 characters (padded on the right to 8
8991 bytes) denoting a short string value.  Whether the value is a
8992 @code{flt64} or a character string is not defined inside the value label
8993 record.
8994
8995 The second field in the tuple, the label, has variable length.  The
8996 first @code{char} is a count of the number of characters in the value
8997 label.  The remainder of the field is the label itself.  The field is
8998 padded on the right to a multiple of 64 bits in length.
8999
9000 @node Value Label Variable Record, Document Record, Value Label Record, Data File Format
9001 @section Value Label Variable Record
9002
9003 Every value label variable record must be immediately preceded by a
9004 value label record, described above.
9005
9006 @example
9007 struct sysfile_value_label_variable
9008   @{
9009      int32              rec_type;
9010      int32              count;
9011      int32              vars[/* variable length */];
9012   @};
9013 @end example
9014
9015 @table @code
9016 @item int32 rec_type;
9017 Record type.  Always set to 4.
9018
9019 @item int32 count;
9020 Number of variables that the associated value labels from the value
9021 label record are to be applied.
9022
9023 @item int32 vars[/* variable length];
9024 A list of variables to which to apply the value labels.  There are
9025 @code{count} elements.
9026 @end table
9027
9028 @node Document Record, Machine int32 Info Record, Value Label Variable Record, Data File Format
9029 @section Document Record
9030
9031 There must be no more than one document record per system file.
9032 Document records must follow the variable records and precede the
9033 dictionary termination record.
9034
9035 @example
9036 struct sysfile_document
9037   @{
9038     int32               rec_type;
9039     int32               n_lines;
9040     char                lines[/* variable length */][80];
9041   @};
9042 @end example
9043
9044 @table @code
9045 @item int32 rec_type;
9046 Record type.  Always set to 6.
9047
9048 @item int32 n_lines;
9049 Number of lines of documents present.
9050
9051 @item char lines[/* variable length */][80];
9052 Document lines.  The number of elements is defined by @code{n_lines}.
9053 Lines shorter than 80 characters are padded on the right with spaces.
9054 @end table
9055
9056 @node Machine int32 Info Record, Machine flt64 Info Record, Document Record, Data File Format
9057 @section Machine @code{int32} Info Record
9058
9059 There must be no more than one machine @code{int32} info record per
9060 system file.  Machine @code{int32} info records must follow the variable
9061 records and precede the dictionary termination record.
9062
9063 @example
9064 struct sysfile_machine_int32_info
9065   @{
9066     /* Header. */
9067     int32               rec_type;
9068     int32               subtype;
9069     int32               size;
9070     int32               count;
9071
9072     /* Data. */
9073     int32               version_major;
9074     int32               version_minor;
9075     int32               version_revision;
9076     int32               machine_code;
9077     int32               floating_point_rep;
9078     int32               compression_code;
9079     int32               endianness;
9080     int32               character_code;
9081   @};
9082 @end example
9083
9084 @table @code
9085 @item int32 rec_type;
9086 Record type.  Always set to 7.
9087
9088 @item int32 subtype;
9089 Record subtype.  Always set to 3.
9090
9091 @item int32 size;
9092 Size of each piece of data in the data part, in bytes.  Always set to 4.
9093
9094 @item int32 count;
9095 Number of pieces of data in the data part.  Always set to 8.
9096
9097 @item int32 version_major;
9098 PSPP major version number.  In version @var{x}.@var{y}.@var{z}, this
9099 is @var{x}.
9100
9101 @item int32 version_minor;
9102 PSPP minor version number.  In version @var{x}.@var{y}.@var{z}, this
9103 is @var{y}.
9104
9105 @item int32 version_revision;
9106 PSPP version revision number.  In version @var{x}.@var{y}.@var{z},
9107 this is @var{z}.
9108
9109 @item int32 machine_code;
9110 Machine code.  PSPP always set this field to value to -1, but other
9111 values may appear.
9112
9113 @item int32 floating_point_rep;
9114 Floating point representation code.  For IEEE 754 systems this is 1.
9115 IBM 370 sets this to 2, and DEC VAX E to 3.
9116
9117 @item int32 compression_code;
9118 Compression code.  Always set to 1.
9119
9120 @item int32 endianness;
9121 Machine endianness.  1 indicates big-endian, 2 indicates little-endian.
9122
9123 @item int32 character_code;
9124 Character code.  1 indicates EBCDIC, 2 indicates 7-bit ASCII, 3
9125 indicates 8-bit ASCII, 4 indicates DEC Kanji.
9126 @end table
9127
9128 @node Machine flt64 Info Record, Miscellaneous Informational Records, Machine int32 Info Record, Data File Format
9129 @section Machine @code{flt64} Info Record
9130
9131 There must be no more than one machine @code{flt64} info record per
9132 system file.  Machine @code{flt64} info records must follow the variable
9133 records and precede the dictionary termination record.
9134
9135 @example
9136 struct sysfile_machine_flt64_info
9137   @{
9138     /* Header. */
9139     int32               rec_type;
9140     int32               subtype;
9141     int32               size;
9142     int32               count;
9143
9144     /* Data. */
9145     flt64               sysmis;
9146     flt64               highest;
9147     flt64               lowest;
9148   @};
9149 @end example
9150
9151 @table @code
9152 @item int32 rec_type;
9153 Record type.  Always set to 7.
9154
9155 @item int32 subtype;
9156 Record subtype.  Always set to 4.
9157
9158 @item int32 size;
9159 Size of each piece of data in the data part, in bytes.  Always set to 4.
9160
9161 @item int32 count;
9162 Number of pieces of data in the data part.  Always set to 3.
9163
9164 @item flt64 sysmis;
9165 The system missing value.
9166
9167 @item flt64 highest;
9168 The value used for HIGHEST in missing values.
9169
9170 @item flt64 lowest;
9171 The value used for LOWEST in missing values.
9172 @end table
9173
9174 @node Miscellaneous Informational Records, Dictionary Termination Record, Machine flt64 Info Record, Data File Format
9175 @section Miscellaneous Informational Records
9176
9177 Miscellaneous informational records must follow the variable records and
9178 precede the dictionary termination record.
9179
9180 Miscellaneous informational records are ignored by PSPP when reading
9181 system files.  They are not written by PSPP when writing system files.
9182
9183 @example
9184 struct sysfile_misc_info
9185   @{
9186     /* Header. */
9187     int32               rec_type;
9188     int32               subtype;
9189     int32               size;
9190     int32               count;
9191
9192     /* Data. */
9193     char                data[/* variable length */];
9194   @};
9195 @end example
9196
9197 @table @code
9198 @item int32 rec_type;
9199 Record type.  Always set to 7.
9200
9201 @item int32 subtype;
9202 Record subtype.  May take any value.  According to Aapi
9203 H@"am@"al@"ainen, value 5 indicates a set of grouped variables and 6
9204 indicates date info (probably related to USE).
9205
9206 @item int32 size;
9207 Size of each piece of data in the data part.  Should have the value 4 or
9208 8, for @code{int32} and @code{flt64}, respectively.
9209
9210 @item int32 count;
9211 Number of pieces of data in the data part.
9212
9213 @item char data[/* variable length */];
9214 Arbitrary data.  There must be @code{size} times @code{count} bytes of
9215 data.
9216 @end table
9217
9218 @node Dictionary Termination Record, Data Record, Miscellaneous Informational Records, Data File Format
9219 @section Dictionary Termination Record
9220
9221 The dictionary termination record must follow all other records, except
9222 for the actual cases, which it must precede.  There must be exactly one
9223 dictionary termination record in every system file.
9224
9225 @example
9226 struct sysfile_dict_term
9227   @{
9228     int32               rec_type;
9229     int32               filler;
9230   @};
9231 @end example
9232
9233 @table @code
9234 @item int32 rec_type;
9235 Record type.  Always set to 999.
9236
9237 @item int32 filler;
9238 Ignored padding.  Should be set to 0.
9239 @end table
9240
9241 @node Data Record,  , Dictionary Termination Record, Data File Format
9242 @section Data Record
9243
9244 Data records must follow all other records in the data file.  There must
9245 be at least one data record in every system file.
9246
9247 The format of data records varies depending on whether the data is
9248 compressed.  Regardless, the data is arranged in a series of 8-byte
9249 elements.
9250
9251 When data is not compressed, Every case is composed of @code{case_size}
9252 of these 8-byte elements, where @code{case_size} comes from the file
9253 header record (@pxref{File Header Record}).  Each element corresponds to
9254 the variable declared in the respective variable record (@pxref{Variable
9255 Record}).  Numeric values are given in @code{flt64} format; string
9256 values are literal characters string, padded on the right when
9257 necessary.
9258
9259 Compressed data is arranged in the following manner: the first 8-byte
9260 element in the data section is divided into a series of 1-byte command
9261 codes.  These codes have meanings as described below:
9262
9263 @table @asis
9264 @item 0
9265 Ignored.  If the program writing the system file accumulates compressed
9266 data in blocks of fixed length, 0 bytes can be used to pad out extra
9267 bytes remaining at the end of a fixed-size block.
9268
9269 @item 1 through 251
9270 These values indicate that the corresponding numeric variable has the
9271 value @code{(@var{code} - @var{bias})} for the case being read, where
9272 @var{code} is the value of the compression code and @var{bias} is the
9273 variable @code{compression_bias} from the file header.  For example,
9274 code 105 with bias 100.0 (the normal value) indicates a numeric variable
9275 of value 5.
9276
9277 @item 252
9278 End of file.  This code may or may not appear at the end of the data
9279 stream.  PSPP always outputs this code but its use is not required.
9280
9281 @item 253
9282 This value indicates that the numeric or string value is not
9283 compressible.  The value is stored in the 8-byte element following the
9284 current block of command bytes.  If this value appears twice in a block
9285 of command bytes, then it indicates the second element following the
9286 command bytes, and so on.
9287
9288 @item 254
9289 Used to indicate a string value that is all spaces.
9290
9291 @item 255
9292 Used to indicate the system-missing value.
9293 @end table
9294
9295 When the end of the first 8-byte element of command bytes is reached,
9296 any blocks of non-compressible values are skipped, and the next element
9297 of command bytes is read and interpreted, until the end of the file is
9298 reached.
9299
9300 @node Portable File Format, q2c Input Format, Data File Format, Top
9301 @chapter Portable File Format
9302
9303 These days, most computers use the same internal data formats for
9304 integer and floating-point data, if one ignores little differences like
9305 big- versus little-endian byte ordering.  However, occasionally it is
9306 necessary to exchange data between systems with incompatible data
9307 formats.  This is what portable files are designed to do.
9308
9309 @strong{Please note:} Although all of the following information is
9310 correct, as far as the author has been able to ascertain, it is gleaned
9311 from examination of ASCII-formatted portable files only, so some of it
9312 may be incorrect in the general case.
9313
9314 @menu
9315 * Portable File Characters::    
9316 * Portable File Structure::     
9317 * Portable File Header::        
9318 * Version and Date Info Record::  
9319 * Identification Records::      
9320 * Variable Count Record::       
9321 * Case Weight Variable Record::  
9322 * Variable Records::            
9323 * Value Label Records::         
9324 * Portable File Data::          
9325 @end menu
9326
9327 @node Portable File Characters, Portable File Structure, Portable File Format, Portable File Format
9328 @section Portable File Characters
9329
9330 Portable files are arranged as a series of lines of exactly 80
9331 characters each.  Each line is terminated by a carriage-return,
9332 line-feed sequence ``new-lines'').  New-lines are only used to avoid
9333 line length limits imposed by some OSes; they are not meaningful.
9334
9335 The file must be terminated with a @samp{Z} character.  In addition, if
9336 the final line in the file does not have exactly 80 characters, then it
9337 is padded on the right with @samp{Z} characters.  (The file contents may
9338 be in any character set; the file contains a description of its own
9339 character set, as explained in the next section.  Therefore, the
9340 @samp{Z} character is not necessarily an ASCII @samp{Z}.)
9341
9342 For the rest of the description of the portable file format, new-lines
9343 and the trailing @samp{Z}s will be ignored, as if they did not exist,
9344 because they are not an important part of understanding the file
9345 contents.
9346
9347 @node Portable File Structure, Portable File Header, Portable File Characters, Portable File Format
9348 @section Portable File Structure
9349
9350 Every portable file consists of the following records, in sequence:
9351
9352 @itemize @bullet
9353
9354 @item
9355 File header.
9356
9357 @item
9358 Version and date info.
9359
9360 @item
9361 Product identification.
9362
9363 @item
9364 Subproduct identification (optional).
9365
9366 @item
9367 Variable count.
9368
9369 @item
9370 Case weight variable (optional).
9371
9372 @item
9373 Variables.  Each variable record may optionally be followed by a
9374 missing value record and a variable label record.
9375
9376 @item
9377 Value labels (optional).
9378
9379 @item
9380 Data.
9381 @end itemize
9382
9383 Most records are identified by a single-character tag code.  The file
9384 header and version info record do not have a tag.
9385
9386 Other than these single-character codes, there are three types of fields
9387 in a portable file: floating-point, integer, and string.  Floating-point
9388 fields have the following format:
9389
9390 @itemize @bullet
9391
9392 @item
9393 Zero or more leading spaces.
9394
9395 @item
9396 Optional asterisk (@samp{*}), which indicates a missing value.  The
9397 asterisk must be followed by a single character, generally a period
9398 (@samp{.}), but it appears that other characters may also be possible.
9399 This completes the specification of a missing value.
9400
9401 @item
9402 Optional minus sign (@samp{-}) to indicate a negative number.
9403
9404 @item
9405 A whole number, consisting of one or more base-30 digits: @samp{0}
9406 through @samp{9} plus capital letters @samp{A} through @samp{T}.
9407
9408 @item
9409 Optional fraction, consisting of a radix point (@samp{.}) followed by
9410 one or more base-30 digits.
9411
9412 @item
9413 Optional exponent, consisting of a plus or minus sign (@samp{+} or
9414 @samp{-}) followed by one or more base-30 digits.
9415
9416 @item
9417 A forward slash (@samp{/}).
9418 @end itemize
9419
9420 Integer fields take a form identical to floating-point fields, but they
9421 may not contain a fraction.
9422
9423 String fields take the form of a integer field having value @var{n},
9424 followed by exactly @var{n} characters, which are the string content.
9425
9426 @node Portable File Header, Version and Date Info Record, Portable File Structure, Portable File Format
9427 @section Portable File Header
9428
9429 Every portable file begins with a 464-byte header, consisting of a
9430 200-byte collection of vanity splash strings, followed by a 256-byte
9431 character set translation table, followed by an 8-byte tag string.
9432
9433 The 200-byte segment is divided into five 40-byte sections, each of
9434 which represents the string @code{@var{charset} SPSS PORT FILE} in a
9435 different character set encoding, where @var{charset} is the name of
9436 the character set used in the file, e.g.@: @code{ASCII} or
9437 @code{EBCDIC}.  Each string is padded on the right with spaces in its
9438 respective character set.
9439
9440 It appears that these strings exist only to inform those who might view
9441 the file on a screen, and that they are not parsed by SPSS products.
9442 Thus, they can be safely ignored.  For those interested, the strings are
9443 supposed to be in the following character sets, in the specified order:
9444 EBCDIC, 7-bit ASCII, CDC 6-bit ASCII, 6-bit ASCII, Honeywell 6-bit
9445 ASCII.
9446
9447 The 256-byte segment describes a mapping from the character set used in
9448 the portable file to an arbitrary character set having characters at the
9449 following positions:
9450
9451 @table @asis
9452 @item 0--60
9453
9454 Control characters.  Not important enough to describe in full here.
9455
9456 @item 61--63
9457
9458 Reserved.
9459
9460 @item 64--73
9461
9462 Digits @samp{0} through @samp{9}.
9463
9464 @item 74--99
9465
9466 Capital letters @samp{A} through @samp{Z}. 
9467
9468 @item 100--125
9469
9470 Lowercase letters @samp{a} through @samp{z}.
9471
9472 @item 126
9473
9474 Space.
9475
9476 @item 127--130
9477
9478 Symbols @code{.<(+}
9479
9480 @item 131
9481
9482 Solid vertical pipe.
9483
9484 @item 132--142
9485
9486 Symbols @code{&[]!$*);^-/}
9487
9488 @item 143
9489
9490 Broken vertical pipe.
9491
9492 @item 144--150
9493
9494 Symbols @code{,%_>}?@code{`:}   @c @code{?} is an inverted question mark
9495
9496 @item 151
9497
9498 British pound symbol.
9499
9500 @item 152--155
9501
9502 Symbols @code{@@'="}.
9503
9504 @item 156
9505
9506 Less than or equal symbol.
9507
9508 @item 157
9509
9510 Empty box.
9511
9512 @item 158
9513
9514 Plus or minus.
9515
9516 @item 159
9517
9518 Filled box.
9519
9520 @item 160
9521
9522 Degree symbol.
9523
9524 @item 161
9525
9526 Dagger.
9527
9528 @item 162
9529
9530 Symbol @samp{~}.
9531
9532 @item 163
9533
9534 En dash.
9535
9536 @item 164
9537
9538 Lower left corner box draw.
9539
9540 @item 165
9541
9542 Upper left corner box draw.
9543
9544 @item 166
9545
9546 Greater than or equal symbol.
9547
9548 @item 167--176
9549
9550 Superscript @samp{0} through @samp{9}.
9551
9552 @item 177
9553
9554 Lower right corner box draw.
9555
9556 @item 178
9557
9558 Upper right corner box draw.
9559
9560 @item 179
9561
9562 Not equal symbol.
9563
9564 @item 180
9565
9566 Em dash.
9567
9568 @item 181
9569
9570 Superscript @samp{(}.
9571
9572 @item 182
9573
9574 Superscript @samp{)}.
9575
9576 @item 183
9577
9578 Horizontal dagger (?).
9579
9580 @item 184--186
9581
9582 Symbols @samp{@{@}\}.
9583 @item 187
9584
9585 Cents symbol.
9586
9587 @item 188
9588
9589 Centered dot, or bullet.
9590
9591 @item 189--255
9592
9593 Reserved.
9594 @end table
9595
9596 Symbols that are not defined in a particular character set are set to
9597 the same value as symbol 64; i.e., to @samp{0}.
9598
9599 The 8-byte tag string consists of the exact characters @code{SPSSPORT}
9600 in the portable file's character set, which can be used to verify that
9601 the file is indeed a portable file.
9602
9603 @node Version and Date Info Record, Identification Records, Portable File Header, Portable File Format
9604 @section Version and Date Info Record
9605
9606 This record does not have a tag code.  It has the following structure:
9607
9608 @itemize @bullet
9609 @item
9610 A single character identifying the file format version.  The letter A
9611 represents version 0, and so on.
9612
9613 @item
9614 An 8-character string field giving the file creation date in the format
9615 YYYYMMDD.
9616
9617 @item
9618 A 6-character string field giving the file creation time in the format
9619 HHMMSS.
9620 @end itemize
9621
9622 @node Identification Records, Variable Count Record, Version and Date Info Record, Portable File Format
9623 @section Identification Records
9624
9625 The product identification record has tag code @samp{1}.  It consists of
9626 a single string field giving the name of the product that wrote the
9627 portable file.
9628
9629 The subproduct identification record has tag code @samp{3}.  It
9630 consists of a single string field giving additional information on the
9631 product that wrote the portable file.
9632
9633 @node Variable Count Record, Case Weight Variable Record, Identification Records, Portable File Format
9634 @section Variable Count Record
9635
9636 The variable count record has tag code @samp{4}.  It consists of two
9637 integer fields.  The first contains the number of variables in the file
9638 dictionary.  The purpose of the second is unknown; it contains the value
9639 161 in all portable files examined so far.
9640
9641 @node Case Weight Variable Record, Variable Records, Variable Count Record, Portable File Format
9642 @section Case Weight Variable Record
9643
9644 The case weight variable record is optional.  If it is present, it
9645 indicates the variable used for weighting cases; if it is absent,
9646 cases are unweighted.  It has tag code @samp{6}.  It consists of a
9647 single string field that names the weighting variable.
9648
9649 @node Variable Records, Value Label Records, Case Weight Variable Record, Portable File Format
9650 @section Variable Records
9651
9652 Each variable record represents a single variable.  Variable records
9653 have tag code @samp{7}.  They have the following structure:
9654
9655 @itemize @bullet
9656
9657 @item
9658 Width (integer).  This is 0 for a numeric variable, and a number between 1
9659 and 255 for a string variable.
9660
9661 @item
9662 Name (string).  1--8 characters long.  Must be in all capitals.
9663
9664 @item
9665 Print format.  This is a set of three integer fields:
9666
9667 @itemize @minus
9668
9669 @item
9670 Format type (@pxref{Variable Record}).
9671
9672 @item
9673 Format width.  1--40.
9674
9675 @item
9676 Number of decimal places.  1--40.
9677 @end itemize
9678
9679 @item
9680 Write format.  Same structure as the print format described above.
9681 @end itemize
9682
9683 Each variable record can optionally be followed by a missing value
9684 record, which has tag code @samp{8}.  A missing value record has one
9685 field, the missing value itself (a floating-point or string, as
9686 appropriate).  Up to three of these missing value records can be used.
9687
9688 There is also a record for missing value ranges, which has tag code
9689 @samp{B}.  It is followed by two fields representing the range, which
9690 are floating-point or string as appropriate.  If a missing value range
9691 is present, it may be followed by a single missing value record.
9692
9693 Tag codes @samp{9} and @samp{A} represent @code{LO THRU @var{x}} and
9694 @code{@var{x} THRU HI} ranges, respectively.  Each is followed by a
9695 single field representing @var{x}.  If one of the ranges is present, it
9696 may be followed by a single missing value record.
9697
9698 In addition, each variable record can optionally be followed by a
9699 variable label record, which has tag code @samp{C}.  A variable label
9700 record has one field, the variable label itself (string).
9701
9702 @node Value Label Records, Portable File Data, Variable Records, Portable File Format
9703 @section Value Label Records
9704
9705 Value label records have tag code @samp{D}.  They have the following
9706 format:
9707
9708 @itemize @bullet
9709 @item
9710 Variable count (integer).
9711
9712 @item
9713 List of variables (strings).  The variable count specifies the number in
9714 the list.  Variables are specified by their names.  All variables must
9715 be of the same type (numeric or string).
9716
9717 @item
9718 Label count (integer).
9719
9720 @item
9721 List of (value, label) tuples.  The label count specifies the number of
9722 tuples.  Each tuple consists of a value, which is numeric or string as
9723 appropriate to the variables, followed by a label (string).
9724 @end itemize
9725
9726 @node Portable File Data,  , Value Label Records, Portable File Format
9727 @section Portable File Data
9728
9729 The data record has tag code @samp{F}.  There is only one tag for all
9730 the data; thus, all the data must follow the dictionary.  The data is
9731 terminated by the end-of-file marker @samp{Z}, which is not valid as the
9732 beginning of a data element.
9733
9734 Data elements are output in the same order as the variable records
9735 describing them.  String variables are output as string fields, and
9736 numeric variables are output as floating-point fields.
9737
9738 @node q2c Input Format, Bugs, Portable File Format, Top
9739 @chapter @code{q2c} Input Format
9740
9741 PSPP statistical procedures have a bizarre and somewhat irregular
9742 syntax.  Despite this, a parser generator has been written that
9743 adequately addresses many of the possibilities and tries to provide
9744 hooks for the exceptional cases.  This parser generator is named
9745 @code{q2c}.
9746
9747 @menu
9748 * Invoking q2c::                q2c command-line syntax.
9749 * q2c Input Structure::         High-level layout of the input file.
9750 * Grammar Rules::               Syntax of the grammar rules.
9751 @end menu
9752
9753 @node Invoking q2c, q2c Input Structure, q2c Input Format, q2c Input Format
9754 @section Invoking q2c
9755
9756 @example
9757 q2c @var{input.q} @var{output.c}
9758 @end example
9759
9760 @code{q2c} translates a @samp{.q} file into a @samp{.c} file.  It takes
9761 exactly two command-line arguments, which are the input file name and
9762 output file name, respectively.  @code{q2c} does not accept any
9763 command-line options.
9764
9765 @node q2c Input Structure, Grammar Rules, Invoking q2c, q2c Input Format
9766 @section @code{q2c} Input Structure
9767
9768 @code{q2c} input files are divided into two sections: the grammar rules
9769 and the supporting code.  The @dfn{grammar rules}, which make up the
9770 first part of the input, are used to define the syntax of the
9771 statistical procedure to be parsed.  The @dfn{supporting code},
9772 following the grammar rules, are copied largely unchanged to the output
9773 file, except for certain escapes.
9774
9775 The most important lines in the grammar rules are used for defining
9776 procedure syntax.  These lines can be prefixed with a dollar sign
9777 (@samp{$}), which prevents Emacs' CC-mode from munging them.  Besides
9778 this, a bang (@samp{!}) at the beginning of a line causes the line,
9779 minus the bang, to be written verbatim to the output file (useful for
9780 comments).  As a third special case, any line that begins with the exact
9781 characters @code{/* *INDENT} is ignored and not written to the output.
9782 This allows @code{.q} files to be processed through @code{indent}
9783 without being munged.
9784
9785 The syntax of the grammar rules themselves is given in the following
9786 sections.
9787
9788 The supporting code is passed into the output file largely unchanged.
9789 However, the following escapes are supported.  Each escape must appear
9790 on a line by itself.
9791
9792 @table @code
9793 @item /* (header) */
9794
9795 Expands to a series of C @code{#include} directives which include the
9796 headers that are required for the parser generated by @code{q2c}.
9797
9798 @item /* (decls @var{scope}) */
9799
9800 Expands to C variable and data type declarations for the variables and
9801 @code{enum}s input and output by the @code{q2c} parser.  @var{scope}
9802 must be either @code{local} or @code{global}.  @code{local} causes the
9803 declarations to be output as function locals.  @code{global} causes them
9804 to be declared as @code{static} module variables; thus, @code{global} is
9805 a bit of a misnomer.
9806
9807 @item /* (parser) */
9808
9809 Expands to the entire parser.  Must be enclosed within a C function.
9810
9811 @item /* (free) */
9812
9813 Expands to a set of calls to the @code{free} function for variables
9814 declared by the parser.  Only needs to be invoked if subcommands of type
9815 @code{string} are used in the grammar rules.
9816 @end table
9817
9818 @node Grammar Rules,  , q2c Input Structure, q2c Input Format
9819 @section Grammar Rules
9820
9821 The grammar rules describe the format of the syntax that the parser
9822 generated by @code{q2c} will understand.  The way that the grammar rules
9823 are included in @code{q2c} input file are described above.
9824
9825 The grammar rules are divided into tokens of the following types:
9826
9827 @table @asis
9828 @item Identifier (@code{ID})
9829
9830 An identifier token is a sequence of letters, digits, and underscores
9831 (@samp{_}).  Identifiers are @emph{not} case-sensitive.
9832
9833 @item String (@code{STRING})
9834
9835 String tokens are initiated by a double-quote character (@samp{"}) and
9836 consist of all the characters between that double quote and the next
9837 double quote, which must be on the same line as the first.  Within a
9838 string, a backslash can be used as a ``literal escape''.  The only
9839 reasons to use a literal escape are to include a double quote or a
9840 backslash within a string.
9841
9842 @item Special character
9843
9844 Other characters, other than whitespace, constitute tokens in
9845 themselves.
9846
9847 @end table
9848
9849 The syntax of the grammar rules is as follows:
9850
9851 @example
9852 grammar-rules ::= ID : subcommands .
9853 subcommands ::= subcommand
9854             ::= subcommands ; subcommand
9855 @end example
9856
9857 The syntax begins with an ID or STRING token that gives the name of the
9858 procedure to be parsed.  The rest of the syntax consists of subcommands
9859 separated by semicolons (@samp{;}) and terminated with a full stop
9860 (@samp{.}).
9861
9862 @example
9863 subcommand ::= sbc-options ID sbc-defn
9864 sbc-options ::= 
9865             ::= sbc-option
9866             ::= sbc-options sbc-options
9867 sbc-option ::= *
9868            ::= +
9869 sbc-defn ::= opt-prefix = specifiers
9870          ::= [ ID ] = array-sbc
9871          ::= opt-prefix = sbc-special-form
9872 opt-prefix ::=
9873            ::= ( ID )
9874 @end example
9875
9876 Each subcommand can be prefixed with one or more option characters.  An
9877 asterisk (@samp{*}) is used to indicate the default subcommand; the
9878 keyword used for the default subcommand can be omitted in the PSPP
9879 syntax file.  A plus sign (@samp{+}) is used to indicate that a
9880 subcommand can appear more than once; if it is not present then that
9881 subcommand can appear no more than once.
9882
9883 The subcommand name appears after the option characters.
9884
9885 There are three forms of subcommands.  The first and most common form
9886 simply gives an equals sign (@samp{=}) and a list of specifiers, which
9887 can each be set to a single setting.  The second form declares an array,
9888 which is a set of flags that can be individually turned on by the user.
9889 There are also several special forms that do not take a list of
9890 specifiers.
9891
9892 Arrays require an additional @code{ID} argument.  This is used as a
9893 prefix, prepended to the variable names constructed from the
9894 specifiers.  The other forms also allow an optional prefix to be
9895 specified.
9896
9897 @example
9898 array-sbc ::= alternatives
9899           ::= array-sbc , alternatives
9900 alternatives ::= ID
9901              ::= alternatives | ID
9902 @end example
9903
9904 An array subcommand is a set of Boolean values that can independently be
9905 turned on by the user, listed separated by commas (@samp{,}).  If an value has more
9906 than one name then these names are separated by pipes (@samp{|}).
9907
9908 @example
9909 specifiers ::= specifier
9910            ::= specifiers , specifier
9911 specifier ::= opt-id : settings
9912 opt-id ::=
9913        ::= ID
9914 @end example
9915
9916 Ordinary subcommands (other than arrays and special forms) require a
9917 list of specifiers.  Each specifier has an optional name and a list of
9918 settings.  If the name is given then a correspondingly named variable
9919 will be used to store the user's choice of setting.  If no name is given
9920 then there is no way to tell which setting the user picked; in this case
9921 the settings should probably have values attached.
9922
9923 @example
9924 settings ::= setting
9925          ::= settings / setting
9926 setting ::= setting-options ID setting-value
9927 setting-options ::=
9928                 ::= *
9929                 ::= !
9930                 ::= * !
9931 @end example
9932
9933 Individual settings are separated by forward slashes (@samp{/}).  Each
9934 setting can be as little as an @code{ID} token, but options and values
9935 can optionally be included.  The @samp{*} option means that, for this
9936 setting, the @code{ID} can be omitted.  The @samp{!} option means that
9937 this option is the default for its specifier.
9938
9939 @example
9940 setting-value ::=
9941               ::= ( setting-value-2 )
9942               ::= setting-value-2
9943 setting-value-2 ::= setting-value-options setting-value-type : ID 
9944                     setting-value-restriction
9945 setting-value-options ::=
9946                       ::= *
9947 setting-value-type ::= N
9948                    ::= D
9949 setting-value-restriction ::= 
9950                           ::= , STRING
9951 @end example
9952
9953 Settings may have values.  If the value must be enclosed in parentheses,
9954 then enclose the value declaration in parentheses.  Declare the setting
9955 type as @samp{n} or @samp{d} for integer or floating point type,
9956 respectively.  The given @code{ID} is used to construct a variable name.
9957 If option @samp{*} is given, then the value is optional; otherwise it
9958 must be specified whenever the corresponding setting is specified.  A
9959 ``restriction'' can also be specified which is a string giving a C
9960 expression limiting the valid range of the value.  The special escape
9961 @code{%s} should be used within the restriction to refer to the
9962 setting's value variable.
9963
9964 @example
9965 sbc-special-form ::= VAR
9966                  ::= VARLIST varlist-options
9967                  ::= INTEGER opt-list
9968                  ::= DOUBLE opt-list
9969                  ::= PINT
9970                  ::= STRING @r{(the literal word STRING)} string-options
9971                  ::= CUSTOM
9972 varlist-options ::= 
9973                 ::= ( STRING )
9974 opt-list ::=
9975          ::= LIST
9976 string-options ::= 
9977                ::= ( STRING STRING )
9978 @end example
9979
9980 The special forms are of the following types:
9981
9982 @table @code
9983 @item VAR
9984
9985 A single variable name.
9986
9987 @item VARLIST
9988
9989 A list of variables.  If given, the string can be used to provide
9990 @code{PV_@var{*}} options to the call to @code{parse_variables}. 
9991
9992 @item INTEGER
9993
9994 A single integer value.
9995
9996 @item INTEGER LIST
9997
9998 A list of integers separated by spaces or commas.
9999
10000 @item DOUBLE
10001
10002 A single floating-point value.
10003
10004 @item DOUBLE LIST
10005
10006 A list of floating-point values.
10007
10008 @item PINT
10009
10010 A single positive integer value.
10011
10012 @item STRING
10013
10014 A string value.  If the options are given then the first string is an
10015 expression giving a restriction on the value of the string; the second
10016 string is an error message to display when the restriction is violated.
10017
10018 @item CUSTOM
10019
10020 A custom function is used to parse this subcommand.  The function must
10021 have prototype @code{int custom_@var{name} (void)}.  It should return 0
10022 on failure (when it has already issued an appropriate diagnostic), 1 on
10023 success, or 2 if it fails and the calling function should issue a syntax
10024 error on behalf of the custom handler.
10025
10026 @end table
10027
10028 @node Bugs, Function Index, q2c Input Format, Top
10029 @chapter Bugs
10030
10031 @menu
10032 * Known bugs::                  Pointers to other files.
10033 * Contacting the Author::       Where to send the bug reports.
10034 @end menu
10035
10036 @node Known bugs, Contacting the Author, Bugs, Bugs
10037 @section Known bugs
10038
10039 This is the list of known bugs in PSPP.  In addition, @xref{Not
10040 Implemented}, and @xref{Functions Not Implemented}, for lists of bugs
10041 due to features not implemented.  For known bugs in individual language
10042 features, see the documentation for that feature.
10043
10044 @itemize @bullet
10045 @item
10046 Nothing has yet been tested exhaustively. Be cautious using PSPP to
10047 make important decisions.
10048
10049 @item
10050 @code{make check} fails on some systems that don't like the syntax.  I'm
10051 not sure why.  If someone could make an attempt to track this down, it
10052 would be appreciated.
10053
10054 @item
10055 PostScript driver bugs:
10056
10057 @itemize @minus
10058 @item
10059 Does not support driver arguments `max-fonts-simult' or
10060 `optimize-text-size'.
10061
10062 @item
10063 Minor problems with font-encodings.
10064
10065 @item
10066 Fails to align fonts along their baselines.
10067
10068 @item
10069 Does not support certain bizarre line intersections--should
10070 never crop up in practice.
10071
10072 @item
10073 Does not gracefully substitute for existing fonts whose
10074 encodings are missing.
10075
10076 @item
10077 Does not perform italic correction or left italic correction
10078 on font changes.
10079
10080 @item
10081 Encapsulated PostScript is unimplemented.
10082 @end itemize
10083
10084 @item
10085 ASCII driver bugs:
10086
10087 @itemize @minus
10088 Does not support `infinite length' or `infinite width' paper.
10089 @end itemize
10090 @end itemize
10091
10092 See below for information on reporting bugs not listed here.
10093
10094 @node Contacting the Author,  , Known bugs, Bugs
10095 @section Contacting the Author
10096
10097 The author can be contacted at e-mail address
10098 @ifinfo
10099 <blp@@gnu.org>.
10100 @end ifinfo
10101 @iftex
10102 @code{<blp@@gnu.org>}.
10103 @end iftex
10104
10105 PSPP bug reports should be sent to 
10106 @ifinfo
10107 <bug-gnu-pspp@@gnu.org>.
10108 @end ifinfo
10109 @iftex
10110 @code{<bug-gnu-pspp@@gnu.org>}.
10111 @end iftex
10112
10113 @node Function Index, Concept Index, Bugs, Top
10114 @chapter Function Index
10115 @printindex fn
10116
10117 @node Concept Index, Command Index, Function Index, Top
10118 @chapter Concept Index
10119 @printindex cp
10120
10121 @node Command Index,  , Concept Index, Top
10122 @chapter Command Index
10123 @printindex vr
10124
10125 @contents
10126 @bye
10127
10128 @c Local Variables:
10129 @c compile-command: "makeinfo pspp.texi"
10130 @c End: