Table of Contents
A paired samples t-test is a statistical test used to compare the means of two related samples. In SAS, this can be performed by using the PROC TTEST procedure. First, the data should be organized in a format where each observation represents the paired values from the two samples. Then, the PROC TTEST procedure should be called and the two variables representing the samples should be specified in the PAIRED statement. The output will provide the t-statistic, degrees of freedom, and p-value, which can be used to determine if there is a significant difference between the means of the two samples. This procedure is commonly used in research and data analysis to assess the effectiveness of a treatment or intervention.
Perform a Paired Samples t-Test in SAS
A is used to compare the means of two samples when each 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 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 printdata=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 :
- H0: The mean pre-test and post-test scores are equal
- HA: The mean pre-test and post-test scores are 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:
Cite this article
stats writer (2024). How do you perform a paired samples t-test in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-you-perform-a-paired-samples-t-test-in-sas/
stats writer. "How do you perform a paired samples t-test in SAS?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-do-you-perform-a-paired-samples-t-test-in-sas/.
stats writer. "How do you perform a paired samples t-test in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-you-perform-a-paired-samples-t-test-in-sas/.
stats writer (2024) 'How do you perform a paired samples t-test in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-you-perform-a-paired-samples-t-test-in-sas/.
[1] stats writer, "How do you perform a paired samples t-test in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How do you perform a paired samples t-test in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
