SAS Chi-Square Test – SAS PROC FREQ

We offer you a brighter future with FREE online courses - Start Now!!

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.

So, let’s start with SAS Chi-Square Test and SAS Proc Freq.

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.


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.


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.

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 =;
tables origin /chisq
testp=(0.35 0.40 0.25);
SAS Chi Square Test

SAS Chi Square Test


SAS Chi Square Test

One Way Chi-Square Test Output

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.


proc freq data =;
tables origin*drivetrain /chisq ;
SAS Chi Square Test

Two Way Chi-Square Test Example with Output

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.


Hope you all understood what is a chi-square test and how can we create it in SAS. We also saw a two-way chi-square test in SAS. In conclusion, we saw some SAS Chi-square test examples.

Furthermore, if you have any query feel free to ask in a comment section. and stay tuned to learn more interesting things in SAS.

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *