How do you perform a Two Sample t-Test in SAS? 2

How do you perform a Two Sample t-Test in SAS?

A Two Sample t-Test in SAS is a statistical analysis method used to compare the means of two independent groups. It involves calculating the t-statistic, which measures the difference between the means of the two groups and takes into account the variation within each group. To perform a Two Sample t-Test in SAS, the data for the two groups must be organized and imported into the software. The t-Test procedure in SAS then calculates the t-statistic and p-value, which can be used to determine if there is a significant difference between the two group means. This test is commonly used in research and decision-making processes to evaluate the effectiveness of a treatment or intervention.

Perform a Two Sample t-Test in SAS


A two sample t-test is used to determine whether or not two are equal.

This tutorial explains how to perform a two sample t-test in SAS.

Example: Two Sample t-Test in SAS

Suppose a botanist wants to know if the mean height of two different species of plants is equal. She collects a of 12 plants from each species and and records their heights in inches.

The heights are as follows:

Sample 1: 13, 15, 15, 16, 16, 16, 17, 18, 18, 19, 20, 21

Sample 2: 15, 15, 16, 18, 19, 19, 19, 20, 21, 23, 23, 24

Use the following steps to conduct a two sample t-test to determine if the mean height is equal between the two species.

Step 1: Create the data.

First, we’ll use the following code to create the dataset in SAS:

/*create dataset*/
data my_data;
    input Species $ Height;
    datalines;
1 13
1 15
1 15
1 16
1 16
1 16
1 17
1 18
1 18
1 19
1 20
1 21
2 15
2 15
2 16
2 18
2 19
2 19
2 19
2 20
2 21
2 23
2 23
2 24
;run;

Step 2: Perform a two sample t-test.

Next, we’ll use proc ttest to perform the two sample t-test:

/*perform two sample t-test*/
proc ttestdata=my_data sides=2alpha=0.05h0=0;
    class Species;
    var Height;
run;

The last table titled Equality of Variances performs an F-test to determine if the variances are equal between the two samples.

Since the p-value (.3577) of this test is not less than .05, we can assume the two sample variances are equal.

  • t Value: -2.11
  • p-value: .0460

Recall that the two sample t-test uses the following null and alternative hypotheses:

  • H0μ1 = μ2
  • HA: μ1 ≠ μ2

Since the p-value (.0460) is less than .05, we reject the null hypothesis.

This means we have sufficient evidence to say that the mean height between the two species of plants is not equal.

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 Two Sample t-Test in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-you-perform-a-two-sample-t-test-in-sas/

stats writer. "How do you perform a Two Sample t-Test in SAS?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-do-you-perform-a-two-sample-t-test-in-sas/.

stats writer. "How do you perform a Two Sample t-Test in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-you-perform-a-two-sample-t-test-in-sas/.

stats writer (2024) 'How do you perform a Two Sample t-Test in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-you-perform-a-two-sample-t-test-in-sas/.

[1] stats writer, "How do you perform a Two Sample t-Test in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.

stats writer. How do you perform a Two Sample t-Test in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top