1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([CROSSTABS procedure])
19 dnl Based on bug #60982.
20 AT_SETUP([CROSSTABS residuals])
21 AT_DATA([crosstabs.sps],
23 DATA LIST LIST NOTABLE/ r c n.
35 CROSSTABS r by c /STATISTICS=CHISQ
36 /CELLS=COUNT EXPECTED RESID SRESID ASRESID.
38 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
41 ,Valid,,Missing,,Total,
42 ,N,Percent,N,Percent,N,Percent
43 r × c,161.00,100.0%,.00,.0%,161.00,100.0%
48 r,1.00,Count,26.00,31.00,57.00
49 ,,Expected,25.84,31.16,.35
51 ,,Std. Residual,.03,-.03,
52 ,,Adjusted Residual,.05,-.05,
53 ,2.00,Count,12.00,32.00,44.00
54 ,,Expected,19.95,24.05,.27
55 ,,Residual,-7.95,7.95,
56 ,,Std. Residual,-1.78,1.62,
57 ,,Adjusted Residual,-2.82,2.82,
58 ,3.00,Count,27.00,18.00,45.00
59 ,,Expected,20.40,24.60,.28
60 ,,Residual,6.60,-6.60,
61 ,,Std. Residual,1.46,-1.33,
62 ,,Adjusted Residual,2.33,-2.33,
63 ,4.00,Count,8.00,7.00,15.00
64 ,,Expected,6.80,8.20,.09
65 ,,Residual,1.20,-1.20,
66 ,,Std. Residual,.46,-.42,
67 ,,Adjusted Residual,.65,-.65,
68 Total,,Count,73.00,88.00,161.00
69 ,,Expected,.45,.55,1.00
71 Table: Chi-Square Tests
72 ,Value,df,Asymptotic Sig. (2-tailed)
73 Pearson Chi-Square,10.09,3.00,.018
74 Likelihood Ratio,10.35,3.00,.016
75 Linear-by-Linear Association,1.96,1.00,.162
76 N of Valid Cases,161.00,,
80 AT_SETUP([CROSSTABS integer mode crash])
81 AT_DATA([crosstabs.sps],
82 [DATA LIST LIST /A * B * X * Y * .
87 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
89 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
90 AT_CHECK([cat pspp.csv], [0],
91 [[Table: Reading free-form data from INLINE.
100 ,Valid,,Missing,,Total,
101 ,N,Percent,N,Percent,N,Percent
102 X × Y,1,100.0%,0,.0%,1,100.0%
105 ,,,Y,,,,,,,Total
106 ,,,1.00,2.00,3.00,4.00,5.00,6.00,7.00,
107 X,1.00,Count,0,0,0,0,0,0,0,0
108 ,2.00,Count,0,0,0,0,0,0,0,0
109 ,3.00,Count,0,0,0,0,0,0,0,0
110 ,4.00,Count,0,0,0,0,1,0,0,1
111 ,5.00,Count,0,0,0,0,0,0,0,0
112 ,6.00,Count,0,0,0,0,0,0,0,0
113 ,7.00,Count,0,0,0,0,0,0,0,0
114 Total,,Count,0,0,0,0,1,0,0,1
119 AT_SETUP([CROSSTABS integer mode crash 2])
120 AT_DATA([crosstabs.sps], [dnl
127 VARIABLES x (1,3) y (1,7)
130 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
131 [[Table: Reading free-form data from INLINE.
138 ,Valid,,Missing,,Total,
139 ,N,Percent,N,Percent,N,Percent
140 x × y,0,.0%,1,100.0%,1,100.0%
143 ,,,y,,,,,,,Total
144 ,,,1.00,2.00,3.00,4.00,5.00,6.00,7.00,
145 x,1.00,Count,,,,,,,,
146 ,2.00,Count,,,,,,,,
147 ,3.00,Count,,,,,,,,
148 Total,,Count,,,,,,,,
153 AT_SETUP([CROSSTABS long string crash])
154 AT_DATA([crosstabs.sps],
155 [data list list /x * y (a18).
166 CROSSTABS /TABLES = x BY y.
168 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
169 [[Table: Reading free-form data from INLINE.
174 "crosstabs.sps:4: warning: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
176 "crosstabs.sps:6: warning: Missing value(s) for all variables from x onward. These will be filled with the system-missing value or blanks, as appropriate."
180 ,Valid,,Missing,,Total,
181 ,N,Percent,N,Percent,N,Percent
182 x × y,4,66.7%,2,33.3%,6,100.0%
186 ,,,one unity,three lots,two duality,zero none,
187 x,1.00,Count,1,0,0,1,2
188 ,2.00,Count,0,0,1,0,1
189 ,3.00,Count,0,1,0,0,1
190 Total,,Count,1,1,1,1,4
194 AT_SETUP([CROSSTABS crash])
195 AT_DATA([crosstabs.sps],
216 CROSSTABS TABLES y by z.
218 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
219 [Table: Reading 1 record from INLINE.
220 Variable,Record,Columns,Format
239 ,Valid,,Missing,,Total,
240 ,N,Percent,N,Percent,N,Percent
241 y × z,9,100.0%,0,.0%,9,100.0%
252 # Bug #26739, which caused CROSSTABS to crash or to fail to output
253 # chi-square results.
254 AT_SETUP([CROSSTABS chi-square crash])
255 AT_DATA([crosstabs.sps],
256 [[DATA LIST LIST /x * y *.
268 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
269 [[Table: Reading free-form data from INLINE.
276 ,Valid,,Missing,,Total,
277 ,N,Percent,N,Percent,N,Percent
278 x × y,4,100.0%,0,.0%,4,100.0%
288 Table: Chi-Square Tests
289 ,Value,df,Asymptotic Sig. (2-tailed)
290 Pearson Chi-Square,2.00,2,.368
291 Likelihood Ratio,2.77,2,.250
292 Linear-by-Linear Association,.27,1,.602
298 AT_SETUP([CROSSTABS crash with SPLIT FILE])
299 AT_DATA([crosstabs.sps],
300 [data list notable / v0 to v2 1-6 (A)
314 SPLIT FILE SEPARATE BY v0.
318 /FORMAT=AVALUE TABLES
320 /CELLS=COUNT ROW COLUMN TOTAL.
323 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
324 AT_CHECK([cat pspp.csv], [0], [dnl
331 ,Valid,,Missing,,Total,
332 ,N,Percent,N,Percent,N,Percent
333 v1 × v2,6,100.0%,0,.0%,6,100.0%
339 ,,Row %,75.0%,25.0%,100.0%
340 ,,Column %,75.0%,50.0%,66.7%
341 ,,Total %,50.0%,16.7%,66.7%
343 ,,Row %,50.0%,50.0%,100.0%
344 ,,Column %,25.0%,50.0%,33.3%
345 ,,Total %,16.7%,16.7%,33.3%
347 ,,Row %,66.7%,33.3%,100.0%
348 ,,Column %,100.0%,100.0%,100.0%
349 ,,Total %,66.7%,33.3%,100.0%
351 Table: Chi-Square Tests
352 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
353 Pearson Chi-Square,.38,1,.540,,
354 Likelihood Ratio,.37,1,.545,,
355 Fisher's Exact Test,,,,1.000,.600
356 Continuity Correction,.00,1,1.000,,
357 N of Valid Cases,6,,,,
365 ,Valid,,Missing,,Total,
366 ,N,Percent,N,Percent,N,Percent
367 v1 × v2,4,100.0%,0,.0%,4,100.0%
373 ,,Row %,.0%,100.0%,100.0%
374 ,,Column %,.0%,33.3%,25.0%
375 ,,Total %,.0%,25.0%,25.0%
377 ,,Row %,33.3%,66.7%,100.0%
378 ,,Column %,100.0%,66.7%,75.0%
379 ,,Total %,25.0%,50.0%,75.0%
381 ,,Row %,25.0%,75.0%,100.0%
382 ,,Column %,100.0%,100.0%,100.0%
383 ,,Total %,25.0%,75.0%,100.0%
385 Table: Chi-Square Tests
386 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
387 Pearson Chi-Square,.44,1,.505,,
388 Likelihood Ratio,.68,1,.410,,
389 Fisher's Exact Test,,,,1.000,.750
390 Continuity Correction,.00,1,1.000,,
391 N of Valid Cases,4,,,,
396 AT_SETUP([3-way CROSSTABS])
397 AT_DATA([crosstabs.sps],
418 CROSSTABS TABLES x BY y BY z/STATISTICS=ALL.
420 AT_CHECK([pspp -o - -O format=csv -o pspp.csv -o pspp.txt crosstabs.sps], [0],
421 [Table: Reading 1 record from INLINE.
422 Variable,Record,Columns,Format
441 ,Valid,,Missing,,Total,
442 ,N,Percent,N,Percent,N,Percent
443 x × y × z,9,100.0%,0,.0%,9,100.0%
460 Table: Chi-Square Tests
461 ,,,Value,df,Asymptotic Sig. (2-tailed)
462 z,1,Pearson Chi-Square,5.00,4,.287
463 ,,Likelihood Ratio,5.00,4,.287
464 ,,Linear-by-Linear Association,.01,1,.938
465 ,,N of Valid Cases,5,,
466 ,2,Pearson Chi-Square,4.00,3,.261
467 ,,Likelihood Ratio,4.50,3,.212
468 ,,Linear-by-Linear Association,1.58,1,.209
469 ,,N of Valid Cases,4,,
471 Table: Symmetric Measures
472 ,,,,Value,Asymp. Std. Error,Approx. T
473 z,1,Nominal by Nominal,Phi,1.00,,
475 ,,,Contingency Coefficient,.71,,
476 ,,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00
477 ,,,Kendall's tau-c,.00,.32,.00
479 ,,,Spearman Correlation,.00,.22,.00
480 ,,Interval by Interval,Pearson's R,.04,.22,.07
481 ,,N of Valid Cases,,5,,
482 ,2,Nominal by Nominal,Phi,1.00,,
484 ,,,Contingency Coefficient,.71,,
485 ,,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73
486 ,,,Kendall's tau-c,-.75,.43,-1.73
487 ,,,Gamma,-1.00,.00,-1.73
488 ,,,Spearman Correlation,-.77,.17,-1.73
489 ,,Interval by Interval,Pearson's R,-.73,.18,-1.49
490 ,,N of Valid Cases,,4,,
492 Table: Directional Measures
493 ,,,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
494 z,1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
495 ,,,,x Dependent,.25,.22,1.12,.264
496 ,,,,y Dependent,1.00,.00,1.12,.264
497 ,,,Goodman and Kruskal tau,x Dependent,.25,,,
498 ,,,,y Dependent,1.00,,,
499 ,,,Uncertainty Coefficient,Symmetric,.47,.18,,
500 ,,,,x Dependent,.31,.15,2.02,
501 ,,,,y Dependent,1.00,.00,2.02,
502 ,,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
503 ,,,,x Dependent,.00,.50,.00,1.000
504 ,,,,y Dependent,.00,.20,.00,1.000
505 ,,Nominal by Interval,Eta,x Dependent,.04,,,
506 ,,,,y Dependent,1.00,,,
507 ,2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
508 ,,,,x Dependent,.33,.27,1.15,.248
509 ,,,,y Dependent,1.00,.00,1.15,.248
510 ,,,Goodman and Kruskal tau,x Dependent,.33,,,
511 ,,,,y Dependent,1.00,,,
512 ,,,Uncertainty Coefficient,Symmetric,.58,.17,,
513 ,,,,x Dependent,.41,.17,2.36,
514 ,,,,y Dependent,1.00,.00,2.36,
515 ,,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
516 ,,,,x Dependent,-1.00,.00,-1.73,.083
517 ,,,,y Dependent,-.50,.29,-1.73,.083
518 ,,Nominal by Interval,Eta,x Dependent,.73,,,
519 ,,,,y Dependent,1.00,,,
523 AT_SETUP([CROSSTABS rounding weights with COUNT])
524 AT_DATA([crosstabs.sps],
525 [[DATA LIST NOTABLE LIST /x y w.
536 * These should have the same effect (no rounding).
537 CROSSTABS /TABLES x BY y.
538 CROSSTABS /TABLES x BY y /COUNT ASIS.
540 * Round input weights.
541 CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
542 CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
544 * Round cell weights.
545 CROSSTABS /TABLES x BY y /COUNT.
546 CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
549 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
550 AT_CHECK([cat pspp.csv], [0],
553 ,Valid,,Missing,,Total,
554 ,N,Percent,N,Percent,N,Percent
555 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
560 x,1.00,Count,2.80,3.20,6.00
561 ,2.00,Count,1.00,2.00,3.00
562 Total,,Count,3.80,5.20,9.00
566 ,Valid,,Missing,,Total,
567 ,N,Percent,N,Percent,N,Percent
568 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
573 x,1.00,Count,2.80,3.20,6.00
574 ,2.00,Count,1.00,2.00,3.00
575 Total,,Count,3.80,5.20,9.00
579 ,Valid,,Missing,,Total,
580 ,N,Percent,N,Percent,N,Percent
581 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
586 x,1.00,Count,2.00,4.00,6.00
587 ,2.00,Count,1.00,2.00,3.00
588 Total,,Count,3.00,6.00,9.00
592 ,Valid,,Missing,,Total,
593 ,N,Percent,N,Percent,N,Percent
594 x × y,7.00,100.0%,.00,.0%,7.00,100.0%
599 x,1.00,Count,2.00,2.00,4.00
600 ,2.00,Count,1.00,2.00,3.00
601 Total,,Count,3.00,4.00,7.00
605 ,Valid,,Missing,,Total,
606 ,N,Percent,N,Percent,N,Percent
607 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
612 x,1.00,Count,3.00,3.00,6.00
613 ,2.00,Count,1.00,2.00,3.00
614 Total,,Count,4.00,5.00,9.00
618 ,Valid,,Missing,,Total,
619 ,N,Percent,N,Percent,N,Percent
620 x × y,8.00,100.0%,.00,.0%,8.00,100.0%
625 x,1.00,Count,2.00,3.00,5.00
626 ,2.00,Count,1.00,2.00,3.00
627 Total,,Count,3.00,5.00,8.00
631 AT_SETUP([CROSSTABS descending sort order])
632 AT_DATA([crosstabs-descending.sps],
633 [[DATA LIST NOTABLE LIST /x * y *.
648 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs-descending.sps])
649 AT_CHECK([cat pspp.csv], [0],
652 ,Valid,,Missing,,Total,
653 ,N,Percent,N,Percent,N,Percent
654 x × y,6,100.0%,0,.0%,6,100.0%
667 AT_SETUP([CROSSTABS crash when all cases missing])
668 AT_DATA([crosstabs.sps], [dnl
669 DATA LIST LIST NOTABLE /X1 X2.
674 MISSING VALUES x2 (1).
676 CROSSTABS /TABLES= X1 by X2.
678 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
681 ,Valid,,Missing,,Total,
682 ,N,Percent,N,Percent,N,Percent
683 X1 × X2,0,.0%,1,100.0%,1,100.0%
685 "crosstabs.sps:8.20-8.27: warning: CROSSTABS: Crosstabulation X1 × X2 contained no non-missing cases.
686 8 | CROSSTABS /TABLES= X1 by X2.
693 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
694 AT_SETUP([CROSSTABS Fisher Exact Test])
696 AT_DATA([fisher-exact.sps], [dnl
700 DATA LIST notable LIST /schtyp (F9.2) female (F9.2) ses (F9.2) .
904 VARIABLE LABEL schtyp 'type of school'.
905 ADD VALUE LABELS female 0 male 1 female.
906 ADD VALUE LABELS ses 1 low 2 middle 3 high.
907 ADD VALUE LABELS schtyp 1 public 2 private.
909 crosstabs /tables = schtyp by female /statistic = chisq.
910 crosstabs /tables = female by ses /statistic = chisq.
913 AT_CHECK([pspp -o pspp.csv -o pspp.txt fisher-exact.sps])
914 AT_CHECK([cat pspp.csv], [0], [Table: Summary
916 ,Valid,,Missing,,Total,
917 ,N,Percent,N,Percent,N,Percent
918 type of school × female,200,100.0%,0,.0%,200,100.0%
920 Table: type of school × female
923 type of school,public,Count,77,91,168
924 ,private,Count,14,18,32
925 Total,,Count,91,109,200
927 Table: Chi-Square Tests
928 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
929 Pearson Chi-Square,.047,1,.828,,
930 Likelihood Ratio,.047,1,.828,,
931 Fisher's Exact Test,,,,.849,.492
932 Continuity Correction,.001,1,.981,,
933 Linear-by-Linear Association,.047,1,.829,,
934 N of Valid Cases,200,,,,
938 ,Valid,,Missing,,Total,
939 ,N,Percent,N,Percent,N,Percent
940 female × ses,200,100.0%,0,.0%,200,100.0%
945 female,male,Count,15,47,29,91
946 ,female,Count,32,48,29,109
947 Total,,Count,47,95,58,200
949 Table: Chi-Square Tests
950 ,Value,df,Asymptotic Sig. (2-tailed)
951 Pearson Chi-Square,4.577,2,.101
952 Likelihood Ratio,4.679,2,.096
953 Linear-by-Linear Association,3.110,1,.078
954 N of Valid Cases,200,,
959 AT_SETUP([CROSSTABS Pearson's R - 1])
960 AT_DATA([pearson.sps], [dnl
963 * From http://www.statisticslectures.com/topics/pearsonr/.
972 CROSSTABS x BY y/STATISTICS=CORR.
974 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson.sps])
975 AT_CHECK([cat pspp.csv], [0], [dnl
978 ,Valid,,Missing,,Total,
979 ,N,Percent,N,Percent,N,Percent
980 x × y,5,100.0%,0,.0%,5,100.0%
984 ,,,4.000,6.000,10.000,12.000,13.000,
985 x,1.000,Count,1,0,0,0,0,1
986 ,3.000,Count,0,1,0,0,0,1
987 ,5.000,Count,0,0,1,1,0,2
988 ,6.000,Count,0,0,0,0,1,1
989 Total,,Count,1,1,1,1,1,5
991 Table: Symmetric Measures
992 ,,Value,Asymp. Std. Error,Approx. T
993 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550
994 Interval by Interval,Pearson's R,.968,.017,6.708
995 N of Valid Cases,,5,,
999 AT_SETUP([CROSSTABS Pearson's R - 2])
1000 AT_DATA([pearson2.sps], [dnl
1003 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
1017 CROSSTABS x BY y/STATISTICS=CORR.
1019 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson2.sps])
1020 AT_CHECK([cat pspp.csv], [0], [dnl
1023 ,Valid,,Missing,,Total,
1024 ,N,Percent,N,Percent,N,Percent
1025 x × y,10,100.0%,0,.0%,10,100.0%
1028 ,,,y,,,,,,,,,Total
1029 ,,,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,
1030 x,1.000,Count,1,0,0,0,0,0,0,0,0,1
1031 ,2.000,Count,1,0,0,0,0,0,0,0,0,1
1032 ,3.000,Count,0,1,0,0,0,0,0,0,0,1
1033 ,4.000,Count,0,0,0,1,0,0,0,0,0,1
1034 ,5.000,Count,0,0,1,0,0,0,0,0,0,1
1035 ,6.000,Count,0,0,0,0,0,1,0,0,0,1
1036 ,7.000,Count,0,0,0,0,1,0,0,0,0,1
1037 ,8.000,Count,0,0,0,0,0,0,1,0,0,1
1038 ,9.000,Count,0,0,0,0,0,0,0,1,0,1
1039 ,10.000,Count,0,0,0,0,0,0,0,0,1,1
1040 Total,,Count,2,1,1,1,1,1,1,1,1,10
1042 Table: Symmetric Measures
1043 ,,Value,Asymp. Std. Error,Approx. T
1044 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844
1045 Interval by Interval,Pearson's R,.971,.017,11.580
1046 N of Valid Cases,,10,,
1050 AT_SETUP([CROSSTABS Pearson's R - 3])
1051 AT_DATA([pearson3.sps], [dnl
1054 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
1067 CROSSTABS x BY y/STATISTICS=CORR.
1069 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson3.sps])
1070 AT_CHECK([cat pspp.csv], [0], [dnl
1073 ,Valid,,Missing,,Total,
1074 ,N,Percent,N,Percent,N,Percent
1075 x × y,9,100.0%,0,.0%,9,100.0%
1078 ,,,y,,,,,,,,Total
1079 ,,,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,
1080 x,25.000,Count,1,0,0,0,0,0,0,0,1
1081 ,35.000,Count,0,1,0,0,0,0,0,0,1
1082 ,44.000,Count,0,0,1,0,0,0,0,0,1
1083 ,50.000,Count,0,0,0,1,0,0,0,0,1
1084 ,56.000,Count,0,0,0,0,0,1,1,0,2
1085 ,65.000,Count,0,0,0,0,1,0,1,0,2
1086 ,87.000,Count,0,0,0,0,0,0,0,1,1
1087 Total,,Count,1,1,1,1,1,1,2,1,9
1089 Table: Symmetric Measures
1090 ,,Value,Asymp. Std. Error,Approx. T
1091 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860
1092 Interval by Interval,Pearson's R,.966,.017,9.915
1093 N of Valid Cases,,9,,
1097 AT_SETUP([CROSSTABS Pearson's R - 4])
1098 AT_DATA([pearson4.sps], [dnl
1101 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
1117 CROSSTABS x BY y/STATISTICS=CORR.
1119 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson4.sps])
1120 AT_CHECK([cat pspp.csv], [0], [dnl
1123 ,Valid,,Missing,,Total,
1124 ,N,Percent,N,Percent,N,Percent
1125 x × y,12,100.0%,0,.0%,12,100.0%
1128 ,,,y,,,,,,,,,,,,Total
1129 ,,,2.000,4.000,5.000,7.000,9.000,11.000,12.000,14.000,15.000,17.000,18.000,20.000,
1130 x,2.000,Count,0,0,0,1,0,0,0,0,0,0,0,0,1
1131 ,3.000,Count,0,0,0,0,0,0,1,0,0,0,0,0,1
1132 ,4.000,Count,0,0,0,0,1,1,0,0,0,0,0,0,2
1133 ,5.000,Count,0,0,1,0,0,0,0,0,0,0,0,0,1
1134 ,6.000,Count,1,1,0,0,0,0,0,0,0,0,0,0,2
1135 ,7.000,Count,0,0,0,0,0,0,0,1,0,0,0,0,1
1136 ,8.000,Count,0,0,0,0,0,0,0,0,1,0,0,0,1
1137 ,9.000,Count,0,0,0,0,0,0,0,0,0,1,0,0,1
1138 ,10.000,Count,0,0,0,0,0,0,0,0,0,0,1,1,2
1139 Total,,Count,1,1,1,1,1,1,1,1,1,1,1,1,12
1141 Table: Symmetric Measures
1142 ,,Value,Asymp. Std. Error,Approx. T
1143 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758
1144 Interval by Interval,Pearson's R,.667,.132,2.830
1145 N of Valid Cases,,12,,
1149 AT_SETUP([CROSSTABS Pearson's R - 5])
1150 AT_DATA([pearson5.sps], [dnl
1153 * From http://www.statisticslectures.com/topics/pearsonr/.
1167 CROSSTABS x BY y/STATISTICS=CORR.
1169 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson5.sps])
1170 AT_CHECK([cat pspp.csv], [0], [dnl
1173 ,Valid,,Missing,,Total,
1174 ,N,Percent,N,Percent,N,Percent
1175 x × y,10,100.0%,0,.0%,10,100.0%
1178 ,,,y,,,,,,,,,,Total
1179 ,,,15000.00,26000.00,29000.00,32000.00,33000.00,41000.00,45000.00,52000.00,68000.00,80000.00,
1180 x,18.000,Count,1,0,0,0,0,0,0,0,0,0,1
1181 ,24.000,Count,0,1,0,0,0,0,0,0,0,0,1
1182 ,25.000,Count,0,0,1,0,0,0,0,0,0,0,1
1183 ,26.000,Count,0,0,0,1,0,0,0,0,0,0,1
1184 ,33.000,Count,0,0,0,0,1,0,0,0,0,0,1
1185 ,37.000,Count,0,0,0,0,0,1,0,0,0,0,1
1186 ,40.000,Count,0,0,0,0,0,0,1,0,0,0,1
1187 ,45.000,Count,0,0,0,0,0,0,0,1,0,0,1
1188 ,57.000,Count,0,0,0,0,0,0,0,0,1,0,1
1189 ,64.000,Count,0,0,0,0,0,0,0,0,0,1,1
1190 Total,,Count,1,1,1,1,1,1,1,1,1,1,10
1192 Table: Symmetric Measures
1193 ,,Value,Asymp. Std. Error,Approx. T
1194 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinit
1195 Interval by Interval,Pearson's R,.992,.004,22.638
1196 N of Valid Cases,,10,,
1200 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 1])
1201 AT_DATA([lambda.sps], [dnl
1204 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
1205 DATA LIST LIST NOTABLE/x y w.
1216 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1218 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1219 AT_CHECK([cat pspp.csv], [0], [dnl
1222 ,Valid,,Missing,,Total,
1223 ,N,Percent,N,Percent,N,Percent
1224 x × y,1296.000,100.0%,.000,.0%,1296.000,100.0%
1226 Table: Directional Measures
1227 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1228 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1229 ,,x Dependent,.497,.024,15.986,.000
1230 ,,y Dependent,.370,.020,16.339,.000
1231 ,Goodman and Kruskal tau,x Dependent,.382,,,
1232 ,,y Dependent,.198,,,
1236 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 2])
1237 AT_DATA([lambda.sps], [dnl
1240 * From http://vassarstats.net.
1241 DATA LIST LIST NOTABLE/x y w.
1255 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1257 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1258 AT_CHECK([cat pspp.csv], [0], [dnl
1261 ,Valid,,Missing,,Total,
1262 ,N,Percent,N,Percent,N,Percent
1263 x × y,137.000,100.0%,.000,.0%,137.000,100.0%
1265 Table: Directional Measures
1266 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1267 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1268 ,,x Dependent,.250,.089,2.479,.013
1269 ,,y Dependent,.267,.085,2.766,.006
1270 ,Goodman and Kruskal tau,x Dependent,.129,,,
1271 ,,y Dependent,.123,,,
1275 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 3])
1276 AT_DATA([lambda.sps], [dnl
1279 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1280 cross classifications". Part I. Journal of the American Statistical
1281 Association, 49, 732-764.
1282 DATA LIST LIST NOTABLE/x y w.
1298 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1300 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1301 AT_CHECK([cat pspp.csv], [0], [dnl
1304 ,Valid,,Missing,,Total,
1305 ,N,Percent,N,Percent,N,Percent
1306 x × y,6800.000,100.0%,.000,.0%,6800.000,100.0%
1308 Table: Directional Measures
1309 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1310 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1311 ,,x Dependent,.224,.013,16.076,.000
1312 ,,y Dependent,.192,.012,14.438,.000
1313 ,Goodman and Kruskal tau,x Dependent,.089,,,
1314 ,,y Dependent,.081,,,
1318 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1319 AT_DATA([lambda.sps], [dnl
1322 * From Douglas Bonett.
1323 DATA LIST LIST NOTABLE/x y w.
1334 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1336 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1337 AT_CHECK([cat pspp.csv], [0], [dnl
1340 ,Valid,,Missing,,Total,
1341 ,N,Percent,N,Percent,N,Percent
1342 x × y,500.000,100.0%,.000,.0%,500.000,100.0%
1344 Table: Directional Measures
1345 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1346 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1347 ,,x Dependent,.000,.000,NaN,NaN
1348 ,,y Dependent,.033,.014,2.336,.019
1349 ,Goodman and Kruskal tau,x Dependent,.012,,,
1350 ,,y Dependent,.009,,,
1354 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 1])
1355 AT_DATA([somersd.sps], [dnl
1358 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1359 DATA LIST LIST NOTABLE/x y * w (F10.6).
1377 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1379 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1380 AT_CHECK([cat pspp.csv], [0], [dnl
1383 ,Valid,,Missing,,Total,
1384 ,N,Percent,N,Percent,N,Percent
1385 x × y,1.000000,100.0%,.000000,.0%,1.000000,100.0%
1387 Table: Directional Measures
1388 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1389 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1390 ,,x Dependent,-.045,.300,-.149,.882
1391 ,,y Dependent,-.684,2.378,-.149,.882
1395 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 2])
1396 AT_DATA([somersd.sps], [dnl
1399 * From http://uregina.ca/~gingrich/gamma.pdf.
1400 DATA LIST LIST NOTABLE/x y w.
1413 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1415 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1416 AT_CHECK([cat pspp.csv], [0], [dnl
1419 ,Valid,,Missing,,Total,
1420 ,N,Percent,N,Percent,N,Percent
1421 x × y,687.000,100.0%,.000,.0%,687.000,100.0%
1423 Table: Symmetric Measures
1424 ,,Value,Asymp. Std. Error,Approx. T
1425 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669
1426 ,Kendall's tau-c,.310,.029,10.669
1427 ,Gamma,.591,.043,10.669
1428 N of Valid Cases,,687.000,,
1430 Table: Directional Measures
1431 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1432 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1433 ,,x Dependent,.351,.032,10.669,.000
1434 ,,y Dependent,.394,.035,10.669,.000
1438 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 3])
1439 AT_DATA([ordinal.sps], [dnl
1442 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1443 DATA LIST LIST NOTABLE /x y w.
1450 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1452 * Same site, case 2.
1453 DATA LIST LIST NOTABLE /x y w.
1460 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1462 * Same site, case 3.
1463 DATA LIST LIST NOTABLE /x y w.
1470 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1472 * Same site, case 4.
1473 DATA LIST LIST NOTABLE /x y w.
1481 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1483 * Same site, case 5.
1484 DATA LIST LIST NOTABLE /x y w.
1492 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1494 * Same site, case 6.
1495 DATA LIST LIST NOTABLE /x y w.
1507 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1509 * Same site, case 7.
1510 DATA LIST LIST NOTABLE /x y w.
1522 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1524 * Same site, case 8.
1525 DATA LIST LIST NOTABLE /x y w.
1545 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1547 AT_CHECK([pspp -o pspp.csv -o pspp.txt ordinal.sps])
1548 AT_CHECK([cat pspp.csv], [0], [dnl
1551 ,Valid,,Missing,,Total,
1552 ,N,Percent,N,Percent,N,Percent
1553 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1555 Table: Symmetric Measures
1556 ,,Value,Asymp. Std. Error,Approx. T
1557 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1558 ,Gamma,1.000,.000,24.841
1559 N of Valid Cases,,150.000,,
1561 Table: Directional Measures
1562 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1563 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1564 ,,x Dependent,1.000,.000,24.841,.000
1565 ,,y Dependent,1.000,.000,24.841,.000
1569 ,Valid,,Missing,,Total,
1570 ,N,Percent,N,Percent,N,Percent
1571 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1573 Table: Symmetric Measures
1574 ,,Value,Asymp. Std. Error,Approx. T
1575 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1576 ,Gamma,1.000,.000,24.841
1577 N of Valid Cases,,150.000,,
1579 Table: Directional Measures
1580 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1581 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1582 ,,x Dependent,1.000,.000,24.841,.000
1583 ,,y Dependent,1.000,.000,24.841,.000
1587 ,Valid,,Missing,,Total,
1588 ,N,Percent,N,Percent,N,Percent
1589 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1591 Table: Symmetric Measures
1592 ,,Value,Asymp. Std. Error,Approx. T
1593 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841
1594 ,Gamma,-1.000,.000,-24.841
1595 N of Valid Cases,,150.000,,
1597 Table: Directional Measures
1598 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1599 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1600 ,,x Dependent,-1.000,.000,-24.841,.000
1601 ,,y Dependent,-1.000,.000,-24.841,.000
1605 ,Valid,,Missing,,Total,
1606 ,N,Percent,N,Percent,N,Percent
1607 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1609 Table: Symmetric Measures
1610 ,,Value,Asymp. Std. Error,Approx. T
1611 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841
1612 ,Gamma,1.000,.000,24.841
1613 N of Valid Cases,,150.000,,
1615 Table: Directional Measures
1616 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1617 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1618 ,,x Dependent,.944,.013,24.841,.000
1619 ,,y Dependent,1.000,.000,24.841,.000
1623 ,Valid,,Missing,,Total,
1624 ,N,Percent,N,Percent,N,Percent
1625 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1627 Table: Symmetric Measures
1628 ,,Value,Asymp. Std. Error,Approx. T
1629 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009
1630 ,Gamma,1.000,.000,1.009
1631 N of Valid Cases,,150.000,,
1633 Table: Directional Measures
1634 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1635 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1636 ,,x Dependent,.805,.032,1.009,.313
1637 ,,y Dependent,.018,.017,1.009,.313
1641 ,Valid,,Missing,,Total,
1642 ,N,Percent,N,Percent,N,Percent
1643 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1645 Table: Symmetric Measures
1646 ,,Value,Asymp. Std. Error,Approx. T
1647 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641
1648 ,Gamma,-.381,.130,-2.641
1649 N of Valid Cases,,148.000,,
1651 Table: Directional Measures
1652 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1653 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1654 ,,x Dependent,-.182,.069,-2.641,.008
1655 ,,y Dependent,-.237,.089,-2.641,.008
1659 ,Valid,,Missing,,Total,
1660 ,N,Percent,N,Percent,N,Percent
1661 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1663 Table: Symmetric Measures
1664 ,,Value,Asymp. Std. Error,Approx. T
1665 Nominal by Nominal,Phi,.731,,
1667 Ordinal by Ordinal,Gamma,-.110,.107,-1.022
1668 N of Valid Cases,,148.000,,
1670 Table: Directional Measures
1671 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1672 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1673 ,,x Dependent,.640,.085,4.875,.000
1674 ,,y Dependent,.174,.050,3.248,.001
1675 ,Goodman and Kruskal tau,x Dependent,.534,,,
1676 ,,y Dependent,.167,,,
1677 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1678 ,,x Dependent,-.060,.059,-1.022,.307
1679 ,,y Dependent,-.096,.094,-1.022,.307
1683 ,Valid,,Missing,,Total,
1684 ,N,Percent,N,Percent,N,Percent
1685 x × y,212.000,100.0%,.000,.0%,212.000,100.0%
1687 Table: Symmetric Measures
1688 ,,Value,Asymp. Std. Error,Approx. T
1689 Nominal by Nominal,Phi,.432,,
1691 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338
1692 N of Valid Cases,,212.000,,
1694 Table: Directional Measures
1695 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1696 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1697 ,,x Dependent,.027,.087,.302,.763
1698 ,,y Dependent,.165,.065,2.349,.019
1699 ,Goodman and Kruskal tau,x Dependent,.051,,,
1700 ,,y Dependent,.068,,,
1701 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1702 ,,x Dependent,.202,.060,3.338,.001
1703 ,,y Dependent,.217,.064,3.338,.001
1707 AT_SETUP([CROSSTABS Cohens Kappa])
1709 dnl Example from Wood J. M.
1710 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1711 dnl WebPsychEmpiricist. Oct 3 2007
1712 AT_DATA([kappa.sps], [dnl
1715 data list notable list /p1 * p2 * w *.
1724 crosstabs /table = p1 by p2
1729 AT_CHECK([pspp -o pspp.csv -o pspp.txt kappa.sps])
1730 AT_CHECK([cat pspp.csv], [0], [dnl
1733 ,Valid,,Missing,,Total,
1734 ,N,Percent,N,Percent,N,Percent
1735 p1 × p2,20.000,100.0%,.000,.0%,20.000,100.0%
1740 p1,.000,Count,18.000,1.000,19.000
1741 ,1.000,Count,1.000,.000,1.000
1742 Total,,Count,19.000,1.000,20.000
1744 Table: Symmetric Measures
1745 ,,Value,Asymp. Std. Error,Approx. T
1746 Measure of Agreement,Kappa,-.053,.037,-.235
1747 N of Valid Cases,,20.000,,
1753 AT_SETUP([CROSSTABS many statistics])
1754 AT_DATA([crosstabs.sps], [dnl
1757 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1758 DATA LIST LIST NOTABLE/x y w.
1767 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1769 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
1770 AT_CHECK([cat pspp.csv], [0], [dnl
1773 ,Valid,,Missing,,Total,
1774 ,N,Percent,N,Percent,N,Percent
1775 x × y,66.0000,100.0%,.0000,.0%,66.0000,100.0%
1777 Table: Chi-Square Tests
1778 ,Value,df,Asymptotic Sig. (2-tailed)
1779 Pearson Chi-Square,6.9562,2.0000,.031
1780 Likelihood Ratio,6.6901,2.0000,.035
1781 Linear-by-Linear Association,5.8450,1.0000,.016
1782 N of Valid Cases,66.0000,,
1784 Table: Symmetric Measures
1785 ,,Value,Asymp. Std. Error,Approx. T
1786 Nominal by Nominal,Phi,.3246,,
1788 ,Contingency Coefficient,.3088,,
1789 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920
1790 ,Kendall's tau-c,.1497,.0751,1.9920
1791 ,Gamma,.8717,.1250,1.9920
1792 ,Spearman Correlation,.2908,.0906,2.4311
1793 Interval by Interval,Pearson's R,.2999,.0973,2.5147
1794 N of Valid Cases,,66.0000,,
1796 Table: Directional Measures
1797 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1798 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1799 ,,x Dependent,.0000,.0000,NaN,NaN
1800 ,,y Dependent,.0500,.1791,.2723,.785
1801 ,Goodman and Kruskal tau,x Dependent,.1054,,,
1802 ,,y Dependent,.0434,,,
1803 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,
1804 ,,x Dependent,.2217,.1062,1.5373,
1805 ,,y Dependent,.0473,.0306,1.5373,
1806 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1807 ,,x Dependent,.1152,.0572,1.9920,.046
1808 ,,y Dependent,.6573,.1417,1.9920,.046
1812 AT_SETUP([CROSSTABS uncertainy coefficient])
1813 AT_DATA([uc.sps], [dnl
1814 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1817 DATA LIST LIST NOTABLE/x y w.
1827 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1829 AT_CHECK([pspp -o pspp.csv -o pspp.txt uc.sps])
1830 AT_CHECK([cat pspp.csv], [0], [dnl
1833 ,Valid,,Missing,,Total,
1834 ,N,Percent,N,Percent,N,Percent
1835 x × y,987.000,100.0%,.000,.0%,987.000,100.0%
1837 Table: Directional Measures
1838 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1839 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1840 ,,x Dependent,.000,.000,NaN,NaN
1841 ,,y Dependent,.000,.000,NaN,NaN
1842 ,Goodman and Kruskal tau,x Dependent,.076,,,
1843 ,,y Dependent,.108,,,
1844 ,Uncertainty Coefficient,Symmetric,.105,.012,,
1845 ,,x Dependent,.073,.009,7.890,
1846 ,,y Dependent,.184,.019,7.890,
1850 AT_SETUP([CROSSTABS estimated risk])
1851 dnl Example data and expected output from
1852 dnl http://www.psychology.nottingham.ac.uk/staff/ddc/c8cxpa/further/Project_resources/SPSSCrosstabW.pdf
1853 AT_DATA([risk.sps], [dnl
1854 DATA LIST LIST /factor disease count (F8.0).
1856 VALUE LABELS /factor 0 'Placebo' 1 'Aspirin'
1857 /disease 1 'No' 0 'Yes'.
1864 CROSSTABS factor BY disease/STATISTICS=RISK CHISQ.
1866 AT_CHECK([pspp -o pspp.csv -o pspp.txt risk.sps])
1867 AT_CHECK([cat pspp.csv], [0], [dnl
1868 Table: Reading free-form data from INLINE.
1876 ,Valid,,Missing,,Total,
1877 ,N,Percent,N,Percent,N,Percent
1878 factor × disease,250,100.0%,0,.0%,250,100.0%
1880 Table: factor × disease
1883 factor,Placebo,Count,20,80,100
1884 ,Aspirin,Count,15,135,150
1885 Total,,Count,35,215,250
1887 Table: Chi-Square Tests
1888 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
1889 Pearson Chi-Square,4.98,1,.026,,
1890 Likelihood Ratio,4.88,1,.027,,
1891 Fisher's Exact Test,,,,.039,.021
1892 Continuity Correction,4.19,1,.041,,
1893 Linear-by-Linear Association,4.96,1,.026,,
1894 N of Valid Cases,250,,,,
1896 Table: Risk Estimate
1897 ,Value,95% Confidence Interval,
1899 Odds Ratio for factor (Placebo / Aspirin),2.25,1.09,4.64
1900 For cohort disease = Yes,2.00,1.08,3.72
1901 For cohort disease = No,.89,.80,.99
1902 N of Valid Cases,250.00,,
1906 AT_SETUP([CROSSTABS barchart])
1907 AT_DATA([bc.sps], [dnl
1910 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1934 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1936 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1937 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1939 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])
1943 AT_SETUP([CROSSTABS syntax errors])
1944 AT_DATA([crosstabs.sps], [dnl
1945 DATA LIST LIST NOTABLE/x y v1 to v100.
1946 CROSSTABS TABLES=x BY y/VARIABLES **.
1947 CROSSTABS VARIABLES=**.
1948 CROSSTABS VARIABLES=x **.
1949 CROSSTABS VARIABLES=x (**).
1950 CROSSTABS VARIABLES=x (1,**).
1951 CROSSTABS VARIABLES=x (1,5**).
1952 CROSSTABS MISSING=**.
1954 CROSSTABS FORMAT=**.
1956 CROSSTABS STATISTICS=**.
1959 v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
1960 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
1961 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
1962 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
1963 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
1964 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100.
1966 CROSSTABS x BY y/MISSING=REPORT.
1968 AT_CHECK([pspp -O format=csv crosstabs.sps], [1], [dnl
1969 "crosstabs.sps:2.25-2.33: error: CROSSTABS: VARIABLES must be specified before TABLES.
1970 2 | CROSSTABS TABLES=x BY y/VARIABLES **.
1973 "crosstabs.sps:3.21-3.22: error: CROSSTABS: Syntax error expecting variable name.
1974 3 | CROSSTABS VARIABLES=**.
1977 "crosstabs.sps:4.23-4.24: error: CROSSTABS: Syntax error expecting `('.
1978 4 | CROSSTABS VARIABLES=x **.
1981 "crosstabs.sps:5.24-5.25: error: CROSSTABS: Syntax error expecting integer.
1982 5 | CROSSTABS VARIABLES=x (**).
1985 "crosstabs.sps:6.26-6.27: error: CROSSTABS: Syntax error expecting positive integer.
1986 6 | CROSSTABS VARIABLES=x (1,**).
1989 "crosstabs.sps:7.27-7.28: error: CROSSTABS: Syntax error expecting `)'.
1990 7 | CROSSTABS VARIABLES=x (1,5**).
1993 "crosstabs.sps:8.19-8.20: error: CROSSTABS: Syntax error expecting TABLE, INCLUDE, or REPORT.
1994 8 | CROSSTABS MISSING=**.
1997 "crosstabs.sps:9.17-9.18: error: CROSSTABS: Syntax error expecting ASIS, CASE, CELL, ROUND, or TRUNCATE.
1998 9 | CROSSTABS COUNT=**.
2001 "crosstabs.sps:10.18-10.19: error: CROSSTABS: Syntax error expecting AVALUE, DVALUE, TABLES, or NOTABLES.
2002 10 | CROSSTABS FORMAT=**.
2005 "crosstabs.sps:11.17-11.18: error: CROSSTABS: Syntax error expecting COUNT, EXPECTED, ROW, COLUMN, TOTAL, RESIDUAL, SRESIDUAL, or ASRESIDUAL.
2006 11 | CROSSTABS CELLS=**.
2009 "crosstabs.sps:12.22-12.23: error: CROSSTABS: Syntax error expecting one of the following: CHISQ, PHI, CC, LAMBDA, UC, BTAU, CTAU, RISK, GAMMA, D, KAPPA, ETA, CORR.
2010 12 | CROSSTABS STATISTICS=**.
2013 "crosstabs.sps:13.11-13.12: error: CROSSTABS: Syntax error expecting subcommand name or variable name.
2017 "crosstabs.sps:15.8-20.87: error: CROSSTABS: Too many cross-tabulation variables or dimensions.
2018 15 | v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
2019 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020 16 | BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
2021 | ---------------------------------------------------------------------------------------
2023 20 | BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100.
2024 | ---------------------------------------------------------------------------------------"
2026 crosstabs.sps:21: error: CROSSTABS: At least one crosstabulation must be requested (using the TABLES subcommand).
2028 "crosstabs.sps:22.26-22.31: warning: CROSSTABS: Missing mode REPORT not allowed in general mode. Assuming MISSING=TABLE.
2029 22 | CROSSTABS x BY y/MISSING=REPORT.
2032 error: CROSSTABS: At end of input: Syntax error expecting `BEGIN DATA'.