In some situations, the syntax is easier than the visual menu to use in SPSS. This tutorial provides examples of syntax for chi-square test in SPSS.
2 Examples of Syntax for chi-square test in SPSS
Example 1: One variable
The first example is the one variable chi-square test. The following is example data for one variable, with 3 groups.
Course Names | Student Counts |
---|---|
Math | 25 |
Computer | 50 |
English | 30 |
DATA LIST LIST / a count. BEGIN DATA. 1 25 2 50 3 30 END DATA. WEIGHT BY count. NPAR TESTS /CHISQUARE=a.
Example 2: two variables
We can also do two variable chi-square tests using SPSS syntax. The following is an example of data of two variables.
Course Names | Gender | Student Counts |
---|---|---|
Math | Female | 15 |
Math | Male | 10 |
Computer | Female | 25 |
Computer | Male | 25 |
English | Female | 17 |
English | Male | 13 |
The following is the SPSS syntax.
DATA LIST LIST / Course Gender count. BEGIN DATA 1 1 15 1 2 10 2 1 25 2 2 25 3 1 17 3 2 13 END DATA. WEIGHT BY count. CROSSTABS Course BY Gender /STATISTIC=CHISQ.