1 AT_BANNER([CROSSTABS procedure])
3 AT_SETUP([CROSSTABS integer mode crash])
4 AT_DATA([crosstabs.sps],
5 [DATA LIST LIST /A * B * X * Y * .
10 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
12 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
13 [[Table: Reading free-form data from INLINE.
22 ,Valid,,Missing,,Total,
23 ,N,Percent,N,Percent,N,Percent
24 X * Y,1,100.0%,0,0.0%,1,100.0%
28 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
29 1.00,.00,.00,.00,.00,.00,.00,.00,.00
30 2.00,.00,.00,.00,.00,.00,.00,.00,.00
31 3.00,.00,.00,.00,.00,.00,.00,.00,.00
32 4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
33 5.00,.00,.00,.00,.00,.00,.00,.00,.00
34 6.00,.00,.00,.00,.00,.00,.00,.00,.00
35 7.00,.00,.00,.00,.00,.00,.00,.00,.00
36 Total,.00,.00,.00,.00,1.00,.00,.00,1.00
41 AT_SETUP([CROSSTABS long string crash])
42 AT_DATA([crosstabs.sps],
43 [data list list /x * y (a18).
54 CROSSTABS /TABLES = x BY y.
56 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
57 [[Table: Reading free-form data from INLINE.
62 "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."
64 "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."
68 ,Valid,,Missing,,Total,
69 ,N,Percent,N,Percent,N,Percent
70 x * y,4,66.7%,2,33.3%,6,100.0%
74 x,one unity ,three lots ,two duality ,zero none ,Total
75 1.00,1.00,.00,.00,1.00,2.00
76 2.00,.00,.00,1.00,.00,1.00
77 3.00,.00,1.00,.00,.00,1.00
78 Total,1.00,1.00,1.00,1.00,4.00
82 AT_SETUP([CROSSTABS crash])
83 AT_DATA([crosstabs.sps],
104 CROSSTABS TABLES y by z.
106 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
107 [[Table: Reading 1 record from INLINE.
108 Variable,Record,Columns,Format
127 ,Valid,,Missing,,Total,
128 ,N,Percent,N,Percent,N,Percent
129 y * z,9,100.0%,0,0.0%,9,100.0%
131 Table: y * z [count].
140 # Bug #26739, which caused CROSSTABS to crash or to fail to output
141 # chi-square results.
142 AT_SETUP([CROSSTABS chi-square crash])
143 AT_DATA([crosstabs.sps],
144 [[DATA LIST LIST /x * y *.
156 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
157 [[Table: Reading free-form data from INLINE.
164 ,Valid,,Missing,,Total,
165 ,N,Percent,N,Percent,N,Percent
166 x * y,4,100.0%,0,0.0%,4,100.0%
168 Table: x * y [count].
176 Table: Chi-square tests.
177 Statistic,Value,df,Asymp. Sig. (2-tailed)
178 Pearson Chi-Square,2.00,2,.368
179 Likelihood Ratio,2.77,2,.250
180 Linear-by-Linear Association,.27,1,.602
186 AT_SETUP([CROSSTABS crash with SPLIT FILE])
187 AT_DATA([crosstabs.sps],
188 [data list notable / v0 to v2 1-6 (A)
202 SPLIT FILE SEPARATE BY v0.
206 /FORMAT=AVALUE TABLES PIVOT
208 /CELLS=COUNT ROW COLUMN TOTAL.
211 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
212 [[Variable,Value,Label
217 ,Valid,,Missing,,Total,
218 ,N,Percent,N,Percent,N,Percent
219 v1 * v2,6,100.0%,0,0.0%,6,100.0%
221 "Table: v1 * v2 [count, row %, column %, total %]."
225 ,75.00%,25.00%,100.00%
226 ,75.00%,50.00%,66.67%
227 ,50.00%,16.67%,66.67%
229 ,50.00%,50.00%,100.00%
230 ,25.00%,50.00%,33.33%
231 ,16.67%,16.67%,33.33%
233 ,66.67%,33.33%,100.00%
234 ,100.00%,100.00%,100.00%
235 ,66.67%,33.33%,100.00%
237 Table: Chi-square tests.
238 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
239 Pearson Chi-Square,.38,1,.540,,
240 Likelihood Ratio,.37,1,.545,,
241 Fisher's Exact Test,,,,1.000,.600
242 Continuity Correction,.00,1,1.000,,
243 N of Valid Cases,6,,,,
250 ,Valid,,Missing,,Total,
251 ,N,Percent,N,Percent,N,Percent
252 v1 * v2,4,100.0%,0,0.0%,4,100.0%
254 "Table: v1 * v2 [count, row %, column %, total %]."
258 ,.00%,100.00%,100.00%
262 ,33.33%,66.67%,100.00%
263 ,100.00%,66.67%,75.00%
264 ,25.00%,50.00%,75.00%
266 ,25.00%,75.00%,100.00%
267 ,100.00%,100.00%,100.00%
268 ,25.00%,75.00%,100.00%
270 Table: Chi-square tests.
271 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
272 Pearson Chi-Square,.44,1,.505,,
273 Likelihood Ratio,.68,1,.410,,
274 Fisher's Exact Test,,,,1.000,.750
275 Continuity Correction,.00,1,1.000,,
276 N of Valid Cases,4,,,,
281 AT_SETUP([3-way CROSSTABS])
282 AT_DATA([crosstabs.sps],
303 CROSSTABS TABLES x BY y BY z/STATISTICS=ALL.
305 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
306 [[Table: Reading 1 record from INLINE.
307 Variable,Record,Columns,Format
326 ,Valid,,Missing,,Total,
327 ,N,Percent,N,Percent,N,Percent
328 x * y * z,9,100.0%,0,0.0%,9,100.0%
330 Table: x * y * z [count].
338 Total,,4.00,1.00,5.00
343 Total,,3.00,1.00,4.00
345 Table: Chi-square tests.
346 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
347 1,Pearson Chi-Square,5.00,4,.287
348 ,Likelihood Ratio,5.00,4,.287
349 ,Linear-by-Linear Association,.01,1,.938
350 ,N of Valid Cases,5,,
351 2,Pearson Chi-Square,4.00,3,.261
352 ,Likelihood Ratio,4.50,3,.212
353 ,Linear-by-Linear Association,1.58,1,.209
354 ,N of Valid Cases,4,,
356 Table: Symmetric measures.
357 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
358 1,Nominal by Nominal,Phi,1.00,,,
360 ,,Contingency Coefficient,.71,,,
361 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
362 ,,Kendall's tau-c,.00,.32,.00,
364 ,,Spearman Correlation,.00,.22,.00,
365 ,Interval by Interval,Pearson's R,.04,.22,.18,
366 ,N of Valid Cases,,5,,,
367 2,Nominal by Nominal,Phi,1.00,,,
369 ,,Contingency Coefficient,.71,,,
370 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
371 ,,Kendall's tau-c,-.75,.43,-1.73,
372 ,,Gamma,-1.00,.00,-1.73,
373 ,,Spearman Correlation,-.77,.17,-6.77,
374 ,Interval by Interval,Pearson's R,-.73,.18,-5.49,
375 ,N of Valid Cases,,4,,,
377 Table: Directional measures.
378 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
379 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.02,
380 ,,,x Dependent,.25,NaN,1.12,
381 ,,,y Dependent,1.00,NaN,1.12,
382 ,,Goodman and Kruskal tau,x Dependent,.25,,,
383 ,,,y Dependent,1.00,,,
384 ,,Uncertainty Coefficient,Symmetric,.47,.18,1.51,
385 ,,,x Dependent,.31,.15,2.02,
386 ,,,y Dependent,1.00,.00,2.02,
387 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,.09,.00,
388 ,,,x Dependent,.00,.50,.00,
389 ,,,y Dependent,.00,.20,.00,
390 ,Nominal by Interval,Eta,x Dependent,.04,,,
391 ,,,y Dependent,1.00,,,
392 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,1.51,
393 ,,,x Dependent,.33,NaN,1.15,
394 ,,,y Dependent,1.00,NaN,1.15,
395 ,,Goodman and Kruskal tau,x Dependent,.33,,,
396 ,,,y Dependent,1.00,,,
397 ,,Uncertainty Coefficient,Symmetric,.58,.17,1.56,
398 ,,,x Dependent,.41,.17,2.36,
399 ,,,y Dependent,1.00,.00,2.36,
400 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,.04,-1.73,
401 ,,,x Dependent,-1.00,.00,-1.73,
402 ,,,y Dependent,-.50,.29,-1.73,
403 ,Nominal by Interval,Eta,x Dependent,.73,,,
404 ,,,y Dependent,1.00,,,
410 AT_SETUP([CROSSTABS descending sort order])
411 AT_DATA([crosstabs-descending.sps],
412 [[DATA LIST NOTABLE LIST /x * y *.
427 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
430 ,Valid,,Missing,,Total,
431 ,N,Percent,N,Percent,N,Percent
432 x * y,6,100.0%,0,0.0%,6,100.0%
434 Table: x * y [count].
445 AT_SETUP([CROSSTABS crash when all cases missing])
446 AT_DATA([crosstabs.sps], [dnl
447 DATA LIST LIST NOTABLE /X1 X2.
452 MISSING VALUES x2 (1).
454 CROSSTABS /TABLES= X1 by X2.
456 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
459 ,Valid,,Missing,,Total,
460 ,N,Percent,N,Percent,N,Percent
461 X1 * X2,0,0.0%,1,100.0%,1,100.0%
463 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
469 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
470 AT_SETUP([CROSSTABS Fisher Exact Test])
472 AT_DATA([fisher-exact.sps], [dnl
476 DATA LIST notable LIST /schtyp (F9.2) female (F9.2) ses (F9.2) .
680 VARIABLE LABEL schtyp 'type of school'.
681 ADD VALUE LABELS female 0 male 1 female.
682 ADD VALUE LABELS ses 1 low 2 middle 3 high.
683 ADD VALUE LABELS schtyp 1 public 2 private.
685 crosstabs /tables = schtyp by female /statistic = chisq.
686 crosstabs /tables = female by ses /statistic = chisq.
689 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
692 ,Valid,,Missing,,Total,
693 ,N,Percent,N,Percent,N,Percent
694 type of school * female,200,100.0%,0,0.0%,200,100.0%
696 Table: type of school * female [[count]].
698 type of school,male,female,Total
699 public,77.000,91.000,168.000
700 private,14.000,18.000,32.000
701 Total,91.000,109.000,200.000
703 Table: Chi-square tests.
704 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
705 Pearson Chi-Square,.047,1,.828,,
706 Likelihood Ratio,.047,1,.828,,
707 Fisher's Exact Test,,,,.849,.492
708 Continuity Correction,.001,1,.981,,
709 Linear-by-Linear Association,.047,1,.829,,
710 N of Valid Cases,200,,,,
714 ,Valid,,Missing,,Total,
715 ,N,Percent,N,Percent,N,Percent
716 female * ses,200,100.0%,0,0.0%,200,100.0%
718 Table: female * ses [[count]].
720 female,low,middle,high,Total
721 male,15.000,47.000,29.000,91.000
722 female,32.000,48.000,29.000,109.000
723 Total,47.000,95.000,58.000,200.000
725 Table: Chi-square tests.
726 Statistic,Value,df,Asymp. Sig. (2-tailed)
727 Pearson Chi-Square,4.577,2,.101
728 Likelihood Ratio,4.679,2,.096
729 Linear-by-Linear Association,3.110,1,.078
730 N of Valid Cases,200,,
735 AT_SETUP([CROSSTABS Pearson's R])
737 AT_DATA([pearson.sps], [dnl
738 * From http://www.statisticslectures.com/topics/pearsonr/.
747 CROSSTABS x BY y/STATISTICS=CORR.
749 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
752 ,Valid,,Missing,,Total,
753 ,N,Percent,N,Percent,N,Percent
754 x * y,5,100.0%,0,0.0%,5,100.0%
756 Table: x * y [[count]].
758 x,4.00,6.00,10.00,12.00,13.00,Total
759 1.00,1.00,.00,.00,.00,.00,1.00
760 3.00,.00,1.00,.00,.00,.00,1.00
761 5.00,.00,.00,1.00,1.00,.00,2.00
762 6.00,.00,.00,.00,.00,1.00,1.00
763 Total,1.00,1.00,1.00,1.00,1.00,5.00
765 Table: Symmetric measures.
766 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
767 Ordinal by Ordinal,Spearman Correlation,.97,.02,2.84,
768 Interval by Interval,Pearson's R,.97,.02,3.36,
769 N of Valid Cases,,5,,,
773 AT_DATA([pearson2.sps], [dnl
774 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
788 CROSSTABS x BY y/STATISTICS=CORR.
790 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
793 ,Valid,,Missing,,Total,
794 ,N,Percent,N,Percent,N,Percent
795 x * y,10,100.0%,0,0.0%,10,100.0%
797 Table: x * y [[count]].
798 ,y,,,,,,,,,
799 x,1.50,4.00,5.00,6.00,6.50,7.00,9.00,10.50,11.00,Total
800 1.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
801 2.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
802 3.00,.00,1.00,.00,.00,.00,.00,.00,.00,.00,1.00
803 4.00,.00,.00,.00,1.00,.00,.00,.00,.00,.00,1.00
804 5.00,.00,.00,1.00,.00,.00,.00,.00,.00,.00,1.00
805 6.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,1.00
806 7.00,.00,.00,.00,.00,1.00,.00,.00,.00,.00,1.00
807 8.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,1.00
808 9.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,1.00
809 10.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,1.00
810 Total,2.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,10.00
812 Table: Symmetric measures.
813 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
814 Ordinal by Ordinal,Spearman Correlation,.97,.02,3.66,
815 Interval by Interval,Pearson's R,.97,.02,3.69,
816 N of Valid Cases,,10,,,
820 AT_DATA([pearson3.sps], [dnl
821 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
834 CROSSTABS x BY y/STATISTICS=CORR.
836 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
839 ,Valid,,Missing,,Total,
840 ,N,Percent,N,Percent,N,Percent
841 x * y,9,100.0%,0,0.0%,9,100.0%
843 Table: x * y [[count]].
845 x,28.00,58.00,66.00,75.00,85.00,87.00,91.00,122.00,Total
846 25.00,1.00,.00,.00,.00,.00,.00,.00,.00,1.00
847 35.00,.00,1.00,.00,.00,.00,.00,.00,.00,1.00
848 44.00,.00,.00,1.00,.00,.00,.00,.00,.00,1.00
849 50.00,.00,.00,.00,1.00,.00,.00,.00,.00,1.00
850 56.00,.00,.00,.00,.00,.00,1.00,1.00,.00,2.00
851 65.00,.00,.00,.00,.00,1.00,.00,1.00,.00,2.00
852 87.00,.00,.00,.00,.00,.00,.00,.00,1.00,1.00
853 Total,1.00,1.00,1.00,1.00,1.00,1.00,2.00,1.00,9.00
855 Table: Symmetric measures.
856 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
857 Ordinal by Ordinal,Spearman Correlation,.91,.07,3.45,
858 Interval by Interval,Pearson's R,.97,.02,5.00,
859 N of Valid Cases,,9,,,
863 AT_DATA([pearson4.sps], [dnl
864 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
880 CROSSTABS x BY y/STATISTICS=CORR.
882 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
885 ,Valid,,Missing,,Total,
886 ,N,Percent,N,Percent,N,Percent
887 x * y,12,100.0%,0,0.0%,12,100.0%
889 Table: x * y [[count]].
890 ,y,,,,,,,,,,,,
891 x,2.00,4.00,5.00,7.00,9.00,11.00,12.00,14.00,15.00,17.00,18.00,20.00,Total
892 2.00,.00,.00,.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
893 3.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,.00,.00,1.00
894 4.00,.00,.00,.00,.00,1.00,1.00,.00,.00,.00,.00,.00,.00,2.00
895 5.00,.00,.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
896 6.00,1.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,2.00
897 7.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,.00,1.00
898 8.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,1.00
899 9.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,1.00
900 10.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,1.00,2.00
901 Total,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,12.00
903 Table: Symmetric measures.
904 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
905 Ordinal by Ordinal,Spearman Correlation,.66,.14,2.59,
906 Interval by Interval,Pearson's R,.67,.13,2.93,
907 N of Valid Cases,,12,,,
911 AT_DATA([pearson5.sps], [dnl
912 * From http://www.statisticslectures.com/topics/pearsonr/.
926 CROSSTABS x BY y/STATISTICS=CORR.
928 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
931 ,Valid,,Missing,,Total,
932 ,N,Percent,N,Percent,N,Percent
933 x * y,10,100.0%,0,0.0%,10,100.0%
935 Table: x * y [[count]].
936 ,y,,,,,,,,,,
937 x,15000.00,26000.00,29000.00,32000.00,33000.00,41000.00,45000.00,52000.00,68000.00,80000.00,Total
938 18.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
939 24.00,.00,1.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00
940 25.00,.00,.00,1.00,.00,.00,.00,.00,.00,.00,.00,1.00
941 26.00,.00,.00,.00,1.00,.00,.00,.00,.00,.00,.00,1.00
942 33.00,.00,.00,.00,.00,1.00,.00,.00,.00,.00,.00,1.00
943 37.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,.00,1.00
944 40.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,.00,1.00
945 45.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,.00,1.00
946 57.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,.00,1.00
947 64.00,.00,.00,.00,.00,.00,.00,.00,.00,.00,1.00,1.00
948 Total,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,10.00
950 Table: Symmetric measures.
951 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
952 Ordinal by Ordinal,Spearman Correlation,1.00,.00,3.76,
953 Interval by Interval,Pearson's R,.99,.00,3.86,
954 N of Valid Cases,,10,,,