How do you perform a Chi-Square Test of Independence in SAS? 2

How do you perform a Chi-Square Test of Independence in SAS?

The Chi-Square Test of Independence is a statistical method used to determine the relationship between two categorical variables. In SAS, this test can be performed by using the PROC FREQ procedure. First, the data must be organized in a contingency table format with the two variables of interest. Then, the PROC FREQ statement is used to specify the variables and the CHISQ option is added to the TABLES statement to request the Chi-Square test. The results of the test, including the Chi-Square statistic and the p-value, will be displayed in the output. This test is useful for determining if there is a significant association between two variables, and can provide valuable insights for further analysis.

Perform a Chi-Square Test of Independence in SAS


A Chi-Square Test of Independence is used to determine whether or not there is a significant association between two .

The following example shows how to perform a Chi-Square Test of Independence in SAS.

Example: Chi-Square Test of Independence in SAS

Suppose we want to know whether or not gender is associated with political party preference. We take a of 500 voters and survey them on their political party preference.

The following table shows the results of the survey:

 RepublicanDemocratIndependentTotal
Male1209040250
Female1109545250
Total23018585500

Use the following steps to perform a Chi-Square Test of Independence in SAS to determine if gender is associated with political party preference.

Step 1: Create the data.

First, we will create a dataset in SAS to hold the survey responses:

/*create dataset*/
data my_data;
	input Gender $ Party $ Count;
	datalines;
Male Rep 120
Male Dem 90
Male Ind 40
Female Rep 110
Female Dem 95
Female Ind 45
;
run;

/*print dataset*/
proc printdata=my_data;

Step 2: Perform the Chi-Square Test of Independence.

Next, we can use the following code to perform the Chi-Square Test of Independence:

/*perform Chi-Square Test of Independence*/
proc freqdata=my_data;
	tables Gender*Party / chisq;
	weight Count;
run;

Chi-square test of independence in SAS

There are two values of interest in the output:

  • Chi-Square Test Statistic: 0.8640
  • Corresponding p-value: 0.6492
  • H0: The two variables are independent.
  • HA: The two variables are not independent.

Since the (0.6492) of the test is not less than 0.05, we fail to reject the null hypothesis.

This means we do not have sufficient evidence to say that there is an association between gender and political party preference.

In other words, gender and political party preference are independent.

Additional Resources

The following tutorials provide additional information about the Chi-Square test of independence:

Cite this article

stats writer (2024). How do you perform a Chi-Square Test of Independence in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-you-perform-a-chi-square-test-of-independence-in-sas/

stats writer. "How do you perform a Chi-Square Test of Independence in SAS?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-do-you-perform-a-chi-square-test-of-independence-in-sas/.

stats writer. "How do you perform a Chi-Square Test of Independence in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-you-perform-a-chi-square-test-of-independence-in-sas/.

stats writer (2024) 'How do you perform a Chi-Square Test of Independence in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-you-perform-a-chi-square-test-of-independence-in-sas/.

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

stats writer. How do you perform a Chi-Square Test of Independence in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

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