Aggregate is an SPSS command for creating variables holding statistics over cases. This tutorials briefly demonstrates the most common scenarios and points out some best practices.

SPSS Aggregate Command
The SPSS AGGREGATE
command typically works like so:
- One or more
BREAK
variables can be specified.In SPSS versions 15 and below, specifying at least oneBREAK
variable is mandatory. If you want statistics over all cases, usecompute constant = 0.
and useconstant
as the BREAK variable. - All cases with the same value(s) on the break variable(s) are referred to as a break group
- Each break group will become a single case in the aggregated data (unless
MODE = ADDVARIABLES
is used). - This new case has summary statistics over the original cases as new variables. Available statistics include the frequency, mean, maximum and many others. Consult the CSR for a complete overview.
- The result of
AGGREGATE
may be the active dataset, a new dataset or a new data file. (This last option is not available forMODE = ADDVARIABLES
.) A new Dataset must first be declared before it can be specified inAGGREGATE
. - For a very basic demonstration, run the syntax below.
SPSS Aggregate Syntax Example
data list free/id.
begin data
3 5 5 8 8 8 9 9 9 9
end data.
*2. Create Dataset with id counts (called 'freq' for 'frequency').
aggregate outfile *
/break id
/freq = nu.
MODE = ADDVARIABLES

Except for SPSS versions 12 and below, summary statistics of break groups can be appended to a Dataset without actually aggregating it. The syntax below demonstrates this.
SPSS Aggregate Syntax Example
aggregate outfile * mode = addvariables
/break id
/freq = nu.
Statistics over Multiple Variables
Summary statistics can be rendered over multiple variables in one go. The TO and ALL keywords can conveniently shorten the list of variables as shown in the syntax below.
data list free/v1 to v5.
begin data
1 2 3 4 5 6 7 8 9 10
end data.
*2. Aggregate multiple variables at once.
aggregate outfile *
/mean_1 to mean_5 = mean(v1 to v5).
Multiple Statistics
Different summary statistics (over the same or different variables) can be specified in a single command. This is demonstrated below (uses test data from previous example).
aggregate outfile *
/mean_1 to mean_5 = mean(v1 to v5)
/sd_1 to sd_5 = sd(v1 to v5).
Final Note
Lots of different things can be done with the AGGREGATE
command. This tutorial aimed at illustrating the most common scenarios found in practice. It is by no means intended as an exhaustive overview of all options.