Table of Contents
Levene’s test is a statistical method used to determine the equality of variances between two or more groups in a dataset. In SAS, this test can be performed by using the PROC GLM procedure. First, the data should be organized in a tabular format with one column for the group variable and another column for the variable of interest. Then, the PROC GLM statement should be used, specifying the group variable as the class variable and the variable of interest as the dependent variable. Finally, the LEVENE option should be added to the MODEL statement to request the Levene’s test. The output will include the test statistics and p-values for each group, allowing for the determination of the significance of any differences in variances between groups.
Perform Levene’s Test in SAS
Many statistical tests (like a ) make the assumption that the variance among several groups is equal.
One way to formally test this assumption is to use Levene’s Test, which tests whether or not the variance among two or more groups is equal.
This test uses the following :
- Null hypothesis (H0): The variance among the groups is equal.
- Alternative hypothesis (HA): The variance among the groups is not equal.
If the from the test is less than our chosen significance level, we can reject the null hypothesis and conclude that we have enough evidence to state that the variance among the groups is not equal.
The following example shows how to perform Levene’s test in SAS.
Example: Levene’s Test in SAS
Suppose we have the following dataset in SAS that shows the fertilizer used on various plants and the resulting growth (in inches) for 18 plants:
/*create dataset*/ data my_data; input fertilizer $ growth; datalines; A 29 A 23 A 20 A 21 A 33 A 30 B 19 B 19 B 17 B 24 B 25 B 29 C 21 C 22 C 30 C 25 C 24 C 33 ; run; /*view dataset*/ proc printdata=my_data;

Suppose we would like to perform a one-way ANOVA to determine if the mean plant growth is equal between the three different fertilizers.
We can use the following syntax in SAS to perform a one-way ANOVA with the statement hovtest=levene(type=abs) to also perform Levene’s test to determine whether or not the three groups have equal variances:
/*perform one-way ANOVA along with Levene's test*/
proc glmdata = my_data;
class fertilizer;
model growth = fertilizer;
means fertilizer / hovtest=levene(type=abs);
run;The first table in the output shows the results of the one-way ANOVA:

The p-value in the ANOVA table is 0.3358.
Since this value is not less than .05, we would conclude that there is no statistically significant difference in mean plant growth between the three fertilizers.
We can see the output of Levene’s test in the second table in the output:

From this table we can see that the p-value of Levene’s test is 0.6745.
Since this value is not less than .05, we fail to reject the null hypothesis of the test.
In other words, we can assume that the three groups have equal variances.
Note: We used the argument type=abs in the levene() function to specify that we should use the absolute value of the residuals when performing Levene’s test. This is consistent with the method used by other statistical software such as R.
The following tutorials explain how to perform other common statistical tests in SAS:
Cite this article
stats writer (2024). How can I perform Levene’s test in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-perform-levenes-test-in-sas/
stats writer. "How can I perform Levene’s test in SAS?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-perform-levenes-test-in-sas/.
stats writer. "How can I perform Levene’s test in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-perform-levenes-test-in-sas/.
stats writer (2024) 'How can I perform Levene’s test in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-perform-levenes-test-in-sas/.
[1] stats writer, "How can I perform Levene’s test in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I perform Levene’s test in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
