Scripting > UNICOM Intelligence Function Library > Categorical functions > Intersection
 
Intersection
Returns the intersection of two or more category lists--that is, it returns the categories that appear in all of the category lists. The categories are returned in the order in which they appear in the first category list.
Syntax
Intersection(Val [, Val, ...])
Parameters
Val
Type: Categorical
Categorical value.
Vals
Type: None
One or more variant values of type Categorical or Text. Each value specifies a set of categories.
(return)
Type: Categorical
Set of categories that are in all of Val and Vals, in the order in which they occur in Val.
Remarks
If the current value is NULL, Val is an empty Categorical value ({}) and the return value is also an empty Categorical value. If an item in Vals is NULL, the item is ignored.
This function is equivalent to the Multiplication (*) operator for Categorical values, except that Intersection can operate on named categories and the NULL behavior is different. However, using the * operator is generally faster than using the Intersection function.
Examples
Function call
Q1
Q2
Result
Q1.Intersection(Q2)
{4,2,9,6,1,7}
{6,10,3,5,9}
{9,6}
Intersection(Q1, Q2)
{4,2,9,6,1,7}
{3}
{}
Function call
Q1
Q2
Q3
Result
Q1.Intersection(Q2, Q3)
{5,6,8,2,3}
{1,3,4,6}
{2,4,6,7,8}
{6}
Intersection(Q1, Q2, Q3)
{5,6,8,2,3}
NULL
{2,4,6,7,8}
{6,8,2}
Like Difference and XUnion, Intersection is useful when categorical variables have identical or overlapping response lists. The biology and education variables are single response categorical variables that have identical category lists (Yes, No, and Not answered). You could use the Intersection function to return the categories that are in both of the category lists. In the following example, the = operator tests whether the result is the Yes category. You could therefore use this example to select respondents who chose the Yes category in response to both questions.
biology.Intersection(education) = {yes}
See also
Categorical functions