How to Perform a Two Sample t-test in SPSS


A two sample t-test is used to test whether or not the means of two populations are equal.

This tutorial explains how to conduct a two sample t-test in SPSS.

Example: Two Sample t-test in SPSS

Researchers want to know if a new fuel treatment leads to a change in the average miles per gallon of a certain car. To test this, they conduct an experiment in which 12 cars receive the new fuel treatment and 12 cars do not.

The following screenshot shows the mpg for each car along with the group they belong to (0 = no fuel treatment, 1 = fuel treatment):

Use the following steps to perform a two sample t-test to determine if there is a difference in average mpg between these two groups, based on the following null and alternative hypotheses:

  • H0μ1 = μ(average mpg between the two populations is equal)
  • H1μ1 ≠ μ(average mpg between the two populations is not equal)

Use a significance level of α = 0.05.

Step 1: Choose the Independent Samples T Test option.

Click the Analyze tab, then Compare Means, then Independent-Samples T Test:

Two sample t-test in SPSS

Step 2: Fill in the necessary values to perform the two sample t-test.

Once you click Independent-Samples T Test, the following window will appear:

Drag the mpg into the box labelled Test Variable(s) and group into the box labelled Grouping Variable. Then click Define Groups and define Group 1 as the rows with value 0 and define Group 2 as the rows with value 1. Then click OK.

Step 3: Interpret the results.

Once you click OK, the results of the two sample t-test will be displayed:

Interpreting output of two sample t-test in SPSS

The first table displays the following summary statistics for both groups:

  • N: The sample size
  • Mean: The mean mpg of cars in each group
  • Std. Deviation: The standard deviation of the mpg of cars in each group
  • Std. Error Mean: The standard error of the mean mpg, calculated as s/√n

The second table displays the results of the two sample t-test. The first row shows the results of the test if you assume that the variance between the two groups is equal. The second row shows the results of the test if you don’t make this assumption. 

In this case, the two versions of the test produce nearly identical results. Thus, we will simply refer to the results of the first row:

  • t: The test statistic, found to be -1.428
  • df: The degrees of freedom, calculated as n1+n2-2 = 12+12-2 = 22
  • Sig. (2-tailed): The two-sided p-value that corresponds to a t value of -1.428 with df=22
  • Mean Difference: The difference between the two sample means
  • Std. Error Difference: The standard error of the mean difference
  • 95% C.I. of the Difference: The 95% confidence interval for the true difference between the two population means

Since the p-value of the test (.167) is not less than 0.05, we fail to reject the null hypothesis. We do not have sufficient evidence to say that the true mean mpg is different between cars that receive treatment and cars that don’t.

3 Replies to “How to Perform a Two Sample t-test in SPSS”

  1. Hi There! I tried running the two-tailed t-test as you instructed but I am obviously doing something wrong. I received a Warning #5281. It says the Independent samples table is not produced; effect sized table is not produced. I have a table. What step am I missing to get the program to see the table? Please advise.

    1. It sounds like you’re very close—you’ve likely entered the data correctly, but SPSS isn’t recognizing how to *use* it for the independent samples t-test. That Warning #5281 usually shows up when SPSS doesn’t have a proper grouping variable defined, even if the data table itself looks fine.

      Here’s the most common issue: SPSS needs two things for an independent samples t-test:

      1. A test variable (your numeric outcome—e.g., scores, measurements, etc.)
      2. A grouping variable (a categorical variable that tells SPSS which rows belong to Group 1 vs Group 2)

      If either of those isn’t set up correctly, SPSS won’t produce the Independent Samples Test table.

      A few things to check:

      First, make sure your data is in the correct format. In SPSS, the data should be in “long format,” meaning:

      * One column contains the values you want to compare (e.g., test scores)
      * A second column identifies the group (e.g., 1 = control, 2 = treatment)

      A common mistake is entering the data in two separate columns (one column per group). That format works for some analyses, but not for the independent samples t-test in SPSS.

      Second, when you run the test (Analyze → Compare Means → Independent-Samples T Test), make sure you:

      * Move your numeric variable into the Test Variable(s) box
      * Move your group variable into the Grouping Variable box
      * Then click Define Groups and explicitly enter the group codes (for example, 1 and 2)

      That last step—*Define Groups*—is often the missing piece. If you skip it, SPSS doesn’t know which values belong to which group, and you’ll get the warning you’re seeing.

      Third, check your grouping variable in Variable View:

      * It should be set to Numeric (not string)
      * The values should be consistent (e.g., only 1 and 2, no blanks or text)
      * You can optionally assign value labels (e.g., 1 = Male, 2 = Female), but the underlying values still need to be numeric

      Finally, scan your data for missing or invalid entries. If SPSS can’t find valid cases for both groups, it won’t produce the test table.

      So in short, the issue usually isn’t that SPSS “can’t see the table”—it’s that it doesn’t see a properly defined grouping structure. Once the grouping variable is clearly defined and linked using the “Define Groups” step, the output tables should appear normally.

Leave a Reply

Your email address will not be published. Required fields are marked *