Table of Contents

In SAS, performing a Chi-Square Goodness of Fit Test involves first specifying the observed and expected counts of each category of a categorical variable in a data set. Then, using the PROC FREQ procedure and specifying a TABLES statement with the CHISQ option, the Chi-Square statistic and associated p-value are produced to test the goodness of fit. The results can be interpreted for significance based on the p-value or the chi-square statistic.

A is used to determine whether or not a 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 :

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

Since the (.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.

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