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