range2list(X;L;R)

Returns a value from a list of numeric or text values that indicates which of the intervals, defined by a specified list of numbers, that a given value falls.

Syntax

range2list(X;L;R)

Input

Argument Type Description
X any numeric type A scalar value or the name of a column
L any numeric type A scalar value

A comma- or space-separated list of numbers

R any simple type A scalar value

A comma- or space-separated list of numeric or text values

Note: R must have one more element than L.

Return Value

Returns a numeric or text value (depending on the type of the elements in R) indicating into which interval X falls. The intervals are defined by the list L.

The result is:
  • the first element of R if X is less than or equal to the least element in L
  • the last element of R if X is greater than the greatest element in L
  • the element in R corresponding to the matching interval in L, otherwise

If R contains all integer values, the result is integer. If R contains all decimal values or a mix of decimal and integer values, the result is decimal. If R contains all text values or a mix of text and numeric values, the result is text.

If X is N/A, the first element of R is returned.

Sample Usage

value list bucket range2list(value;list;bucket)
-5 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'too few'
10 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'enough'
30 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'even more'
75 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'lots'
200 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'too many'
10.5 0,10.25,25.25,50,100.75 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'more'
NA 0,10,25,50,100 'too few' 'enough' 'more' 'even more' 'lots' 'too many' 'too few'
10 0,10,25,50,100 1 2 3 4 5 6 2 (integer)
10 0,10,25,50,100 1 2 3.25 4 5 6 2 (decimal)
10 0,10,25,50,100 1 2 'three' 4 5 6 '2'