output: Introduce pivot tables.
[pspp] / tests / language / stats / crosstabs.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
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.
8 dnl 
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.
13 dnl 
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/>.
16 dnl
17 AT_BANNER([CROSSTABS procedure])
18
19 AT_SETUP([CROSSTABS integer mode crash])
20 AT_DATA([crosstabs.sps],
21   [DATA LIST LIST /A * B * X * Y * .
22 BEGIN DATA.
23 2 3 4 5
24 END DATA.
25
26 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
27 ])
28 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
29 AT_CHECK([cat pspp.csv], [0],
30   [[Table: Reading free-form data from INLINE.
31 Variable,Format
32 A,F8.0
33 B,F8.0
34 X,F8.0
35 Y,F8.0
36
37 Table: Summary
38 ,Cases,,,,,
39 ,Valid,,Missing,,Total,
40 ,N,Percent,N,Percent,N,Percent
41 X × Y,1,100.0%,0,.0%,1,100.0%
42
43 Table: X × Y
44 ,,,Y,,,,,,,Total
45 ,,,1.00,2.00,3.00,4.00,5.00,6.00,7.00,
46 X,1.00,Count,0,0,0,0,0,0,0,0
47 ,2.00,,0,0,0,0,0,0,0,0
48 ,3.00,,0,0,0,0,0,0,0,0
49 ,4.00,,0,0,0,0,1,0,0,1
50 ,5.00,,0,0,0,0,0,0,0,0
51 ,6.00,,0,0,0,0,0,0,0,0
52 ,7.00,,0,0,0,0,0,0,0,0
53 Total,,,0,0,0,0,1,0,0,1
54 ]])
55 AT_CLEANUP
56
57 # Bug #47600.
58 AT_SETUP([CROSSTABS integer mode crash 2])
59 AT_DATA([crosstabs.sps], [dnl
60 DATA LIST lIST /x y.
61 BEGIN DATA.
62 4 5
63 END DATA.
64
65 CROSSTABS
66         VARIABLES x (1,3) y (1,7)
67       /TABLES x BY y.
68 ])
69 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
70   [[Table: Reading free-form data from INLINE.
71 Variable,Format
72 x,F8.0
73 y,F8.0
74
75 Table: Summary
76 ,Cases,,,,,
77 ,Valid,,Missing,,Total,
78 ,N,Percent,N,Percent,N,Percent
79 x × y,0,.0%,1,100.0%,1,100.0%
80
81 Table: x × y
82 ,,
83 ,,
84 ]])
85 AT_CLEANUP
86
87 # Bug #22037.
88 AT_SETUP([CROSSTABS long string crash])
89 AT_DATA([crosstabs.sps],
90   [data list list /x * y (a18).
91
92 begin data.
93
94    1. 'zero none'
95
96 1 'one unity'
97 2 'two duality'
98 3 'three lots'
99 end data.
100
101 CROSSTABS /TABLES = x BY y.
102 ])
103 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
104   [[Table: Reading free-form data from INLINE.
105 Variable,Format
106 x,F8.0
107 y,A18
108
109 "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."
110
111 "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."
112
113 Table: Summary
114 ,Cases,,,,,
115 ,Valid,,Missing,,Total,
116 ,N,Percent,N,Percent,N,Percent
117 x × y,4,66.7%,2,33.3%,6,100.0%
118
119 Table: x × y
120 ,,,y,,,,Total
121 ,,,one unity,three lots,two duality,zero none,
122 x,1.00,Count,1,0,0,1,2
123 ,2.00,,0,0,1,0,1
124 ,3.00,,0,1,0,0,1
125 Total,,,1,1,1,1,4
126 ]])
127 AT_CLEANUP
128
129 AT_SETUP([CROSSTABS crash])
130 AT_DATA([crosstabs.sps],
131   [[DATA LIST FIXED
132      / x   1-2
133        y   3
134        z   4.
135
136 BEGIN DATA.
137 0111 
138 0222 
139 0311 
140 0412 
141 0521 
142 0612 
143 0711 
144 0811 
145 0912 
146 END DATA.
147
148 LIST.
149
150
151 CROSSTABS TABLES  y by z.
152 ]])
153 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
154   [Table: Reading 1 record from INLINE.
155 Variable,Record,Columns,Format
156 x,1,1-  2,F2.0
157 y,1,3-  3,F1.0
158 z,1,4-  4,F1.0
159
160 Table: Data List
161 x,y,z
162 1,1,1
163 2,2,2
164 3,1,1
165 4,1,2
166 5,2,1
167 6,1,2
168 7,1,1
169 8,1,1
170 9,1,2
171
172 Table: Summary
173 ,Cases,,,,,
174 ,Valid,,Missing,,Total,
175 ,N,Percent,N,Percent,N,Percent
176 y × z,9,100.0%,0,.0%,9,100.0%
177
178 Table: y × z
179 ,,,z,,Total
180 ,,,1,2,
181 y,1,Count,4,3,7
182 ,2,,1,1,2
183 Total,,,5,4,9
184 ])
185 AT_CLEANUP
186
187 # Bug #26739, which caused CROSSTABS to crash or to fail to output
188 # chi-square results.
189 AT_SETUP([CROSSTABS chi-square crash])
190 AT_DATA([crosstabs.sps],
191   [[DATA LIST LIST /x * y *.
192 BEGIN DATA.
193 2 2
194 3 1
195 4 2
196 4 1
197 END DATA.
198
199 CROSSTABS
200         /TABLES= x BY y
201         /STATISTICS=CHISQ.
202 ]])
203 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
204   [[Table: Reading free-form data from INLINE.
205 Variable,Format
206 x,F8.0
207 y,F8.0
208
209 Table: Summary
210 ,Cases,,,,,
211 ,Valid,,Missing,,Total,
212 ,N,Percent,N,Percent,N,Percent
213 x × y,4,100.0%,0,.0%,4,100.0%
214
215 Table: x × y
216 ,,,y,,Total
217 ,,,1.00,2.00,
218 x,2.00,Count,0,1,1
219 ,3.00,,1,0,1
220 ,4.00,,1,1,2
221 Total,,,2,2,4
222
223 Table: Chi-Square Tests
224 ,Value,df,Asymptotic Sig. (2-tailed)
225 Pearson Chi-Square,2.00,2,.368
226 Likelihood Ratio,2.77,2,.250
227 Linear-by-Linear Association,.27,1,.602
228 N of Valid Cases,4,,
229 ]])
230 AT_CLEANUP
231
232 # Bug #27883.
233 AT_SETUP([CROSSTABS crash with SPLIT FILE])
234 AT_DATA([crosstabs.sps],
235   [data list notable / v0 to v2 1-6 (A)
236 begin data.
237 a c e
238 a c e
239 a c e
240 a d e
241 a d f
242 b d f
243 b d f
244 b c f
245 b d e
246 a c f
247 end data.
248 SORT CASES BY v0.
249 SPLIT FILE SEPARATE BY v0.
250
251 CROSSTABS
252     /TABLES= v1 BY v2
253     /FORMAT=AVALUE TABLES PIVOT
254     /STATISTICS=CHISQ
255     /CELLS=COUNT ROW COLUMN TOTAL.
256 ])
257
258 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
259 AT_CHECK([cat pspp.csv], [0], [dnl
260 Table: Split Values
261 Variable,Value
262 v0,a
263
264 Table: Summary
265 ,Cases,,,,,
266 ,Valid,,Missing,,Total,
267 ,N,Percent,N,Percent,N,Percent
268 v1 × v2,6,100.0%,0,.0%,6,100.0%
269
270 Table: v1 × v2
271 ,,,v2,,Total
272 ,,,e,f,
273 v1,c,Count,3,1,4
274 ,,Row %,75.0%,25.0%,100.0%
275 ,,Column %,75.0%,50.0%,66.7%
276 ,,Total %,50.0%,16.7%,66.7%
277 ,d,Count,1,1,2
278 ,,Row %,50.0%,50.0%,100.0%
279 ,,Column %,25.0%,50.0%,33.3%
280 ,,Total %,16.7%,16.7%,33.3%
281 Total,,Count,4,2,6
282 ,,Row %,66.7%,33.3%,100.0%
283 ,,Column %,100.0%,100.0%,100.0%
284 ,,Total %,66.7%,33.3%,100.0%
285
286 Table: Chi-Square Tests
287 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
288 Pearson Chi-Square,.38,1,.540,,
289 Likelihood Ratio,.37,1,.545,,
290 Fisher's Exact Test,,,,1.000,.600
291 Continuity Correction,.00,1,1.000,,
292 N of Valid Cases,6,,,,
293
294 Table: Split Values
295 Variable,Value
296 v0,b
297
298 Table: Summary
299 ,Cases,,,,,
300 ,Valid,,Missing,,Total,
301 ,N,Percent,N,Percent,N,Percent
302 v1 × v2,4,100.0%,0,.0%,4,100.0%
303
304 Table: v1 × v2
305 ,,,v2,,Total
306 ,,,e,f,
307 v1,c,Count,0,1,1
308 ,,Row %,.0%,100.0%,100.0%
309 ,,Column %,.0%,33.3%,25.0%
310 ,,Total %,.0%,25.0%,25.0%
311 ,d,Count,1,2,3
312 ,,Row %,33.3%,66.7%,100.0%
313 ,,Column %,100.0%,66.7%,75.0%
314 ,,Total %,25.0%,50.0%,75.0%
315 Total,,Count,1,3,4
316 ,,Row %,25.0%,75.0%,100.0%
317 ,,Column %,100.0%,100.0%,100.0%
318 ,,Total %,25.0%,75.0%,100.0%
319
320 Table: Chi-Square Tests
321 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
322 Pearson Chi-Square,.44,1,.505,,
323 Likelihood Ratio,.68,1,.410,,
324 Fisher's Exact Test,,,,1.000,.750
325 Continuity Correction,.00,1,1.000,,
326 N of Valid Cases,4,,,,
327 ])
328 AT_CLEANUP
329
330 # Bug #24752.
331 AT_SETUP([3-way CROSSTABS])
332 AT_DATA([crosstabs.sps],
333   [[DATA LIST FIXED
334      / x   1-2
335        y   3
336        z   4.
337
338 BEGIN DATA.
339 0111 
340 0222 
341 0311 
342 0412 
343 0521 
344 0612 
345 0711 
346 0811 
347 0912 
348 END DATA.
349
350 LIST.
351
352
353 CROSSTABS TABLES  x BY y BY z/STATISTICS=ALL.
354 ]])
355 AT_CHECK([pspp -o - -O format=csv -o pspp.csv -o pspp.txt crosstabs.sps], [0],
356   [Table: Reading 1 record from INLINE.
357 Variable,Record,Columns,Format
358 x,1,1-  2,F2.0
359 y,1,3-  3,F1.0
360 z,1,4-  4,F1.0
361
362 Table: Data List
363 x,y,z
364 1,1,1
365 2,2,2
366 3,1,1
367 4,1,2
368 5,2,1
369 6,1,2
370 7,1,1
371 8,1,1
372 9,1,2
373
374 Table: Summary
375 ,Cases,,,,,
376 ,Valid,,Missing,,Total,
377 ,N,Percent,N,Percent,N,Percent
378 x × y × z,9,100.0%,0,.0%,9,100.0%
379
380 Table: x × y × z
381 ,,,,,y,,Total
382 ,,,,,1,2,
383 z,1,x,1,Count,1,0,1
384 ,,,3,,0,0,1
385 ,,,5,,1,0,1
386 ,,,7,,0,0,1
387 ,,,8,,0,1,1
388 ,,Total,,,4,1,5
389 ,2,x,2,,0,0,1
390 ,,,4,,0,1,1
391 ,,,6,,0,0,1
392 ,,,9,,1,0,1
393 ,,Total,,,3,1,4
394
395 Table: Chi-Square Tests
396 ,,,Value,df,Asymptotic Sig. (2-tailed)
397 z,1,Pearson Chi-Square,5.00,4,.287
398 ,,Likelihood Ratio,5.00,4,.287
399 ,,Linear-by-Linear Association,.01,1,.938
400 ,,N of Valid Cases,5,,
401 ,2,Pearson Chi-Square,4.00,3,.261
402 ,,Likelihood Ratio,4.50,3,.212
403 ,,Linear-by-Linear Association,1.58,1,.209
404 ,,N of Valid Cases,4,,
405
406 Table: Symmetric Measures
407 ,,,,Value,Asymp. Std. Error,Approx. T
408 z,1,Nominal by Nominal,Phi,1.00,,
409 ,,,Cramer's V,1.00,,
410 ,,,Contingency Coefficient,.71,,
411 ,,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00
412 ,,,Kendall's tau-c,.00,.32,.00
413 ,,,Gamma,.00,.50,.00
414 ,,,Spearman Correlation,.00,.22,.00
415 ,,Interval by Interval,Pearson's R,.04,.22,.07
416 ,,N of Valid Cases,,5,,
417 ,2,Nominal by Nominal,Phi,1.00,,
418 ,,,Cramer's V,1.00,,
419 ,,,Contingency Coefficient,.71,,
420 ,,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73
421 ,,,Kendall's tau-c,-.75,.43,-1.73
422 ,,,Gamma,-1.00,.00,-1.73
423 ,,,Spearman Correlation,-.77,.17,-1.73
424 ,,Interval by Interval,Pearson's R,-.73,.18,-1.49
425 ,,N of Valid Cases,,4,,
426
427 Table: Directional Measures
428 ,,,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
429 z,1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
430 ,,,,x Dependent,.25,.22,1.12,.264
431 ,,,,y Dependent,1.00,.00,1.12,.264
432 ,,,Goodman and Kruskal tau,x Dependent,.25,,,
433 ,,,,y Dependent,1.00,,,
434 ,,,Uncertainty Coefficient,Symmetric,.47,.18,,
435 ,,,,x Dependent,.31,.15,2.02,
436 ,,,,y Dependent,1.00,.00,2.02,
437 ,,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
438 ,,,,x Dependent,.00,.50,.00,1.000
439 ,,,,y Dependent,.00,.20,.00,1.000
440 ,,Nominal by Interval,Eta,x Dependent,.04,,,
441 ,,,,y Dependent,1.00,,,
442 ,2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
443 ,,,,x Dependent,.33,.27,1.15,.248
444 ,,,,y Dependent,1.00,.00,1.15,.248
445 ,,,Goodman and Kruskal tau,x Dependent,.33,,,
446 ,,,,y Dependent,1.00,,,
447 ,,,Uncertainty Coefficient,Symmetric,.58,.17,,
448 ,,,,x Dependent,.41,.17,2.36,
449 ,,,,y Dependent,1.00,.00,2.36,
450 ,,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
451 ,,,,x Dependent,-1.00,.00,-1.73,.083
452 ,,,,y Dependent,-.50,.29,-1.73,.083
453 ,,Nominal by Interval,Eta,x Dependent,.73,,,
454 ,,,,y Dependent,1.00,,,
455 ])
456 AT_CLEANUP
457
458 AT_SETUP([CROSSTABS rounding weights with COUNT])
459 AT_DATA([crosstabs.sps],
460   [[DATA LIST NOTABLE LIST /x y w.
461 BEGIN DATA.
462 1 1 1.4
463 1 1 1.4
464 1 2 1.6
465 1 2 1.6
466 2 1 1
467 2 2 2
468 END DATA.
469 WEIGHT BY w.
470
471 * These should have the same effect (no rounding).
472 CROSSTABS /TABLES x BY y.
473 CROSSTABS /TABLES x BY y /COUNT ASIS.
474
475 * Round input weights.
476 CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
477 CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
478
479 * Round cell weights.
480 CROSSTABS /TABLES x BY y /COUNT.
481 CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
482 ]])
483
484 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
485 AT_CHECK([cat pspp.csv], [0],
486   [Table: Summary
487 ,Cases,,,,,
488 ,Valid,,Missing,,Total,
489 ,N,Percent,N,Percent,N,Percent
490 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
491
492 Table: x × y
493 ,,,y,,Total
494 ,,,1.00,2.00,
495 x,1.00,Count,2.80,3.20,6.00
496 ,2.00,,1.00,2.00,3.00
497 Total,,,3.80,5.20,9.00
498
499 Table: Summary
500 ,Cases,,,,,
501 ,Valid,,Missing,,Total,
502 ,N,Percent,N,Percent,N,Percent
503 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
504
505 Table: x × y
506 ,,,y,,Total
507 ,,,1.00,2.00,
508 x,1.00,Count,2.80,3.20,6.00
509 ,2.00,,1.00,2.00,3.00
510 Total,,,3.80,5.20,9.00
511
512 Table: Summary
513 ,Cases,,,,,
514 ,Valid,,Missing,,Total,
515 ,N,Percent,N,Percent,N,Percent
516 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
517
518 Table: x × y
519 ,,,y,,Total
520 ,,,1.00,2.00,
521 x,1.00,Count,2.00,4.00,6.00
522 ,2.00,,1.00,2.00,3.00
523 Total,,,3.00,6.00,9.00
524
525 Table: Summary
526 ,Cases,,,,,
527 ,Valid,,Missing,,Total,
528 ,N,Percent,N,Percent,N,Percent
529 x × y,7.00,100.0%,.00,.0%,7.00,100.0%
530
531 Table: x × y
532 ,,,y,,Total
533 ,,,1.00,2.00,
534 x,1.00,Count,2.00,2.00,4.00
535 ,2.00,,1.00,2.00,3.00
536 Total,,,3.00,4.00,7.00
537
538 Table: Summary
539 ,Cases,,,,,
540 ,Valid,,Missing,,Total,
541 ,N,Percent,N,Percent,N,Percent
542 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
543
544 Table: x × y
545 ,,,y,,Total
546 ,,,1.00,2.00,
547 x,1.00,Count,3.00,3.00,6.00
548 ,2.00,,1.00,2.00,3.00
549 Total,,,4.00,5.00,9.00
550
551 Table: Summary
552 ,Cases,,,,,
553 ,Valid,,Missing,,Total,
554 ,N,Percent,N,Percent,N,Percent
555 x × y,8.00,100.0%,.00,.0%,8.00,100.0%
556
557 Table: x × y
558 ,,,y,,Total
559 ,,,1.00,2.00,
560 x,1.00,Count,2.00,3.00,5.00
561 ,2.00,,1.00,2.00,3.00
562 Total,,,3.00,5.00,8.00
563 ])
564 AT_CLEANUP
565
566 AT_SETUP([CROSSTABS descending sort order])
567 AT_DATA([crosstabs-descending.sps],
568   [[DATA LIST NOTABLE LIST /x * y *.
569 BEGIN DATA.
570 2 2
571 2 2
572 3 1
573 4 1
574 3 2
575 3 2
576 END DATA.
577
578 CROSSTABS
579         /TABLES= x BY y
580         /FORMAT = DVALUE.
581 ]])
582
583 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs-descending.sps])
584 AT_CHECK([cat pspp.csv], [0],
585   [Table: Summary
586 ,Cases,,,,,
587 ,Valid,,Missing,,Total,
588 ,N,Percent,N,Percent,N,Percent
589 x × y,6,100.0%,0,.0%,6,100.0%
590
591 Table: x × y
592 ,,,y,,Total
593 ,,,2.00,1.00,
594 x,4.00,Count,0,1,1
595 ,3.00,,2,1,3
596 ,2.00,,2,0,2
597 Total,,,4,2,6
598 ])
599 AT_CLEANUP
600
601 # Bug #31260.
602 AT_SETUP([CROSSTABS crash when all cases missing])
603 AT_DATA([crosstabs.sps], [dnl
604 DATA LIST LIST NOTABLE /X1 X2.
605 BEGIN DATA.
606 1 1
607 END DATA.
608
609 MISSING VALUES x2 (1).
610
611 CROSSTABS /TABLES= X1 by X2.
612 ])
613 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
614 Table: Summary
615 ,Cases,,,,,
616 ,Valid,,Missing,,Total,
617 ,N,Percent,N,Percent,N,Percent
618 X1 × X2,0,.0%,1,100.0%,1,100.0%
619
620 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 × X2 contained no non-missing cases.
621 ])
622 AT_CLEANUP
623
624
625
626 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
627 AT_SETUP([CROSSTABS Fisher Exact Test])
628
629 AT_DATA([fisher-exact.sps], [dnl
630 SET FORMAT F12.3.
631 SET DECIMAL DOT.
632
633 DATA LIST notable LIST  /schtyp (F9.2) female (F9.2) ses (F9.2) .
634 begin data.
635       1.00       .00      1.00 
636       1.00      1.00      2.00 
637       1.00       .00      3.00 
638       1.00       .00      3.00 
639       1.00       .00      2.00 
640       1.00       .00      2.00 
641       1.00       .00      2.00 
642       1.00       .00      2.00 
643       1.00       .00      2.00 
644       1.00       .00      2.00 
645       1.00       .00      2.00 
646       1.00       .00      2.00 
647       1.00       .00      3.00 
648       1.00       .00      3.00 
649       1.00       .00      1.00 
650       1.00       .00      1.00 
651       1.00       .00      3.00 
652       2.00       .00      2.00 
653       1.00       .00      3.00 
654       1.00       .00      2.00 
655       1.00       .00      2.00 
656       1.00       .00      2.00 
657       1.00       .00      2.00 
658       1.00       .00      3.00 
659       1.00       .00      2.00 
660       1.00       .00      2.00 
661       1.00       .00      3.00 
662       2.00       .00      2.00 
663       2.00       .00      3.00 
664       1.00       .00      1.00 
665       1.00       .00      2.00 
666       1.00       .00      3.00 
667       2.00       .00      3.00 
668       1.00       .00      2.00 
669       2.00       .00      3.00 
670       1.00       .00      3.00 
671       2.00       .00      2.00 
672       1.00       .00      3.00 
673       1.00       .00      1.00 
674       1.00       .00      2.00 
675       2.00       .00      2.00 
676       2.00       .00      2.00 
677       1.00       .00      2.00 
678       1.00       .00      1.00 
679       1.00       .00      3.00 
680       1.00       .00      1.00 
681       1.00       .00      3.00 
682       1.00       .00      2.00 
683       2.00       .00      2.00 
684       1.00       .00      2.00 
685       1.00       .00      2.00 
686       1.00       .00      3.00 
687       1.00       .00      2.00 
688       2.00       .00      2.00 
689       1.00       .00      2.00 
690       1.00       .00      3.00 
691       1.00       .00      1.00 
692       1.00       .00      2.00 
693       2.00       .00      2.00 
694       1.00       .00      2.00 
695       2.00       .00      2.00 
696       1.00       .00      3.00 
697       1.00       .00      1.00 
698       1.00       .00      2.00 
699       2.00       .00      3.00 
700       1.00       .00      2.00 
701       1.00       .00      2.00 
702       1.00       .00      1.00 
703       1.00       .00      1.00 
704       1.00       .00      2.00 
705       1.00       .00      2.00 
706       1.00       .00      3.00 
707       1.00       .00      2.00 
708       1.00       .00      2.00 
709       1.00       .00      2.00 
710       1.00       .00      1.00 
711       1.00       .00      3.00 
712       1.00       .00      3.00 
713       1.00       .00      2.00 
714       1.00       .00      3.00 
715       1.00       .00      3.00 
716       1.00       .00      1.00 
717       2.00       .00      2.00 
718       1.00       .00      1.00 
719       1.00       .00      2.00 
720       1.00       .00      3.00 
721       1.00       .00      3.00 
722       1.00       .00      3.00 
723       1.00       .00      2.00 
724       1.00       .00      3.00 
725       1.00       .00      2.00 
726       1.00       .00      1.00 
727       1.00      1.00      3.00 
728       1.00      1.00      1.00 
729       1.00      1.00      1.00 
730       1.00      1.00      1.00 
731       1.00      1.00      2.00 
732       1.00      1.00      3.00 
733       1.00      1.00      1.00 
734       2.00      1.00      3.00 
735       1.00      1.00      3.00 
736       1.00      1.00      3.00 
737       1.00      1.00      1.00 
738       1.00      1.00      3.00 
739       1.00      1.00      2.00 
740       1.00      1.00      2.00 
741       1.00      1.00      3.00 
742       1.00      1.00      1.00 
743       2.00      1.00      1.00 
744       2.00      1.00      3.00 
745       1.00      1.00      2.00 
746       1.00      1.00      1.00 
747       1.00      1.00      3.00 
748       1.00      1.00      1.00 
749       2.00      1.00      3.00 
750       1.00      1.00      2.00 
751       1.00      1.00      3.00 
752       1.00      1.00      3.00 
753       1.00      1.00      1.00 
754       1.00      1.00      1.00 
755       2.00      1.00      1.00 
756       1.00      1.00      2.00 
757       1.00      1.00      2.00 
758       1.00      1.00      2.00 
759       1.00      1.00      1.00 
760       1.00      1.00      3.00 
761       1.00      1.00      2.00 
762       1.00      1.00      2.00 
763       1.00      1.00      3.00 
764       1.00      1.00      1.00 
765       1.00      1.00      2.00 
766       1.00      1.00      1.00 
767       1.00      1.00      2.00 
768       1.00      1.00      2.00 
769       1.00      1.00      1.00 
770       1.00      1.00      3.00 
771       2.00      1.00      2.00 
772       1.00      1.00      2.00 
773       1.00      1.00      2.00 
774       2.00      1.00      2.00 
775       1.00      1.00      1.00 
776       1.00      1.00      3.00 
777       1.00      1.00      2.00 
778       1.00      1.00      2.00 
779       1.00      1.00      2.00 
780       2.00      1.00      3.00 
781       1.00      1.00      2.00 
782       2.00      1.00      2.00 
783       1.00      1.00      1.00 
784       1.00      1.00      1.00 
785       1.00      1.00      1.00 
786       1.00      1.00      3.00 
787       1.00      1.00      2.00 
788       1.00      1.00      2.00 
789       1.00      1.00      2.00 
790       1.00      1.00      2.00 
791       1.00      1.00      2.00 
792       1.00      1.00      2.00 
793       1.00      1.00      2.00 
794       1.00      1.00      3.00 
795       1.00      1.00      1.00 
796       1.00      1.00      2.00 
797       2.00      1.00      3.00 
798       1.00      1.00      1.00 
799       1.00      1.00      2.00 
800       1.00      1.00      1.00 
801       1.00      1.00      2.00 
802       1.00      1.00      1.00 
803       2.00      1.00      2.00 
804       1.00      1.00      1.00 
805       1.00      1.00      1.00 
806       1.00      1.00      2.00 
807       1.00      1.00      3.00 
808       1.00      1.00      3.00 
809       1.00      1.00      1.00 
810       1.00      1.00      1.00 
811       1.00      1.00      2.00 
812       1.00      1.00      2.00 
813       1.00      1.00      3.00 
814       1.00      1.00      1.00 
815       1.00      1.00      2.00 
816       2.00      1.00      2.00 
817       1.00      1.00      3.00 
818       1.00      1.00      2.00 
819       1.00      1.00      3.00 
820       1.00      1.00      1.00 
821       1.00      1.00      2.00 
822       1.00      1.00      2.00 
823       2.00      1.00      3.00 
824       1.00      1.00      1.00 
825       1.00      1.00      1.00 
826       2.00      1.00      3.00 
827       2.00      1.00      2.00 
828       1.00      1.00      3.00 
829       2.00      1.00      2.00 
830       2.00      1.00      2.00 
831       1.00      1.00      2.00 
832       2.00      1.00      2.00 
833       1.00      1.00      2.00 
834       1.00      1.00      3.00 
835 end data.
836
837 VARIABLE LABEL schtyp 'type of school'.
838 ADD VALUE LABELS female 0 male 1 female.
839 ADD VALUE LABELS ses 1 low 2 middle 3 high.
840 ADD VALUE LABELS schtyp 1 public 2 private.
841
842 crosstabs /tables = schtyp by female /statistic = chisq.
843 crosstabs /tables = female by ses  /statistic = chisq.
844 ])
845
846 AT_CHECK([pspp -o pspp.csv -o pspp.txt fisher-exact.sps])
847 AT_CHECK([cat pspp.csv], [0], [Table: Summary
848 ,Cases,,,,,
849 ,Valid,,Missing,,Total,
850 ,N,Percent,N,Percent,N,Percent
851 type of school × female,200,100.0%,0,.0%,200,100.0%
852
853 Table: type of school × female
854 ,,,female,,Total
855 ,,,male,female,
856 type of school,public,Count,77,91,168
857 ,private,,14,18,32
858 Total,,,91,109,200
859
860 Table: Chi-Square Tests
861 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
862 Pearson Chi-Square,.047,1,.828,,
863 Likelihood Ratio,.047,1,.828,,
864 Fisher's Exact Test,,,,.849,.492
865 Continuity Correction,.001,1,.981,,
866 Linear-by-Linear Association,.047,1,.829,,
867 N of Valid Cases,200,,,,
868
869 Table: Summary
870 ,Cases,,,,,
871 ,Valid,,Missing,,Total,
872 ,N,Percent,N,Percent,N,Percent
873 female × ses,200,100.0%,0,.0%,200,100.0%
874
875 Table: female × ses
876 ,,,ses,,,Total
877 ,,,low,middle,high,
878 female,male,Count,15,47,29,91
879 ,female,,32,48,29,109
880 Total,,,47,95,58,200
881
882 Table: Chi-Square Tests
883 ,Value,df,Asymptotic Sig. (2-tailed)
884 Pearson Chi-Square,4.577,2,.101
885 Likelihood Ratio,4.679,2,.096
886 Linear-by-Linear Association,3.110,1,.078
887 N of Valid Cases,200,,
888 ])
889
890 AT_CLEANUP
891
892 AT_SETUP([CROSSTABS Pearson's R - 1])
893 AT_DATA([pearson.sps], [dnl
894 SET FORMAT F8.3.
895
896 * From http://www.statisticslectures.com/topics/pearsonr/.
897 DATA LIST FREE/x y.
898 BEGIN DATA.
899 1 4
900 3 6
901 5 10
902 5 12
903 6 13
904 END DATA.
905 CROSSTABS x BY y/STATISTICS=CORR.
906 ])
907 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson.sps])
908 AT_CHECK([cat pspp.csv], [0], [dnl
909 Table: Summary
910 ,Cases,,,,,
911 ,Valid,,Missing,,Total,
912 ,N,Percent,N,Percent,N,Percent
913 x × y,5,100.0%,0,.0%,5,100.0%
914
915 Table: x × y
916 ,,,y,,,,,Total
917 ,,,4.000,6.000,10.000,12.000,13.000,
918 x,1.000,Count,1,0,0,0,0,1
919 ,3.000,,0,1,0,0,0,1
920 ,5.000,,0,0,1,1,0,2
921 ,6.000,,0,0,0,0,1,1
922 Total,,,1,1,1,1,1,5
923
924 Table: Symmetric Measures
925 ,,Value,Asymp. Std. Error,Approx. T
926 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550
927 Interval by Interval,Pearson's R,.968,.017,6.708
928 N of Valid Cases,,5,,
929 ])
930 AT_CLEANUP
931
932 AT_SETUP([CROSSTABS Pearson's R - 2])
933 AT_DATA([pearson2.sps], [dnl
934 SET FORMAT F8.3.
935
936 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
937 DATA LIST FREE/x y.
938 BEGIN DATA.
939 1 1.5
940 2 1.5
941 3 4
942 4 6
943 5 5
944 6 7
945 7 6.5
946 8 9
947 9 10.5
948 10 11
949 END DATA.
950 CROSSTABS x BY y/STATISTICS=CORR.
951 ])
952 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson2.sps])
953 AT_CHECK([cat pspp.csv], [0], [dnl
954 Table: Summary
955 ,Cases,,,,,
956 ,Valid,,Missing,,Total,
957 ,N,Percent,N,Percent,N,Percent
958 x × y,10,100.0%,0,.0%,10,100.0%
959
960 Table: x × y
961 ,,,y,,,,,,,,,Total
962 ,,,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,
963 x,1.000,Count,1,0,0,0,0,0,0,0,0,1
964 ,2.000,,1,0,0,0,0,0,0,0,0,1
965 ,3.000,,0,1,0,0,0,0,0,0,0,1
966 ,4.000,,0,0,0,1,0,0,0,0,0,1
967 ,5.000,,0,0,1,0,0,0,0,0,0,1
968 ,6.000,,0,0,0,0,0,1,0,0,0,1
969 ,7.000,,0,0,0,0,1,0,0,0,0,1
970 ,8.000,,0,0,0,0,0,0,1,0,0,1
971 ,9.000,,0,0,0,0,0,0,0,1,0,1
972 ,10.000,,0,0,0,0,0,0,0,0,1,1
973 Total,,,2,1,1,1,1,1,1,1,1,10
974
975 Table: Symmetric Measures
976 ,,Value,Asymp. Std. Error,Approx. T
977 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844
978 Interval by Interval,Pearson's R,.971,.017,11.580
979 N of Valid Cases,,10,,
980 ])
981 AT_CLEANUP
982
983 AT_SETUP([CROSSTABS Pearson's R - 3])
984 AT_DATA([pearson3.sps], [dnl
985 SET FORMAT F8.3.
986
987 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
988 DATA LIST FREE/x y.
989 BEGIN DATA.
990 56 87
991 56 91
992 65 85
993 65 91
994 50 75
995 25 28
996 87 122
997 44 66
998 35 58
999 END DATA.
1000 CROSSTABS x BY y/STATISTICS=CORR.
1001 ])
1002 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson3.sps])
1003 AT_CHECK([cat pspp.csv], [0], [dnl
1004 Table: Summary
1005 ,Cases,,,,,
1006 ,Valid,,Missing,,Total,
1007 ,N,Percent,N,Percent,N,Percent
1008 x × y,9,100.0%,0,.0%,9,100.0%
1009
1010 Table: x × y
1011 ,,,y,,,,,,,,Total
1012 ,,,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,
1013 x,25.000,Count,1,0,0,0,0,0,0,0,1
1014 ,35.000,,0,1,0,0,0,0,0,0,1
1015 ,44.000,,0,0,1,0,0,0,0,0,1
1016 ,50.000,,0,0,0,1,0,0,0,0,1
1017 ,56.000,,0,0,0,0,0,1,1,0,2
1018 ,65.000,,0,0,0,0,1,0,1,0,2
1019 ,87.000,,0,0,0,0,0,0,0,1,1
1020 Total,,,1,1,1,1,1,1,2,1,9
1021
1022 Table: Symmetric Measures
1023 ,,Value,Asymp. Std. Error,Approx. T
1024 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860
1025 Interval by Interval,Pearson's R,.966,.017,9.915
1026 N of Valid Cases,,9,,
1027 ])
1028 AT_CLEANUP
1029
1030 AT_SETUP([CROSSTABS Pearson's R - 4])
1031 AT_DATA([pearson4.sps], [dnl
1032 SET FORMAT F8.3.
1033
1034 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
1035 DATA LIST FREE/x y.
1036 BEGIN DATA.
1037 5 5
1038 10 20
1039 6 4
1040 8 15
1041 4 11
1042 4 9
1043 3 12
1044 10 18
1045 2 7
1046 6 2
1047 7 14
1048 9 17
1049 END DATA.
1050 CROSSTABS x BY y/STATISTICS=CORR.
1051 ])
1052 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson4.sps])
1053 AT_CHECK([cat pspp.csv], [0], [dnl
1054 Table: Summary
1055 ,Cases,,,,,
1056 ,Valid,,Missing,,Total,
1057 ,N,Percent,N,Percent,N,Percent
1058 x × y,12,100.0%,0,.0%,12,100.0%
1059
1060 Table: x × y
1061 ,,,y,,,,,,,,,,,,Total
1062 ,,,2.000,4.000,5.000,7.000,9.000,11.000,12.000,14.000,15.000,17.000,18.000,20.000,
1063 x,2.000,Count,0,0,0,1,0,0,0,0,0,0,0,0,1
1064 ,3.000,,0,0,0,0,0,0,1,0,0,0,0,0,1
1065 ,4.000,,0,0,0,0,1,1,0,0,0,0,0,0,2
1066 ,5.000,,0,0,1,0,0,0,0,0,0,0,0,0,1
1067 ,6.000,,1,1,0,0,0,0,0,0,0,0,0,0,2
1068 ,7.000,,0,0,0,0,0,0,0,1,0,0,0,0,1
1069 ,8.000,,0,0,0,0,0,0,0,0,1,0,0,0,1
1070 ,9.000,,0,0,0,0,0,0,0,0,0,1,0,0,1
1071 ,10.000,,0,0,0,0,0,0,0,0,0,0,1,1,2
1072 Total,,,1,1,1,1,1,1,1,1,1,1,1,1,12
1073
1074 Table: Symmetric Measures
1075 ,,Value,Asymp. Std. Error,Approx. T
1076 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758
1077 Interval by Interval,Pearson's R,.667,.132,2.830
1078 N of Valid Cases,,12,,
1079 ])
1080 AT_CLEANUP
1081
1082 AT_SETUP([CROSSTABS Pearson's R - 5])
1083 AT_DATA([pearson5.sps], [dnl
1084 SET FORMAT F8.3.
1085
1086 * From http://www.statisticslectures.com/topics/pearsonr/.
1087 DATA LIST FREE/x y.
1088 BEGIN DATA.
1089 18 15000
1090 25 29000
1091 57 68000
1092 45 52000
1093 26 32000
1094 64 80000
1095 37 41000
1096 40 45000
1097 24 26000
1098 33 33000
1099 END DATA.
1100 CROSSTABS x BY y/STATISTICS=CORR.
1101 ])
1102 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson5.sps])
1103 AT_CHECK([cat pspp.csv], [0], [dnl
1104 Table: Summary
1105 ,Cases,,,,,
1106 ,Valid,,Missing,,Total,
1107 ,N,Percent,N,Percent,N,Percent
1108 x × y,10,100.0%,0,.0%,10,100.0%
1109
1110 Table: x × y
1111 ,,,y,,,,,,,,,,Total
1112 ,,,15000.00,26000.00,29000.00,32000.00,33000.00,41000.00,45000.00,52000.00,68000.00,80000.00,
1113 x,18.000,Count,1,0,0,0,0,0,0,0,0,0,1
1114 ,24.000,,0,1,0,0,0,0,0,0,0,0,1
1115 ,25.000,,0,0,1,0,0,0,0,0,0,0,1
1116 ,26.000,,0,0,0,1,0,0,0,0,0,0,1
1117 ,33.000,,0,0,0,0,1,0,0,0,0,0,1
1118 ,37.000,,0,0,0,0,0,1,0,0,0,0,1
1119 ,40.000,,0,0,0,0,0,0,1,0,0,0,1
1120 ,45.000,,0,0,0,0,0,0,0,1,0,0,1
1121 ,57.000,,0,0,0,0,0,0,0,0,1,0,1
1122 ,64.000,,0,0,0,0,0,0,0,0,0,1,1
1123 Total,,,1,1,1,1,1,1,1,1,1,1,10
1124
1125 Table: Symmetric Measures
1126 ,,Value,Asymp. Std. Error,Approx. T
1127 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinit
1128 Interval by Interval,Pearson's R,.992,.004,22.638
1129 N of Valid Cases,,10,,
1130 ])
1131 AT_CLEANUP
1132
1133 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 1])
1134 AT_DATA([lambda.sps], [dnl
1135 SET FORMAT F8.3.
1136
1137 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
1138 DATA LIST LIST NOTABLE/x y w.
1139 WEIGHT BY w.
1140 BEGIN DATA.
1141 1 1 424
1142 1 2 213
1143 1 3 59
1144 3 1 55
1145 3 2 188
1146 3 3 357
1147 END DATA.
1148
1149 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1150 ])
1151 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1152 AT_CHECK([cat pspp.csv], [0], [dnl
1153 Table: Summary
1154 ,Cases,,,,,
1155 ,Valid,,Missing,,Total,
1156 ,N,Percent,N,Percent,N,Percent
1157 x × y,1296.000,100.0%,.000,.0%,1296.000,100.0%
1158
1159 Table: Directional Measures
1160 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1161 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1162 ,,x Dependent,.497,.024,15.986,.000
1163 ,,y Dependent,.370,.020,16.339,.000
1164 ,Goodman and Kruskal tau,x Dependent,.382,,,
1165 ,,y Dependent,.198,,,
1166 ])
1167 AT_CLEANUP
1168
1169 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 2])
1170 AT_DATA([lambda.sps], [dnl
1171 SET FORMAT F8.3.
1172
1173 * From http://vassarstats.net.
1174 DATA LIST LIST NOTABLE/x y w.
1175 WEIGHT BY w.
1176 BEGIN DATA.
1177 1 1 19
1178 1 2 26
1179 1 3 8
1180 2 1 21
1181 2 2 13
1182 2 3 5
1183 3 1 6
1184 3 2 12
1185 3 3 27
1186 END DATA.
1187
1188 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1189 ])
1190 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1191 AT_CHECK([cat pspp.csv], [0], [dnl
1192 Table: Summary
1193 ,Cases,,,,,
1194 ,Valid,,Missing,,Total,
1195 ,N,Percent,N,Percent,N,Percent
1196 x × y,137.000,100.0%,.000,.0%,137.000,100.0%
1197
1198 Table: Directional Measures
1199 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1200 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1201 ,,x Dependent,.250,.089,2.479,.013
1202 ,,y Dependent,.267,.085,2.766,.006
1203 ,Goodman and Kruskal tau,x Dependent,.129,,,
1204 ,,y Dependent,.123,,,
1205 ])
1206 AT_CLEANUP
1207
1208 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 3])
1209 AT_DATA([lambda.sps], [dnl
1210 SET FORMAT F8.3.
1211
1212 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1213   cross classifications". Part I. Journal of the American Statistical
1214   Association, 49, 732-764.
1215 DATA LIST LIST NOTABLE/x y w.
1216 WEIGHT BY w.
1217 BEGIN DATA.
1218 1 1 1768
1219 1 2 807
1220 1 3 189
1221 1 4 47
1222 2 1 946
1223 2 2 1387
1224 2 3 746
1225 2 4 53
1226 3 1 115
1227 3 2 438
1228 3 3 288
1229 3 4 16
1230 END DATA.
1231 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1232 ])
1233 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1234 AT_CHECK([cat pspp.csv], [0], [dnl
1235 Table: Summary
1236 ,Cases,,,,,
1237 ,Valid,,Missing,,Total,
1238 ,N,Percent,N,Percent,N,Percent
1239 x × y,6800.000,100.0%,.000,.0%,6800.000,100.0%
1240
1241 Table: Directional Measures
1242 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1243 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1244 ,,x Dependent,.224,.013,16.076,.000
1245 ,,y Dependent,.192,.012,14.438,.000
1246 ,Goodman and Kruskal tau,x Dependent,.089,,,
1247 ,,y Dependent,.081,,,
1248 ])
1249 AT_CLEANUP
1250
1251 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1252 AT_DATA([lambda.sps], [dnl
1253 SET FORMAT F8.3.
1254
1255 * From Douglas Bonett.
1256 DATA LIST LIST NOTABLE/x y w.
1257 WEIGHT BY w.
1258 BEGIN DATA.
1259 1 1 225
1260 1 2 43
1261 1 3 216
1262 2 1 3
1263 2 2 1
1264 2 3 12
1265 END DATA.
1266
1267 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1268 ])
1269 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1270 AT_CHECK([cat pspp.csv], [0], [dnl
1271 Table: Summary
1272 ,Cases,,,,,
1273 ,Valid,,Missing,,Total,
1274 ,N,Percent,N,Percent,N,Percent
1275 x × y,500.000,100.0%,.000,.0%,500.000,100.0%
1276
1277 Table: Directional Measures
1278 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1279 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1280 ,,x Dependent,.000,.000,NaN,NaN
1281 ,,y Dependent,.033,.014,2.336,.019
1282 ,Goodman and Kruskal tau,x Dependent,.012,,,
1283 ,,y Dependent,.009,,,
1284 ])
1285 AT_CLEANUP
1286
1287 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 1])
1288 AT_DATA([somersd.sps], [dnl
1289 SET FORMAT F8.3.
1290
1291 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1292 DATA LIST LIST NOTABLE/x y * w (F10.6).
1293 WEIGHT BY w.
1294 BEGIN DATA.
1295 1 1 0.000025
1296 1 2 0.0001
1297 1 3 0.001
1298 1 4 0.0025
1299 1 5 0.004
1300 1 6 0.0075
1301 1 7 0.0125
1302 2 1 0.049975
1303 2 2 0.0999
1304 2 3 0.199
1305 2 4 0.2475
1306 2 5 0.196
1307 2 6 0.1425
1308 2 7 0.0375
1309 END DATA.
1310 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1311 ])
1312 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1313 AT_CHECK([cat pspp.csv], [0], [dnl
1314 Table: Summary
1315 ,Cases,,,,,
1316 ,Valid,,Missing,,Total,
1317 ,N,Percent,N,Percent,N,Percent
1318 x × y,1.000000,100.0%,.000000,.0%,1.000000,100.0%
1319
1320 Table: Directional Measures
1321 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1322 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1323 ,,x Dependent,-.045,.300,-.149,.882
1324 ,,y Dependent,-.684,2.378,-.149,.882
1325 ])
1326 AT_CLEANUP
1327
1328 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 2])
1329 AT_DATA([somersd.sps], [dnl
1330 SET FORMAT F8.3.
1331
1332 * From http://uregina.ca/~gingrich/gamma.pdf.
1333 DATA LIST LIST NOTABLE/x y w.
1334 WEIGHT BY w.
1335 BEGIN DATA.
1336 1 1 34
1337 1 2 24
1338 1 3 15
1339 2 1 42
1340 2 2 74
1341 2 3 67
1342 3 1 28
1343 3 2 111
1344 3 3 292
1345 END DATA.
1346 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1347 ])
1348 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1349 AT_CHECK([cat pspp.csv], [0], [dnl
1350 Table: Summary
1351 ,Cases,,,,,
1352 ,Valid,,Missing,,Total,
1353 ,N,Percent,N,Percent,N,Percent
1354 x × y,687.000,100.0%,.000,.0%,687.000,100.0%
1355
1356 Table: Symmetric Measures
1357 ,,Value,Asymp. Std. Error,Approx. T
1358 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669
1359 ,Kendall's tau-c,.310,.029,10.669
1360 ,Gamma,.591,.043,10.669
1361 N of Valid Cases,,687.000,,
1362
1363 Table: Directional Measures
1364 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1365 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1366 ,,x Dependent,.351,.032,10.669,.000
1367 ,,y Dependent,.394,.035,10.669,.000
1368 ])
1369 AT_CLEANUP
1370
1371 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 3])
1372 AT_DATA([ordinal.sps], [dnl
1373 SET FORMAT F8.3.
1374
1375 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1376 DATA LIST LIST NOTABLE /x y w.
1377 WEIGHT BY w.
1378 BEGIN DATA.
1379 1 2 40
1380 2 3 80
1381 3 4 30
1382 END DATA.
1383 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1384
1385 * Same site, case 2.
1386 DATA LIST LIST NOTABLE /x y w.
1387 WEIGHT BY w.
1388 BEGIN DATA.
1389 1 1 40
1390 2 3 80
1391 3 4 30
1392 END DATA.
1393 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1394
1395 * Same site, case 3.
1396 DATA LIST LIST NOTABLE /x y w.
1397 WEIGHT BY w.
1398 BEGIN DATA.
1399 1 4 40
1400 2 3 80
1401 3 2 30
1402 END DATA.
1403 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1404
1405 * Same site, case 4.
1406 DATA LIST LIST NOTABLE /x y w.
1407 WEIGHT BY w.
1408 BEGIN DATA.
1409 1 1 20
1410 1 2 20
1411 2 3 80
1412 3 4 30
1413 END DATA.
1414 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1415
1416 * Same site, case 5.
1417 DATA LIST LIST NOTABLE /x y w.
1418 WEIGHT BY w.
1419 BEGIN DATA.
1420 1 2 40
1421 2 2 80
1422 3 2 29
1423 3 3 1
1424 END DATA.
1425 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1426
1427 * Same site, case 6.
1428 DATA LIST LIST NOTABLE /x y w.
1429 WEIGHT BY w.
1430 BEGIN DATA.
1431 1 1 3
1432 1 2 6
1433 1 3 28
1434 1 4 61
1435 2 1 4
1436 2 2 5
1437 2 3 21
1438 2 4 20
1439 END DATA.
1440 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1441
1442 * Same site, case 7.
1443 DATA LIST LIST NOTABLE /x y w.
1444 WEIGHT BY w.
1445 BEGIN DATA.
1446 1 1 38
1447 1 2 6
1448 1 3 3
1449 1 4 51
1450 2 1 4
1451 2 2 20
1452 2 3 21
1453 2 4 5
1454 END DATA.
1455 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1456
1457 * Same site, case 8.
1458 DATA LIST LIST NOTABLE /x y w.
1459 WEIGHT BY w.
1460 BEGIN DATA.
1461 1 1 2
1462 1 2 3
1463 1 3 5
1464 1 4 1
1465 2 1 2
1466 2 2 16
1467 2 3 3
1468 2 4 6
1469 3 1 3
1470 3 2 10
1471 3 3 35
1472 3 4 27
1473 4 1 6
1474 4 2 15
1475 4 3 33
1476 4 4 45
1477 END DATA.
1478 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1479 ])
1480 AT_CHECK([pspp -o pspp.csv -o pspp.txt ordinal.sps])
1481 AT_CHECK([cat pspp.csv], [0], [dnl
1482 Table: Summary
1483 ,Cases,,,,,
1484 ,Valid,,Missing,,Total,
1485 ,N,Percent,N,Percent,N,Percent
1486 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1487
1488 Table: Symmetric Measures
1489 ,,Value,Asymp. Std. Error,Approx. T
1490 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1491 ,Gamma,1.000,.000,24.841
1492 N of Valid Cases,,150.000,,
1493
1494 Table: Directional Measures
1495 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1496 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1497 ,,x Dependent,1.000,.000,24.841,.000
1498 ,,y Dependent,1.000,.000,24.841,.000
1499
1500 Table: Summary
1501 ,Cases,,,,,
1502 ,Valid,,Missing,,Total,
1503 ,N,Percent,N,Percent,N,Percent
1504 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1505
1506 Table: Symmetric Measures
1507 ,,Value,Asymp. Std. Error,Approx. T
1508 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1509 ,Gamma,1.000,.000,24.841
1510 N of Valid Cases,,150.000,,
1511
1512 Table: Directional Measures
1513 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1514 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1515 ,,x Dependent,1.000,.000,24.841,.000
1516 ,,y Dependent,1.000,.000,24.841,.000
1517
1518 Table: Summary
1519 ,Cases,,,,,
1520 ,Valid,,Missing,,Total,
1521 ,N,Percent,N,Percent,N,Percent
1522 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1523
1524 Table: Symmetric Measures
1525 ,,Value,Asymp. Std. Error,Approx. T
1526 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841
1527 ,Gamma,-1.000,.000,-24.841
1528 N of Valid Cases,,150.000,,
1529
1530 Table: Directional Measures
1531 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1532 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1533 ,,x Dependent,-1.000,.000,-24.841,.000
1534 ,,y Dependent,-1.000,.000,-24.841,.000
1535
1536 Table: Summary
1537 ,Cases,,,,,
1538 ,Valid,,Missing,,Total,
1539 ,N,Percent,N,Percent,N,Percent
1540 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1541
1542 Table: Symmetric Measures
1543 ,,Value,Asymp. Std. Error,Approx. T
1544 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841
1545 ,Gamma,1.000,.000,24.841
1546 N of Valid Cases,,150.000,,
1547
1548 Table: Directional Measures
1549 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1550 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1551 ,,x Dependent,.944,.013,24.841,.000
1552 ,,y Dependent,1.000,.000,24.841,.000
1553
1554 Table: Summary
1555 ,Cases,,,,,
1556 ,Valid,,Missing,,Total,
1557 ,N,Percent,N,Percent,N,Percent
1558 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1559
1560 Table: Symmetric Measures
1561 ,,Value,Asymp. Std. Error,Approx. T
1562 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009
1563 ,Gamma,1.000,.000,1.009
1564 N of Valid Cases,,150.000,,
1565
1566 Table: Directional Measures
1567 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1568 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1569 ,,x Dependent,.805,.032,1.009,.313
1570 ,,y Dependent,.018,.017,1.009,.313
1571
1572 Table: Summary
1573 ,Cases,,,,,
1574 ,Valid,,Missing,,Total,
1575 ,N,Percent,N,Percent,N,Percent
1576 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1577
1578 Table: Symmetric Measures
1579 ,,Value,Asymp. Std. Error,Approx. T
1580 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641
1581 ,Gamma,-.381,.130,-2.641
1582 N of Valid Cases,,148.000,,
1583
1584 Table: Directional Measures
1585 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1586 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1587 ,,x Dependent,-.182,.069,-2.641,.008
1588 ,,y Dependent,-.237,.089,-2.641,.008
1589
1590 Table: Summary
1591 ,Cases,,,,,
1592 ,Valid,,Missing,,Total,
1593 ,N,Percent,N,Percent,N,Percent
1594 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1595
1596 Table: Symmetric Measures
1597 ,,Value,Asymp. Std. Error,Approx. T
1598 Nominal by Nominal,Phi,.731,,
1599 ,Cramer's V,.731,,
1600 Ordinal by Ordinal,Gamma,-.110,.107,-1.022
1601 N of Valid Cases,,148.000,,
1602
1603 Table: Directional Measures
1604 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1605 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1606 ,,x Dependent,.640,.085,4.875,.000
1607 ,,y Dependent,.174,.050,3.248,.001
1608 ,Goodman and Kruskal tau,x Dependent,.534,,,
1609 ,,y Dependent,.167,,,
1610 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1611 ,,x Dependent,-.060,.059,-1.022,.307
1612 ,,y Dependent,-.096,.094,-1.022,.307
1613
1614 Table: Summary
1615 ,Cases,,,,,
1616 ,Valid,,Missing,,Total,
1617 ,N,Percent,N,Percent,N,Percent
1618 x × y,212.000,100.0%,.000,.0%,212.000,100.0%
1619
1620 Table: Symmetric Measures
1621 ,,Value,Asymp. Std. Error,Approx. T
1622 Nominal by Nominal,Phi,.432,,
1623 ,Cramer's V,.249,,
1624 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338
1625 N of Valid Cases,,212.000,,
1626
1627 Table: Directional Measures
1628 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1629 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1630 ,,x Dependent,.027,.087,.302,.763
1631 ,,y Dependent,.165,.065,2.349,.019
1632 ,Goodman and Kruskal tau,x Dependent,.051,,,
1633 ,,y Dependent,.068,,,
1634 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1635 ,,x Dependent,.202,.060,3.338,.001
1636 ,,y Dependent,.217,.064,3.338,.001
1637 ])
1638 AT_CLEANUP
1639
1640 AT_SETUP([CROSSTABS Cohens Kappa])
1641
1642 dnl Example from Wood J. M. 
1643 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1644 dnl WebPsychEmpiricist. Oct 3 2007
1645 AT_DATA([kappa.sps], [dnl
1646 SET FORMAT=F8.3.
1647
1648 data list notable list /p1 * p2 * w *.
1649 begin data.
1650 0 0 18
1651 1 0 1
1652 0 1 1
1653 end data.
1654
1655 weight by w.
1656
1657 crosstabs /table = p1 by p2
1658         statistics = kappa
1659         .
1660 ])
1661
1662 AT_CHECK([pspp -o pspp.csv -o pspp.txt kappa.sps])
1663 AT_CHECK([cat pspp.csv], [0], [dnl
1664 Table: Summary
1665 ,Cases,,,,,
1666 ,Valid,,Missing,,Total,
1667 ,N,Percent,N,Percent,N,Percent
1668 p1 × p2,20.000,100.0%,.000,.0%,20.000,100.0%
1669
1670 Table: p1 × p2
1671 ,,,p2,,Total
1672 ,,,.000,1.000,
1673 p1,.000,Count,18.000,1.000,19.000
1674 ,1.000,,1.000,.000,1.000
1675 Total,,,19.000,1.000,20.000
1676
1677 Table: Symmetric Measures
1678 ,,Value,Asymp. Std. Error,Approx. T
1679 Measure of Agreement,Kappa,-.053,.037,-.235
1680 N of Valid Cases,,20.000,,
1681 ])
1682
1683 AT_CLEANUP
1684
1685
1686 AT_SETUP([CROSSTABS many statistics])
1687 AT_DATA([crosstabs.sps], [dnl
1688 SET FORMAT=F8.4.
1689
1690 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1691 DATA LIST LIST NOTABLE/x y w.
1692 WEIGHT BY w.
1693 BEGIN DATA.
1694 1 1 25
1695 1 2 25
1696 1 3 12
1697 2 2 1
1698 2 3 3
1699 END DATA.
1700 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1701 ])
1702 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
1703 AT_CHECK([cat pspp.csv], [0], [dnl
1704 Table: Summary
1705 ,Cases,,,,,
1706 ,Valid,,Missing,,Total,
1707 ,N,Percent,N,Percent,N,Percent
1708 x × y,66.0000,100.0%,.0000,.0%,66.0000,100.0%
1709
1710 Table: Chi-Square Tests
1711 ,Value,df,Asymptotic Sig. (2-tailed)
1712 Pearson Chi-Square,6.9562,2.0000,.031
1713 Likelihood Ratio,6.6901,2.0000,.035
1714 Linear-by-Linear Association,5.8450,1.0000,.016
1715 N of Valid Cases,66.0000,,
1716
1717 Table: Symmetric Measures
1718 ,,Value,Asymp. Std. Error,Approx. T
1719 Nominal by Nominal,Phi,.3246,,
1720 ,Cramer's V,.3246,,
1721 ,Contingency Coefficient,.3088,,
1722 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920
1723 ,Kendall's tau-c,.1497,.0751,1.9920
1724 ,Gamma,.8717,.1250,1.9920
1725 ,Spearman Correlation,.2908,.0906,2.4311
1726 Interval by Interval,Pearson's R,.2999,.0973,2.5147
1727 N of Valid Cases,,66.0000,,
1728
1729 Table: Directional Measures
1730 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1731 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1732 ,,x Dependent,.0000,.0000,NaN,NaN
1733 ,,y Dependent,.0500,.1791,.2723,.785
1734 ,Goodman and Kruskal tau,x Dependent,.1054,,,
1735 ,,y Dependent,.0434,,,
1736 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,
1737 ,,x Dependent,.2217,.1062,1.5373,
1738 ,,y Dependent,.0473,.0306,1.5373,
1739 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1740 ,,x Dependent,.1152,.0572,1.9920,.046
1741 ,,y Dependent,.6573,.1417,1.9920,.046
1742 ])
1743 AT_CLEANUP
1744
1745 AT_SETUP([CROSSTABS uncertainy coefficient])
1746 AT_DATA([uc.sps], [dnl
1747 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1748 SET FORMAT=F8.3.
1749
1750 DATA LIST LIST NOTABLE/x y w.
1751 WEIGHT BY w.
1752 BEGIN DATA.
1753 1 1 416
1754 1 2 121
1755 2 1 335
1756 2 2 2
1757 3 1 112
1758 3 2 1
1759 END DATA.
1760 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1761 ])
1762 AT_CHECK([pspp -o pspp.csv -o pspp.txt uc.sps])
1763 AT_CHECK([cat pspp.csv], [0], [dnl
1764 Table: Summary
1765 ,Cases,,,,,
1766 ,Valid,,Missing,,Total,
1767 ,N,Percent,N,Percent,N,Percent
1768 x × y,987.000,100.0%,.000,.0%,987.000,100.0%
1769
1770 Table: Directional Measures
1771 ,,,Value,Asymp. Std. Error,Approx. T,Approx Sig.
1772 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1773 ,,x Dependent,.000,.000,NaN,NaN
1774 ,,y Dependent,.000,.000,NaN,NaN
1775 ,Goodman and Kruskal tau,x Dependent,.076,,,
1776 ,,y Dependent,.108,,,
1777 ,Uncertainty Coefficient,Symmetric,.105,.012,,
1778 ,,x Dependent,.073,.009,7.890,
1779 ,,y Dependent,.184,.019,7.890,
1780 ])
1781 AT_CLEANUP
1782
1783 AT_SETUP([CROSSTABS estimated risk])
1784 dnl Example data and expected output from
1785 dnl http://www.psychology.nottingham.ac.uk/staff/ddc/c8cxpa/further/Project_resources/SPSSCrosstabW.pdf
1786 AT_DATA([risk.sps], [dnl
1787 DATA LIST LIST /factor disease count (F8.0).
1788 WEIGHT BY count.
1789 VALUE LABELS /factor 0 'Placebo' 1 'Aspirin'
1790              /disease 1 'No' 0 'Yes'.
1791 BEGIN DATA.
1792 0 1 80
1793 0 0 20
1794 1 1 135
1795 1 0 15
1796 END DATA.
1797 CROSSTABS factor BY disease/STATISTICS=RISK CHISQ.
1798 ])
1799 AT_CHECK([pspp -o pspp.csv -o pspp.txt risk.sps])
1800 AT_CHECK([cat pspp.csv], [0], [dnl
1801 Table: Reading free-form data from INLINE.
1802 Variable,Format
1803 factor,F8.0
1804 disease,F8.0
1805 count,F8.0
1806
1807 Table: Summary
1808 ,Cases,,,,,
1809 ,Valid,,Missing,,Total,
1810 ,N,Percent,N,Percent,N,Percent
1811 factor × disease,250,100.0%,0,.0%,250,100.0%
1812
1813 Table: factor × disease
1814 ,,,disease,,Total
1815 ,,,Yes,No,
1816 factor,Placebo,Count,20,80,100
1817 ,Aspirin,,15,135,150
1818 Total,,,35,215,250
1819
1820 Table: Chi-Square Tests
1821 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
1822 Pearson Chi-Square,4.98,1,.026,,
1823 Likelihood Ratio,4.88,1,.027,,
1824 Fisher's Exact Test,,,,.039,.021
1825 Continuity Correction,4.19,1,.041,,
1826 Linear-by-Linear Association,4.96,1,.026,,
1827 N of Valid Cases,250,,,,
1828
1829 Table: Risk Estimate
1830 ,Value,95% Confidence Interval,
1831 ,,Lower,Upper
1832 Odds Ratio for factor (Placebo / Aspirin),2.25,2.25,2.25
1833 For cohort disease = Yes,1.08,1.08,1.08
1834 For cohort disease = No,.99,.99,.99
1835 N of Valid Cases,250.00,,
1836 ])
1837 AT_CLEANUP
1838
1839 AT_SETUP([CROSSTABS barchart])
1840 AT_DATA([bc.sps], [dnl
1841 SET FORMAT=F8.3.
1842
1843 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1844 BEGIN DATA.
1845 This  1  0 416
1846 That  2  0 121
1847 Other 2  0 335
1848 This  2  0 231
1849 That  3  0 112
1850 Other 4  0 130
1851 This  1  1 160
1852 That  2  1 211
1853 Other 2  1 352
1854 This  2  1 212
1855 That  3  1 121
1856 Other 4  1 101
1857 END DATA.
1858
1859 WEIGHT BY w.
1860
1861 CROSSTABS 
1862           /table x BY y BY z
1863           /table x BY y
1864           /barchart.
1865 ])
1866
1867 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1868
1869 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1870 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1871
1872 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])
1873
1874 AT_CLEANUP