work on docs
[pspp] / doc / expressions.texi
index 345e59669d36ad6f0cc08a8f95251e3b0760fdbc..cd214380e7326a5d5e23fd165fc85d867404f264 100644 (file)
@@ -1,9 +1,24 @@
+@c PSPP - a program for statistical analysis.
+@c Copyright (C) 2017, 2020 Free Software Foundation, Inc.
+@c Permission is granted to copy, distribute and/or modify this document
+@c under the terms of the GNU Free Documentation License, Version 1.3
+@c or any later version published by the Free Software Foundation;
+@c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+@c A copy of the license is included in the section entitled "GNU
+@c Free Documentation License".
+@c
+@c Use @func when referring to a function.
+@c Use @deftypefn for their definitions
+@macro func{NAME}
+@code{\NAME\}
+@end macro
+
 @node Expressions
 @chapter Mathematical Expressions
 @cindex expressions, mathematical
 @cindex mathematical expressions
 
-Expressions share a common syntax each place they appear in PSPP
+Expressions share a common syntax each place they appear in @pspp{}
 commands.  Expressions are made up of @dfn{operands}, which can be
 numbers, strings, or variable names, separated by @dfn{operators}.
 There are five types of operators: grouping, arithmetic, logical,
@@ -30,7 +45,7 @@ full-fledged expressions in themselves.
 @cindex Boolean
 @cindex values, Boolean
 
-Some PSPP operators and expressions work with Boolean values, which
+Some @pspp{} operators and expressions work with Boolean values, which
 represent true/false conditions.  Booleans have only three possible
 values: 0 (false), 1 (true), and system-missing (unknown).
 System-missing is neither true nor false and indicates that the true
@@ -117,7 +132,7 @@ system-missing.  The result of @code{0**0} is system-missing as well.
 @cindex @samp{-}
 @cindex negation
 @item - @var{a}
-Reverses the sign of @var{a}.  
+Reverses the sign of @var{a}.
 @end table
 
 @node Logical Operators
@@ -238,15 +253,15 @@ True if @var{a} is not equal to @var{b}.
 @cindex @code{(}
 @cindex @code{)}
 @cindex names, of functions
-PSPP functions provide mathematical abilities above and beyond
+@pspp{} functions provide mathematical abilities above and beyond
 those possible using simple operators.  Functions have a common
 syntax: each is composed of a function name followed by a left
 parenthesis, one or more arguments, and a right parenthesis.
 
 Function names are not reserved.  Their names are specially treated
-only when followed by a left parenthesis, so that @code{EXP(10)}
-refers to the constant value @code{e} raised to the 10th power, but
-@code{EXP} by itself refers to the value of variable EXP.
+only when followed by a left parenthesis, so that @samp{EXP(10)}
+refers to the constant value @math{e} raised to the 10th power, but
+@samp{EXP} by itself refers to the value of a variable called @code{EXP}.
 
 The sections below describe each function in detail.
 
@@ -256,9 +271,10 @@ The sections below describe each function in detail.
 * Trigonometry::                ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
 * Missing Value Functions::     MISSING NMISS NVALID SYSMIS VALUE
 * Set Membership::              ANY RANGE
-* Statistical Functions::       CFVAR MAX MEAN MIN SD SUM VARIANCE
-* String Functions::            CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER 
-                                RINDEX RPAD RTRIM STRING SUBSTR UPCASE
+* Statistical Functions::       CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE
+* String Functions::            CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
+                                REPLACE RINDEX RPAD RTRIM STRING STRUNC SUBSTR
+                                UPCASE
 * Time and Date::               CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
                                 DATEDIFF DATESUM
 * Miscellaneous Functions::     LAG YRMODA VALUELABEL
@@ -273,7 +289,7 @@ Advanced mathematical functions take numeric arguments and produce
 numeric results.
 
 @deftypefn {Function} {} EXP (@var{exponent})
-Returns @i{e} (approximately 2.71828) raised to power @var{exponent}.
+Returns @math{e} (approximately 2.71828) raised to power @var{exponent}.
 @end deftypefn
 
 @cindex logarithms
@@ -283,12 +299,12 @@ not positive, the result is system-missing.
 @end deftypefn
 
 @deftypefn {Function} {} LN (@var{number})
-Takes the base-@i{e} logarithm of @var{number}.  If @var{number} is
+Takes the base-@math{e} logarithm of @var{number}.  If @var{number} is
 not positive, the result is system-missing.
 @end deftypefn
 
 @deftypefn {Function} {} LNGAMMA (@var{number})
-Yields the base-@i{e} logarithm of the complete gamma of @var{number}.
+Yields the base-@math{e} logarithm of the complete gamma of @var{number}.
 If @var{number} is a negative integer, the result is system-missing.
 @end deftypefn
 
@@ -325,15 +341,24 @@ Returns the remainder when @var{number} is divided by 10.  If
 @end deftypefn
 
 @cindex rounding
-@deftypefn {Function} {} RND (@var{number})
-Takes the absolute value of @var{number} and rounds it to an integer.
-Then, if @var{number} was negative originally, negates the result.
+@deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
+Rounds @var{number} and rounds it to a multiple of @var{mult} (by
+default 1).  Halves are rounded away from zero, as are values that
+fall short of halves by less than @var{fuzzbits} of errors in the
+least-significant bits of @var{number}.  If @var{fuzzbits} is not
+specified then the default is taken from SET FUZZBITS (@pxref{SET
+FUZZBITS}), which is 6 unless overridden.
 @end deftypefn
 
 @cindex truncation
-@deftypefn {Function} {} TRUNC (@var{number})
-Discards the fractional part of @var{number}; that is, rounds
-@var{number} towards zero.
+@deftypefn {Function} {} TRUNC (@var{number} [, @var{mult}[, @var{fuzzbits}]])
+Rounds @var{number} to a multiple of @var{mult}, toward zero.  For the
+default @var{mult} of 1, this is equivalent to discarding the
+fractional part of @var{number}.  Values that fall short of a multiple
+of @var{mult} by less than @var{fuzzbits} of errors in the
+least-significant bits of @var{number} are rounded away from zero.  If
+@var{fuzzbits} is not specified then the default is taken from SET
+FUZZBITS (@pxref{SET FUZZBITS}), which is 6 unless overridden.
 @end deftypefn
 
 @node Trigonometry
@@ -349,7 +374,7 @@ results.
 @deftypefnx {Function} {} ACOS (@var{number})
 Takes the arccosine, in radians, of @var{number}.  Results in
 system-missing if @var{number} is not between -1 and 1 inclusive.
-This function is a PSPP extension.
+This function is a @pspp{} extension.
 @end deftypefn
 
 @cindex arcsine
@@ -381,7 +406,7 @@ Takes the sine of @var{angle} which should be in radians.
 @deftypefn {Function} {} TAN (@var{angle})
 Takes the tangent of @var{angle} which should be in radians.
 Results in system-missing at values
-of @var{angle} that are too close to odd multiples of pi/2.
+of @var{angle} that are too close to odd multiples of @math{\pi/2}.
 Portability: none.
 @end deftypefn
 
@@ -398,7 +423,11 @@ functions.  In particular, user-missing values for numeric variables
 are converted to system-missing values.
 
 @deftypefn {Function} {} MISSING (@var{expr})
-Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
+When @var{expr} is simply the name of a numeric variable, returns 1 if
+the variable has the system-missing value or if it is user-missing.
+For any other value 0 is returned.
+If @var{expr} takes another form, the function returns 1 if the value is
+system-missing, 0 otherwise.
 @end deftypefn
 
 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
@@ -414,16 +443,14 @@ variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
 @end deftypefn
 
 @deftypefn {Function} {} SYSMIS (@var{expr})
-When @var{expr} is simply the name of a numeric variable, returns 1 if
-the variable has the system-missing value, 0 if it is user-missing or
-not missing.  If given @var{expr} takes another form, results in 1 if
-the value is system-missing, 0 otherwise.
+Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
 @end deftypefn
 
 @deftypefn {Function} {} VALUE (@var{variable})
-Prevents the user-missing values of @var{variable} from being
-transformed into system-missing values, and always results in the
-actual value of @var{variable}, whether it is valid, user-missing, or
+@deftypefnx {Function} {} VALUE (@var{vector}(@var{index}))
+Prevents the user-missing values of the variable or vector element
+from being transformed into system-missing values, and always results
+in its actual value, whether it is valid, user-missing, or
 system-missing.
 @end deftypefn
 
@@ -437,23 +464,25 @@ They take a set of numeric arguments or a set of string arguments, and
 produce Boolean results.
 
 String comparisons are performed according to the rules given in
-@ref{Relational Operators}.
+@ref{Relational Operators}.  User-missing string values are treated as
+valid values.
 
 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
-Results in true if @var{value} is equal to any of the @var{set}
-values.  Otherwise, results in false.  If @var{value} is
-system-missing, returns system-missing.  System-missing values in
-@var{set} do not cause ANY to return system-missing.
+Returns true if @var{value} is equal to any of the @var{set} values,
+and false otherwise.  For numeric arguments, returns system-missing if
+@var{value} is system-missing or if all the values in @var{set} are
+system-missing.  If @var{value}
 @end deftypefn
 
 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
-Results in true if @var{value} is in any of the intervals bounded by
-@var{low} and @var{high} inclusive.  Otherwise, results in false.
-Each @var{low} must be less than or equal to its corresponding
-@var{high} value.  @var{low} and @var{high} must be given in pairs.
-If @var{value} is system-missing, returns system-missing.
-System-missing values in @var{set} do not cause RANGE to return
-system-missing.
+Returns true if @var{value} is in any of the intervals bounded by
+@var{low} and @var{high} inclusive, and false otherwise.  @var{low}
+and @var{high} must be given in pairs.  Returns system-missing if any
+@var{high} is less than its @var{low} or, for numeric arguments, if
+@var{value} is system-missing or if all the @var{low}-@var{high} pairs
+contain one (or two) system-missing values.  A pair does not match
+@var{value} if either @var{low} or @var{high} is missing, even if
+@var{value} equals the non-missing endpoint.
 @end deftypefn
 
 @node Statistical Functions
@@ -475,10 +504,10 @@ using the @code{@var{var1} TO @var{var2}} syntax.
 Unlike most functions, statistical functions can return non-missing
 values even when some of their arguments are missing.  Most
 statistical functions, by default, require only 1 non-missing value to
-have a non-missing return, but CFVAR, SD, and VARIANCE require 2.
+have a non-missing return, but @func{CFVAR}, @func{SD}, and @func {VARIANCE} require 2.
 These defaults can be increased (but not decreased) by appending a dot
 and the minimum number of valid arguments to the function name.  For
-example, @code{MEAN.3(X, Y, Z)} would only return non-missing if all
+example, @subcmd{MEAN.3(X, Y, Z)} would only return non-missing if all
 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
 
 @cindex coefficient of variation
@@ -500,6 +529,13 @@ be numeric or string.
 Results in the mean of the values of @var{number}.
 @end deftypefn
 
+@cindex median
+@deftypefn {Function} {} MEDIAN (@var{number}, @var{number}[, @dots{}])
+Results in the median of the values of @var{number}.  Given an even
+number of nonmissing arguments, yields the mean of the two middle
+values.
+@end deftypefn
+
 @cindex minimum
 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
 Results in the value of the least @var{value}.  The @var{value}s may
@@ -534,30 +570,33 @@ String functions take various arguments and return various results.
 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
 Returns a string consisting of each @var{string} in sequence.
 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
-The resultant string is truncated to a maximum of 255 characters.
+The resultant string is truncated to a maximum of 32767 bytes.
 @end deftypefn
 
 @cindex searching strings
 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
-Returns a positive integer indicating the position of the first
-occurrence of @var{needle} in @var{haystack}.  Returns 0 if @var{haystack}
-does not contain @var{needle}.  Returns system-missing if @var{needle}
-is an empty string.
+@deftypefnx {Function} {} RINDEX (@var{haystack}, @var{needle})
+Returns a positive integer indicating the position of the first (for
+@code{INDEX}) or last (for @code{RINDEX}) occurrence of @var{needle}
+in @var{haystack}.  Returns 0 if @var{haystack} does not contain
+@var{needle}.  Returns 1 if @var{needle} is the empty string.
 @end deftypefn
 
 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
-Divides @var{needles} into one or more needles, each with length
-@var{needle_len}.
-Searches @var{haystack} for the first occurrence of each needle, and
-returns the smallest value.  Returns 0 if @var{haystack} does not
-contain any part in @var{needle}.  It is an error if @var{needle_len}
-does not evenly divide the length of @var{needles}.  Returns
-system-missing if @var{needles} is an empty string.
+@deftypefnx {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
+Divides @var{needles} into multiple needles, each with length
+@var{needle_len}, which must be a positive integer that evenly divides
+the length of @var{needles}.  Searches @var{haystack} for the
+occurrences of each needle and returns a positive integer indicating
+the byte index of the beginning of the first (for @code{INDEX}) or
+last (for @code{RINDEX}) needle it finds.  Returns 0 if @var{haystack}
+does not contain any of the needles, or if @var{needles} is the empty
+string.
 @end deftypefn
 
 @cindex strings, finding length of
 @deftypefn {Function} {} LENGTH (@var{string})
-Returns the number of characters in @var{string}.
+Returns the number of bytes in @var{string}.
 @end deftypefn
 
 @cindex strings, case of
@@ -568,33 +607,30 @@ letters are changed to lowercase letters.  The definitions of
 @end deftypefn
 
 @cindex strings, padding
-@deftypefn {Function} {} LPAD (@var{string}, @var{length})
-If @var{string} is at least @var{length} characters in length, returns
-@var{string} unchanged.  Otherwise, returns @var{string} padded with
-spaces on the left side to length @var{length}.  Returns an empty string
-if @var{length} is system-missing, negative, or greater than 255.
-@end deftypefn
+@deftypefn {Function} {} LPAD (@var{string}, @var{length}[, @var{padding}])
+@deftypefnx {Function} {} RPAD (@var{string}, @var{length}[, @var{padding}])
+If @var{string} is at least @var{length} bytes long, these functions
+return @var{string} unchanged.  Otherwise, they return @var{string}
+padded with @var{padding} on the left side (for @code{LPAD}) or right
+side (for @code{RPAD}) to @var{length} bytes.  These functions report
+an error and return @var{string} unchanged if @var{length} is missing
+or bigger than 32767.
 
-@deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
-If @var{string} is at least @var{length} characters in length, returns
-@var{string} unchanged.  Otherwise, returns @var{string} padded with
-@var{padding} on the left side to length @var{length}.  Returns an empty
-string if @var{length} is system-missing, negative, or greater than 255, or
-if @var{padding} does not contain exactly one character.
+The @var{padding} argument must not be an empty string and defaults to
+a space if not specified.  If its length does not evenly fit the
+amount of space needed for padding, the returned string will be
+shorter than @var{length}.
 @end deftypefn
 
 @cindex strings, trimming
 @cindex white space, trimming
-@deftypefn {Function} {} LTRIM (@var{string})
-Returns @var{string}, after removing leading spaces.  Other white space,
-such as tabs, carriage returns, line feeds, and vertical tabs, is not
-removed.
-@end deftypefn
-
-@deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
-Returns @var{string}, after removing leading @var{padding} characters.
-If @var{padding} does not contain exactly one character, returns an
-empty string.
+@deftypefn {Function} {} LTRIM (@var{string}[, @var{padding}])
+@deftypefnx {Function} {} RTRIM (@var{string}[, @var{padding}])
+These functions return @var{string}, after removing leading (for
+@code{LTRIM}) or trailing (for @code{RTRIM}) copies of @var{padding}.
+If @var{padding} is omitted, these functions remove spaces (but not
+tabs or other white space).  These functions return @var{string}
+unchanged if @var{padding} is the empty string.
 @end deftypefn
 
 @cindex numbers, converting from strings
@@ -602,59 +638,21 @@ empty string.
 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
 Returns the number produced when @var{string} is interpreted according
 to format specifier @var{format}.  If the format width @var{w} is less
-than the length of @var{string}, then only the first @var{w}
-characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
-and @code{NUMBER("1234", F3.0)} both have value 123.  If @var{w} is
+than the length of @var{string}, then only the first @var{w} bytes in
+@var{string} are used, @i{e.g.}@: @code{NUMBER("123", F3.0)} and
+@code{NUMBER("1234", F3.0)} both have value 123.  If @var{w} is
 greater than @var{string}'s length, then it is treated as if it were
 right-padded with spaces.  If @var{string} is not in the correct
 format for @var{format}, system-missing is returned.
 @end deftypefn
 
-@cindex strings, searching backwards
-@deftypefn {Function} {} RINDEX (@var{string}, @var{format})
-Returns a positive integer indicating the position of the last
-occurrence of @var{needle} in @var{haystack}.  Returns 0 if
-@var{haystack} does not contain @var{needle}.  Returns system-missing if
-@var{needle} is an empty string.
-@end deftypefn
-
-@deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
-Divides @var{needle} into parts, each with length @var{needle_len}.
-Searches @var{haystack} for the last occurrence of each part, and
-returns the largest value.  Returns 0 if @var{haystack} does not contain
-any part in @var{needle}.  It is an error if @var{needle_len} does not
-evenly divide the length of @var{needle}.  Returns system-missing
-if @var{needle} is an empty string.
-@end deftypefn
-
-@cindex padding strings
-@cindex strings, padding
-@deftypefn {Function} {} RPAD (@var{string}, @var{length})
-If @var{string} is at least @var{length} characters in length, returns
-@var{string} unchanged.  Otherwise, returns @var{string} padded with
-spaces on the right to length @var{length}.  Returns an empty string if
-@var{length} is system-missing, negative, or greater than 255.
-@end deftypefn
-
-@deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
-If @var{string} is at least @var{length} characters in length, returns
-@var{string} unchanged.  Otherwise, returns @var{string} padded with
-@var{padding} on the right to length @var{length}.  Returns an empty
-string if @var{length} is system-missing, negative, or greater than 255,
-or if @var{padding} does not contain exactly one character.
-@end deftypefn
-
-@cindex strings, trimming
-@cindex white space, trimming
-@deftypefn {Function} {} RTRIM (@var{string})
-Returns @var{string}, after removing trailing spaces.  Other types of
-white space are not removed.
-@end deftypefn
-
-@deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
-Returns @var{string}, after removing trailing @var{padding} characters.
-If @var{padding} does not contain exactly one character, returns an
-empty string.
+@cindex strings, replacing substrings
+@cindex replacing substrings
+@deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
+Returns string @var{haystack} with instances of @var{needle} replaced
+by @var{replacement}.  If nonnegative integer @var{n} is specified, it
+limits the maximum number of replacements; otherwise, all instances of
+@var{needle} are replaced.
 @end deftypefn
 
 @cindex strings, converting from numbers
@@ -665,6 +663,16 @@ format specifier @var{format}.  For example, @code{STRING(123.56, F5.1)}
 has the value @code{"123.6"}.
 @end deftypefn
 
+@cindex strings, trimming
+@cindex strings, truncating
+@cindex white space, trimming
+@deftypefn {Function} {} STRUNC (@var{string}, @var{n})
+Returns @var{string}, first trimming it to at most @var{n} bytes, then
+removing trailing spaces (but not tabs or other white space).  Returns
+an empty string if @var{n} is zero or negative, or @var{string}
+unchanged if @var{n} is missing.
+@end deftypefn
+
 @cindex substrings
 @cindex strings, taking substrings of
 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
@@ -674,15 +682,15 @@ less than 1, or greater than the length of @var{string}.
 @end deftypefn
 
 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
-Returns a string consisting of the first @var{count} characters from
-@var{string} beginning at position @var{start}.  Returns an empty string
-if @var{start} or @var{count} is system-missing, if @var{start} is less
-than 1 or greater than the number of characters in @var{string}, or if
-@var{count} is less than 1.  Returns a string shorter than @var{count}
-characters if @var{start} + @var{count} - 1 is greater than the number
-of characters in @var{string}.  Examples: @code{SUBSTR("abcdefg", 3, 2)}
-has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
-@code{"sense"}.
+Returns a string consisting of the first @var{count} bytes from
+@var{string} beginning at position @var{start}.  Returns an empty
+string if @var{start} or @var{count} is system-missing, if @var{start}
+is less than 1 or greater than the number of bytes in @var{string}, or
+if @var{count} is less than 1.  Returns a string shorter than
+@var{count} bytes if @var{start} + @var{count} - 1 is greater than the
+number of bytes in @var{string}.  Examples: @code{SUBSTR("abcdefg", 3,
+2)} has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the
+value @code{"sense"}.
 @end deftypefn
 
 @cindex case conversion
@@ -698,7 +706,7 @@ Returns @var{string}, changing lowercase letters to uppercase letters.
 @cindex dates
 
 @cindex dates, valid
-For compatibility, PSPP considers dates before 15 Oct 1582 invalid.
+For compatibility, @pspp{} considers dates before 15 Oct 1582 invalid.
 Most time and date functions will not accept earlier dates.
 
 @menu
@@ -717,10 +725,10 @@ Most time and date functions will not accept earlier dates.
 
 @cindex time, concepts
 @cindex time, intervals
-Times and dates are handled by PSPP as single numbers.  A
-@dfn{time} is an interval.  PSPP measures times in seconds.
+Times and dates are handled by @pspp{} as single numbers.  A
+@dfn{time} is an interval.  @pspp{} measures times in seconds.
 Thus, the following intervals correspond with the numeric values given:
-                
+
 @example
           10 minutes                        600
           1 hour                          3,600
@@ -731,9 +739,9 @@ Thus, the following intervals correspond with the numeric values given:
 @cindex dates, concepts
 @cindex time, instants of
 A @dfn{date}, on the other hand, is a particular instant in the past
-or the future.  PSPP represents a date as a number of seconds since
+or the future.  @pspp{} represents a date as a number of seconds since
 midnight preceding 14 Oct 1582.  Because midnight preceding the dates
-given below correspond with the numeric PSPP dates given:
+given below correspond with the numeric @pspp{} dates given:
 
 @example
               15 Oct 1582                86,400
@@ -763,7 +771,7 @@ Returns a time corresponding to @var{ndays} days.
 Returns a time corresponding to @var{nhours} hours, @var{nmins}
 minutes, and @var{nsecs} seconds.  The arguments may not have mixed
 signs: if any of them are positive, then none may be negative, and
-vice versa.  
+vice versa.
 @end deftypefn
 
 @node Time Extraction
@@ -773,7 +781,7 @@ vice versa.
 @cindex examination, of times
 @cindex time, lengths of
 
-These functions take numeric arguments in PSPP time format and
+These functions take numeric arguments in @pspp{} time format and
 give numeric results.
 
 @cindex days
@@ -886,18 +894,18 @@ Results in a date value corresponding to the day
 @cindex date examination
 
 @cindex arguments, of date extraction functions
-These functions take numeric arguments in PSPP date or time
+These functions take numeric arguments in @pspp{} date or time
 format and give numeric results.  These names are used for arguments:
 
 @table @var
 @item date
-A numeric value in PSPP date format.
+A numeric value in @pspp{} date format.
 
 @item time
-A numeric value in PSPP time format.
+A numeric value in @pspp{} time format.
 
 @item time-or-date
-A numeric value in PSPP time or date format.
+A numeric value in @pspp{} time or date format.
 @end table
 
 @cindex days
@@ -917,7 +925,7 @@ that is, gives the date that @var{date-or-time} is in.
 For a time, results in the number of whole hours beyond the number of
 whole days represented by @var{date-or-time}.  For a date, results in
 the hour (as an integer between 0 and 23) corresponding to
-@var{date-or-time}.  
+@var{date-or-time}.
 @end deftypefn
 
 @cindex day of the year
@@ -939,7 +947,7 @@ corresponding to @var{date}.
 @cindex time, in minutes
 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
 Results in the number of minutes (as an integer between 0 and 59) after
-the last hour in @var{time-or-date}. 
+the last hour in @var{time-or-date}.
 @end deftypefn
 
 @cindex months
@@ -1025,7 +1033,7 @@ accuracy of some procedures may be affected.  If necessary, convert
 times or dates in seconds to some other unit, like days or years,
 before performing analysis.
 
-PSPP supplies a few functions for date arithmetic:
+@pspp{} supplies a few functions for date arithmetic:
 
 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
 Returns the span of time from @var{date1} to @var{date2} in terms of
@@ -1077,7 +1085,8 @@ yields the value of that variable for the case @var{n} before the
 current one.  Results in system-missing (for numeric variables) or
 blanks (for string variables) for the first @var{n} cases.
 
-@code{LAG} obtains values from the cases that become the new active file
+@code{LAG} obtains values from the cases that become the new active
+dataset
 after a procedure executes.  Thus, @code{LAG} will not return values
 from cases dropped by transformations such as @cmd{SELECT IF}, and
 transformations like @cmd{COMPUTE} that modify data will change the
@@ -1097,7 +1106,7 @@ use of a large value will increase memory consumption.
 @cindex Julian date
 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
 @var{year} is a year, either between 0 and 99 or at least 1582.
-Unlike other PSPP date functions, years between 0 and 99 always
+Unlike other @pspp{} date functions, years between 0 and 99 always
 correspond to 1900 through 1999.  @var{month} is a month between 1 and
 13.  @var{day} is a day between 0 and 31.  A @var{day} of 0 refers to
 the last day of the previous month, and a @var{month} of 13 refers to
@@ -1120,7 +1129,7 @@ associated label, then this function returns the empty string.
 @node Statistical Distribution Functions
 @subsection Statistical Distribution Functions
 
-PSPP can calculate several functions of standard statistical
+@pspp{} can calculate several functions of standard statistical
 distributions.  These functions are named systematically based on the
 function and the distribution.  The table below describes the
 statistical distribution functions in general:
@@ -1143,7 +1152,7 @@ a probability.
 Tail probability function for @var{dist}, that is, the probability
 that a random variate drawn from the distribution is greater than
 @var{x}.  The domain of @var{x} depends @var{dist}.  The result is a
-probability.  Only a few distributions include an SIG function.
+probability.  Only a few distributions include an @func{SIG} function.
 
 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
 Inverse distribution function for @var{dist}, the value of @var{x} for
@@ -1159,7 +1168,7 @@ distribution.
 Noncentral probability density function.  The result is the density of
 the given noncentral distribution at @var{x}.  The domain of @var{x}
 depends on @var{dist}.  The range is nonnegative real numbers.  Only a
-few distributions include an NPDF function.
+few distributions include an @func{NPDF} function.
 
 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
 Noncentral cumulative distribution function for @var{dist}, that is,
@@ -1172,8 +1181,8 @@ include an NCDF function.
 The individual distributions are described individually below.
 
 @menu
-* Continuous Distributions::    
-* Discrete Distributions::      
+* Continuous Distributions::
+* Discrete Distributions::
 @end menu
 
 @node Continuous Distributions
@@ -1194,7 +1203,7 @@ Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
 @end deftypefn
 
 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
-@deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
+@deftypefnx {Function} {} CDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
 Bivariate normal distribution of two standard normal variables with
 correlation coefficient @var{rho}.  Two variates @var{x0} and @var{x1}
 must be provided.  Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
@@ -1208,12 +1217,12 @@ Cauchy distribution with location parameter @var{a} and scale
 parameter @var{b}.  Constraints: @var{b} > 0, 0 < @var{p} < 1.
 @end deftypefn
 
-@deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
-@deftypefnx {Function} {} CDF.CHISQ (@var{x}, @var{df})
+@c @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
+@deftypefn {Function} {} CDF.CHISQ (@var{x}, @var{df})
 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
 @deftypefnx {Function} {} RV.CHISQ (@var{df})
-@deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
+@c @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
 Chi-squared distribution with @var{df} degrees of freedom.  The
 noncentral distribution takes an additional parameter @var{lambda}.
@@ -1235,7 +1244,7 @@ Exponential distribution with scale parameter @var{a}.  The inverse of
 Exponential power distribution with positive scale parameter @var{a}
 and nonnegative power parameter @var{b}.  Constraints: @var{a} > 0,
 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1.  This distribution is a
-PSPP extension.
+@pspp{} extension.
 @end deftypefn
 
 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
@@ -1243,8 +1252,8 @@ PSPP extension.
 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
-@deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
-@deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
+@c @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
+@c @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
 F-distribution of two chi-squared deviates with @var{df1} and
 @var{df2} degrees of freedom.  The noncentral distribution takes an
 additional parameter @var{lambda}.  Constraints: @var{df1} > 0,
@@ -1260,21 +1269,21 @@ Gamma distribution with shape parameter @var{a} and scale parameter
 @var{p} < 1.
 @end deftypefn
 
-@deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
-@deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
-Half-normal distribution with location parameter @var{a} and shape
-parameter @var{b}.  Constraints: @var{b} > 0, 0 < @var{p} < 1.
-@end deftypefn
+@c @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
+@c Half-normal distribution with location parameter @var{a} and shape
+@c parameter @var{b}.  Constraints: @var{b} > 0, 0 < @var{p} < 1.
+@c @end deftypefn
 
-@deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
-@deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
-Inverse Gaussian distribution with parameters @var{a} and @var{b}.
-Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
-@end deftypefn
+@c @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
+@c Inverse Gaussian distribution with parameters @var{a} and @var{b}.
+@c Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
+@c @end deftypefn
 
 @deftypefn {Function} {} PDF.LANDAU (@var{x})
 @deftypefnx {Function} {} RV.LANDAU ()
@@ -1340,7 +1349,7 @@ Equivalent to RV.NORMAL(0, @var{sigma}).
 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
 Normal tail distribution with lower limit @var{a} and standard
-deviation @var{sigma}.  This distribution is a PSPP extension.
+deviation @var{sigma}.  This distribution is a @pspp{} extension.
 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
 @end deftypefn
 
@@ -1358,37 +1367,37 @@ parameter @var{b}.  Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
 Rayleigh distribution with scale parameter @var{sigma}.  This
-distribution is a PSPP extension.  Constraints: @var{sigma} > 0,
+distribution is a @pspp{} extension.  Constraints: @var{sigma} > 0,
 @var{x} > 0.
 @end deftypefn
 
 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
 Rayleigh tail distribution with lower limit @var{a} and scale
-parameter @var{sigma}.  This distribution is a PSPP extension.
+parameter @var{sigma}.  This distribution is a @pspp{} extension.
 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
 @end deftypefn
 
-@deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
-Studentized maximum modulus distribution with parameters @var{a} and
-@var{b}.  Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
-@var{p} < 1.
-@end deftypefn
+@c @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
+@c Studentized maximum modulus distribution with parameters @var{a} and
+@c @var{b}.  Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
+@c @var{p} < 1.
+@c @end deftypefn
 
-@deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
-@deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
-Studentized range distribution with parameters @var{a} and @var{b}.
-Constraints:  @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
-1.
-@end deftypefn
+@c @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
+@c @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
+@c Studentized range distribution with parameters @var{a} and @var{b}.
+@c Constraints:  @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
+@c 1.
+@c @end deftypefn
 
 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
 @deftypefnx {Function} {} RV.T (@var{df})
-@deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
-@deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
+@c @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
+@c @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
 T-distribution with @var{df} degrees of freedom.  The noncentral
 distribution takes an additional parameter @var{lambda}.  Constraints:
 @var{df} > 0, 0 < @var{p} < 1.
@@ -1398,14 +1407,14 @@ distribution takes an additional parameter @var{lambda}.  Constraints:
 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
 Type-1 Gumbel distribution with parameters @var{a} and @var{b}.  This
-distribution is a PSPP extension.  Constraints: 0 < @var{p} < 1.
+distribution is a @pspp{} extension.  Constraints: 0 < @var{p} < 1.
 @end deftypefn
 
 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
 Type-2 Gumbel distribution with parameters @var{a} and @var{b}.  This
-distribution is a PSPP extension.  Constraints: @var{x} > 0, 0 <
+distribution is a @pspp{} extension.  Constraints: @var{x} > 0, 0 <
 @var{p} < 1.
 @end deftypefn
 
@@ -1442,9 +1451,9 @@ Bernoulli distribution with probability of success @var{p}.
 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
 @end deftypefn
 
-@deftypefn {Function} {} PDF.BINOMIAL (@var{x}, @var{n}, @var{p})
-@deftypefnx {Function} {} CDF.BINOMIAL (@var{x}, @var{n}, @var{p})
-@deftypefnx {Function} {} RV.BINOMIAL (@var{n}, @var{p})
+@deftypefn {Function} {} PDF.BINOM (@var{x}, @var{n}, @var{p})
+@deftypefnx {Function} {} CDF.BINOM (@var{x}, @var{n}, @var{p})
+@deftypefnx {Function} {} RV.BINOM (@var{n}, @var{p})
 Binomial distribution with @var{n} trials and probability of success
 @var{p}.  Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
 @var{x} <= @var{n}.
@@ -1475,7 +1484,7 @@ Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
-Negative binomial distribution with number of successes paramter
+Negative binomial distribution with number of successes parameter
 @var{n} and probability of success parameter @var{p}.  Constraints:
 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
 @end deftypefn
@@ -1502,7 +1511,7 @@ subtraction.
 
 @enumerate
 @item
-@code{(  )}
+@code{()}
 @item
 @code{**}
 @item
@@ -1512,7 +1521,11 @@ subtraction.
 @item
 @code{+  -}
 @item
-@code{EQ  GE  GT  LE  LT  NE}
+@code{=  >=  >  <=  <  <>}
+@item
+@code{NOT}
+@item
+@code{AND}
 @item
-@code{AND  NOT  OR}
+@code{OR}
 @end enumerate