* Set Membership:: ANY RANGE
* Statistical Functions:: CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE
* String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
- REPLACE 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
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})
[[replace('banana', 'ba', '', -1)], ["banana"]],
[[replace('banana', 'ba', '', $sysmis)], ["banana"]])
-CHECK_EXPR_EVAL([lpad number ltrim lpad rtrim rpad string substr upcase],
+CHECK_EXPR_EVAL([lpad number ltrim lpad rtrim rpad string strunc substr upcase],
[[lpad('abc', -1)], [""]],
[[lpad('abc', 0)], ["abc"]],
[[lpad('abc', 2)], ["abc"]],
[error: DEBUG EVALUATE: Type mismatch invoking STRING(number, num_output_format) as string(number, format).]],
[[string(123, e6.0)], ["1E+002"]],
+ [[strunc('a c ', 9)], ["a c"]],
+ [[strunc('a c ', 7)], ["a c"]],
+ [[strunc('a c ', 6)], ["a c"]],
+ [[strunc('a c ', 5)], ["a c"]],
+ [[strunc('a c ', 4)], ["a c"]],
+ [[strunc('a c ', 3)], ["a c"]],
+ [[strunc('a c ', 2)], ["a"]],
+ [[strunc('a c ', 1)], ["a"]],
+ [[strunc('a c ', 0)], [""]],
+ [[strunc('a c ', -1)], [""]],
+ [[strunc('a c ', $sysmis)], [""]],
+ [[strunc(' abc ', 9)], [" abc"]],
+ [[strunc(' abc ', 8)], [" abc"]],
+ [[strunc(' abc ', 7)], [" abc"]],
+ [[strunc(' abc ', 6)], [" abc"]],
+ [[strunc(' abc ', 5)], [" abc"]],
+ [[strunc(' abc ', 4)], [" ab"]],
+ [[strunc(' abc ', 3)], [" a"]],
+ [[strunc(' abc ', 2)], [""]],
+ [[strunc(' abc ', 1)], [""]],
+ [[strunc(' abc ', -1)], [""]],
+ [[strunc(' abc ', $sysmis)], [""]],
+
[[substr('abcdefgh', -5)], [""]],
[[substr('abcdefgh', 0)], [""]],
[[substr('abcdefgh', 1)], ["abcdefgh"]],