Band
Calculates categories (called bands) for a numeric variable and returns the appropriate category for a specified value in the numeric variable.
Syntax
Band(Val, Min, Size [, Count])
Parameters
Val
Type: None
Variant value of type Long or Double.
Min
Type: Double
Double value specifying the (inclusive) lower boundary of the first band.
Size
Type: Double
Double value specifying the size of each band. If Size <= 0.0, an empty categorical value is returned.
Count
Type: Long
Optional. The number of bands to define. If omitted or < 0, the number of bands is unlimited.
(return)
Type: Categorical
Categorical value containing the number of the band into which the value falls, if it is in the specified range; an empty categorical value otherwise.
Remarks
The first band is numbered 1.
The numeric value is considered to fall into band N if
Val < (Min + N * Size) and
Val >= (Min + (N - 1) * Size) and
N <= Count (if given)
If Val is NULL, the return value is an empty Categorical value ({}).
Examples
Function call
|
Val
|
Result
|
Band(Val, 1.0, 5.0, 10)
|
30
|
{6}
|
Band(Val, 1.0, 5.0, 10)
|
300
|
{}
|
Band(Val, 1.0, 5.0, 100)
|
300
|
{60}
|
Band(Val, 1.0, 50, 10)
|
300
|
{6}
|
The following example could be used to create a derived categorical case data variable from the visits numeric variable, which records the number of times respondents have previously visited the museum. This example would create categories corresponding to 1-5 visits, 6-10 visits, 11-15 visits, and so on.
visits.Band(1, 5)
See also