A paired samples t-test is used to compare the means of two samples when each observation in one sample can be paired with an observation in the other sample.

This tutorial explains how to perform a paired samples t-test in SAS.

**Example: Paired Samples t-Test in SAS**

Suppose a professor wants to determine if a certain study program affects test scores. To test this, he randomly selects 15 students to take a pre-test. Then, he has each student use the study program for one month and then a post-test of similar difficulty.

The test scores for each of the 15 students are shown below:

To compare the difference between the mean scores on the pre-test and post-test, the professor can use a paired samples t-test because for each student their pre-test score can be paired with their post-test score.

Use the following steps to perform this paired samples t-test in SAS:

**Step 1: Create the Data**

First, let’s use the following code to create the dataset in SAS:

/*create dataset*/ data test_scores; input pre post; datalines; 88 91 82 84 84 88 93 90 75 79 78 80 84 88 87 90 95 90 91 96 83 88 89 89 77 81 68 74 91 92 ; run; /*view dataset*/ proc print data=test_scores;

**Step 2: Perform the Paired Samples t-test**

Next, we can use **proc ttest** to perform the paired samples t-test:

/*perform paired samples t-test*/ proc ttest data=test_scores alpha=.05; paired pre*post; run;

From the output we can see the following:

- Mean difference between pre-test and post-test score:
**-2.3333** - 95% Confidence Interval for Mean difference:
**[-4.0165, -.6502]**

We can also see the t test statistic and corresponding two-sided p-value:

- t test statistic:
**-2.97** - p-value:
**.0101**

In this example, the paired samples t-test uses the following null and alternative hypotheses:

**H**The mean pre-test and post-test scores are equal_{0}:**H**The mean pre-test and post-test scores are_{A}:*not*equal

Since the p-value (**0.0101**) is less than 0.05, we reject the null hypothesis.

This means we have sufficient evidence to say that the true mean test score is different for students before and after participating in the study program.

**Additional Resources**

The following tutorials explain how to perform other common statistical tests in SAS:

How to Perform a One Sample t-Test in SAS

How to Perform a Two Sample t-Test in SAS

How to Perform a Wilcoxon Signed Rank Test in SAS