Scripting > UNICOM Intelligence Function Library > Miscellaneous functions > EqualBand
 
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(Val, Count, Min, Max)
Parameters
Val
Type: None
Variant value of type Long or Double.
Count
Type: Long
The number of bands to define between Min and Max. If Count < 1, an empty categorical value is returned.
Min
Type: Double
Double value specifying the (inclusive) lower bound of the first band.
Max
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.
Remarks
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 Val 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 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 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
Band
Miscellaneous functions