EqualBand
Calculates a specified number of equal categories (called bands) for a numeric variable and returns the appropriate category for a specified value in the numeric variable.
Syntax
EqualBand(<value>, <count>, <minimum>, <maximum>)
Parameters
<value>
Type: None
Variant value of type Long or Double.
<count>
Type: Long
The number of bands to define between <minimum> and <maximum>. If <count> < 1, an empty categorical value is returned.
<minimum>
Type: Double
Double value specifying the (inclusive) lower bound of the first band.
<maximum>
Type: Double
Double value specifying the (exclusive) upper bound of the last band.
(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.
Notes
The first band is numbered 1.
The numeric value is considered to fall into band N if
Val < Min + N * (Max - Min) / Count and
Val >= Min + (N - 1) * (Max - Min) / Count
If <value> is NULL, the return value is an empty Categorical value ({}).
Examples
Function call
|
Val
|
Result
|
EqualBand(Val, 30, 0, 400)
|
300
|
{23}
|
EqualBand(Val, 10, 50, 400)
|
300
|
{8}
|
The following example creates 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 ten categories. Respondents who have visited between 1 and 10 times would be in the first category, those who have visited between 11 and 20 times would be in the second category, and so on.
visits.EqualBand(10, 1, 100)
See also