SPSS tutorials website header logo SPSS TUTORIALS BASICS ANOVA REGRESSION FACTOR CORRELATION

SPSS AGGREGATE Command

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

SPSS Aggregate Command

The SPSS AGGREGATE command typically works like so:

SPSS Aggregate Syntax Example

*1. Create test data.

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

SPSS Aggregate Mode Addvariables SPSS Aggregate - 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

*Append id counts to Dataset.

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.

*1. Create test data.

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).

* Different summary statistics in a single command.

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.

Tell us what you think!

*Required field. Your comment will show up after approval from a moderator.

THIS TUTORIAL HAS 3 COMMENTS: