How can I perform Welch’s t-test in SAS? 2

How can I perform Welch’s t-test in SAS?

Welch’s t-test is a statistical method used to compare the means of two independent groups with unequal variances. In order to perform this test in SAS, you will need to follow the following steps:

1. Load your data into SAS and ensure that it is formatted correctly for analysis.

2. Use the PROC TTEST procedure to specify the variables you want to compare and the desired options, such as ALPHA level and type of t-test (two-tailed or one-tailed).

3. Add the keyword WELCH in the PROC TTEST statement to indicate that you want to perform Welch’s t-test.

4. Run the procedure and review the output, which will include relevant statistics such as the t-value, degrees of freedom, and p-value.

5. Interpret the results and make a conclusion about the significance of the difference between the two groups.

Overall, performing Welch’s t-test in SAS requires the use of the PROC TTEST procedure with the addition of the keyword WELCH to specify the type of t-test desired. This allows for a thorough and accurate comparison of means between two groups with unequal variances.

Perform Welch’s t-Test in SAS


is used to compare the means between two independent groups when it is not assumed that the two groups have equal variances.

This tutorial explains how to perform a Welch’s t-test in SAS.

Example: Welch’s t-Test in SAS

Suppose a teacher wants to compare the exam scores of 12 students who used an exam prep booklet to prepare for some exam vs. 12 students who did not.

The following lists show the exam scores for the students in each group:

Booklet: 90, 85, 88, 89, 94, 91, 79, 83, 87, 88, 91, 90

No Booklet: 67, 90, 71, 95, 88, 83, 72, 66, 75, 86, 93, 84

Use the following steps to perform Welch’s t-test to determine if the mean exam score is equal between the two groups.

Step 1: Create the data.

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

/*create dataset*/
data exam_scores;
    input group $ score;
    datalines;
booklet 90
booklet 85
booklet 88
booklet 89
booklet 94
booklet 91
booklet 79
booklet 83
booklet 87
booklet 88
booklet 91
booklet 90
no_booklet 67
no_booklet 90
no_booklet 71
no_booklet 95
no_booklet 88
no_booklet 83
no_booklet 72
no_booklet 66
no_booklet 75
no_booklet 86
no_booklet 93
no_booklet 84
;
run;

Step 2: Perform Welch’s t-test.

Next, we’ll use proc ttest to perform Welch’s t-test:

/*perform Welch's t-test*/
proc ttest data=exam_scores alpha=0.05;
    class group;
    var score;
run;

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

This F-test uses the following null and alternative hypotheses:

  • H0: The variances are equal.
  • HA: The variances are not equal.

Since the p-value (.0046) of this test is less than .05, we reject the null hypothesis. This means the two sample variances are not equal.

Thus, we must refer to the row titled Unequal in the second to last table to determine the t value and corresponding p-value to use:

  • t Value: 2.24
  • p-value: .0417

Recall that Welch’s t-test uses the following null and alternative hypotheses:

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

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

This means we have sufficient evidence to say that the mean exam score between the two groups is not equal.

Bonus: Feel free to use this to automatically perform Welch’s t-test for any two samples.

Additional Resources

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

Cite this article

stats writer (2024). How can I perform Welch’s t-test in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-perform-welchs-t-test-in-sas/

stats writer. "How can I perform Welch’s t-test in SAS?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-i-perform-welchs-t-test-in-sas/.

stats writer. "How can I perform Welch’s t-test in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-perform-welchs-t-test-in-sas/.

stats writer (2024) 'How can I perform Welch’s t-test in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-perform-welchs-t-test-in-sas/.

[1] stats writer, "How can I perform Welch’s t-test in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.

stats writer. How can I perform Welch’s t-test in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

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