X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=doc%2Fexpressions.texi;h=c530f7a7a839dddd3fe54434bb3e23d43bbff977;hb=f790dbda9d498eef9c9c0a49078adbeecf768d56;hp=1570d0dfb437ce72072a677b52898484534395cd;hpb=30b49ef972d0ff4cd5f5ecda6a447968bc05f356;p=pspp diff --git a/doc/expressions.texi b/doc/expressions.texi index 1570d0dfb4..c530f7a7a8 100644 --- a/doc/expressions.texi +++ b/doc/expressions.texi @@ -1,7 +1,16 @@ -@c Use @func when refering to a function. +@c PSPP - a program for statistical analysis. +@c Copyright (C) 2017 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/} +@code{\NAME\} @end macro @node Expressions @@ -262,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 +* Statistical Functions:: CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER - RINDEX RPAD RTRIM STRING SUBSTR UPCASE + 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 @@ -331,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 @@ -404,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{}) @@ -420,10 +443,7 @@ 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}) @@ -506,6 +526,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 @@ -616,8 +643,17 @@ right-padded with spaces. If @var{string} is not in the correct format for @var{format}, system-missing is returned. @end deftypefn +@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, searching backwards -@deftypefn {Function} {} RINDEX (@var{string}, @var{format}) +@deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}) 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 @@ -630,7 +666,7 @@ 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. +if @var{needle} is an empty string or if needle_len is less than 1. @end deftypefn @cindex padding strings @@ -671,6 +707,15 @@ 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. Returns an empty string if @var{n} is +missing or negative. +@end deftypefn + @cindex substrings @cindex strings, taking substrings of @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})