# SAS Chi-Square Test – SAS PROC FREQ

Keeping you updated with latest technology trends, Join DataFlair on Telegram

## 1. SAS Chi-Square Test – Objective

We looked at SAS t-test, correlation and regression, ANOVA in the previous tutorials, today we will be looking at another process called SAS Chi-Square test, how can we create and a two-way chi-square test in SAS Programming Language. Moreover, we will discuss some SAS Chi-Square Test examples to under this concept better.

## 2. What is Chi-Square Test in SAS

SAS Chi-Square test of Independence is used to determine if there is a significant relationship between two categorical variables.
Chi-Square Testing independence determines whether two or more observations across two populations are dependent on each other (that is, whether one variable helps to estimate the other). Testing for goodness of fit determines if an observed frequency distribution matches a theoretical frequency distribution. In both cases, the equation to calculate the chi-square statistic is where O equals the observed frequency and E the expected frequency.

Let’s learn How to create Pie Chart in SAS and its Types

## 3. SAS PROC FREQ Procedure

We saw the use of PROC FREQ, to create frequency distribution tables, but it can also be used with a CHISQ option to create SAS chi-square test.

Syntax-

```PROC FREQ DATA = dataset;
TABLES variables /CHISQ TESTP=(percentage values);```

Here Percentage Values in the TESTP statement denotes the percentage of levels of the variable.

## 4. One Way Chi-Square Test

In the below SAS Chi-square test example, we consider a SAS chi-square test on the variable named origin in the data set SASHELP.CARS. This variable has three levels and we assign a percentage to each level.

SAS Chi-Square Test Example-

```proc freq data = sashelp.cars;
tables origin /chisq
testp=(0.35 0.40 0.25);
run;```

Also, Study How to Enter and Read Raw Data in SAS

## 5. Two Way Chi-Square Test

In this, two variables are used instead of one and the SAS chi-square test is applied on both of them.

Example-

```proc freq data = sashelp.cars;
tables origin*drivetrain /chisq ;
run;```

This was all about Chi-Square Test Tutorial. Hope you like our explanation of one way and two-way chi-square analysis in SAS Programming Language.