SAS Chi-Square Test – SAS PROC FREQ

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.

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

SAS Chi Square Test

Introduction to Chi-Square Test & Proc FREQ

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;
SAS Chi Square Test

SAS Chi Square Test

 

SAS Chi Square Test

One Way Chi-Square Test Output

 

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;
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.

Read about Splitting and Subsetting Datasets in SAS

6. Conclusion

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.

Related Topic- SAS Numeric Format 

For reference 

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.