collapse Function (GPL)

Syntax

collapse(category(<algebra>), minimumPercent(<numeric>), sumVariable(<algebra>),
         otherValue("label"))

<algebra>. Graph algebra, although in this case, the algebra should identify only one variable. The variable in category() identifies the variable whose categories are collapsed. The variable in sumVariable() identifies the variable whose sum for the total compared to the sum for a particular category determines whether the category is collapsed.

<numeric>. A numeric value between 0 and 100 indicating a percentage. A category is collapsed if its sum is less than the specified percentage of the total sum for sumVariable.

"label". The label for the new variable containing the collapsed categories. This is the text that identifies the variable in the graph.

Description

Collapse small categories of a categorical variable to create a new categorical variable. The function collapses the categories by recoding them to the value specified by otherValue.

Examples

Figure 1. Example: Collapsing categories whose sum is less than 10% of total
TRANS: educ_collapse = collapse(category(educ), minimumPercent(10), sumVariable(salary), 
                                otherValue("Other"))
ELEMENT: interval(position(summary.sum(educ_collapse*salary))))