A Chi-Square goodness of fit test is used to determine whether or not a categorical variable follows a hypothesized distribution.

The following example explains how to perform a Chi-Square Goodness of Fit Test in SAS.

**Example: Chi-Square Goodness of Fit Test in SAS**

A shop owner claims that an equal number of customers come into his shop each weekday. To test this hypothesis, a researcher records the number of customers that come into the shop in a given week and finds the following:

**Monday:**50 customers**Tuesday:**60 customers**Wednesday:**40 customers**Thursday:**47 customers**Friday:**53 customers

Use the following steps to perform a Chi-Square goodness of fit test in SAS to determine if the data is consistent with the shop owner’s claim.

**Step 1: Create the dataset.**

First, we’ll create a dataset and name it **my_data**:

**/*create dataset*/
data my_data;
input Day $ Customers;
datalines;
Mon 50
Tue 60
Wed 40
Thur 47
Fri 53
;
run;
/*print dataset*/
proc print data=my_data;**

**Step 2: Perform the Chi-Square Goodness of Fit Test.**

Next, we’ll use the following code to perform a Chi-Square Goodness of Fit test:

**/*perform Chi-Square Goodness of Fit test*/
proc freq data=my_data;
tables Day / chisq;
weight Customers;
run;**

From the output we can see:

- The Chi-Square test statistic:
**4.36** - The corresponding p-value:
**0.3595**

Recall that a Chi-Square Goodness of Fit Test uses the following null and alternative hypotheses:

**H**A variable follows a hypothesized distribution._{0}:**H**A variable does not follow a hypothesized distribution._{A}:

Since the p-value (.3595) is not less than 0.05, we fail to reject the null hypothesis.

This means we do not have sufficient evidence to say that the true distribution of customers is different from the distribution that the shop owner claimed.

**Additional Resources**

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

An Introduction to the Chi-Square Goodness of Fit Test

Chi-Square Goodness of Fit Test Calculator

How to Perform a Chi-Square Goodness of Fit Test in Excel