@c Use @func when refering to a function.
@c Use @deftypefn for their definitions
@macro func{NAME}
-@code{/NAME/}
+@code{\NAME\}
@end macro
@node Expressions
* 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
@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
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
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
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
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})