AGGREGATE function

Description

AGGREGATE(statistic[,allowmissing],variable,group[,filter]) calculates the specified statistic of a variable in the group a case belongs to.

Parameters

• statistic: must be COUNT, MEAN, MEDIAN, MIN, MAX, PERCENTILE, SEM, STDEV, VAR, SUM, SUMSQ, GEOMEAN or HARMEAN.

When PERCENTILE is specified, the function takes one more parameter "centile", which is a value between 0 and 100. See the example below.

• allowmissing: an optional parameter, if TRUE then the function will also return a value for a case in which data are missing for the continuous variable.
• variable: a continuous variable for which to calculate the statistic of interest
• group: a categorical grouping variable (e.g. gender)
• filter: an optional filter on the continuous variable.

Examples

 Column AG1 AGGREGATE(MEAN,age,gender) returns the MEAN age in the group defined by the variable gender. Column AG2 AGGREGATE(MEAN,TRUE,age,gender) returns the MEAN age in the group defined by the variable gender, even for a case in which the age value is missing. Column AG3 AGGREGATE(MEAN,age,gender,success=1) returns the MEAN age of cases where success=1, in the group defined by the variable gender. Column AG4 AGGREGATE(PERCENTILE,TRUE,75,age,gender) returns the 75th percentile of age in the group defined by the variable gender, even for a case in which the age value is missing. Column AG5 AGGREGATE(PERCENTILE,75,age,gender) returns the 75th percentile of age in the group defined by the variable gender, but not for cases in which the age value is missing.

Note: we have used Auto-values in this example.

Related functions

This site uses cookies to store information on your computer. More info...