f25fe04aec0a38f3b2c42c52deea94bbc89be3ef
[pspp] / tests / language / stats / means.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017, 2019 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([MEANS procedure])
18
19 AT_SETUP([MEANS simple])
20 AT_KEYWORDS([categorical categoricals])
21
22 AT_DATA([means-simple.sps], [dnl
23 data list notable list /hand * score * w *.
24 begin data.
25 1 17 4
26 1 16 5
27 2 21 1
28 2 22 1
29 2 20 8
30 end data.
31
32 weight by w.
33
34 means tables = score by hand
35  /cells = mean count.
36 ])
37
38 AT_CHECK([pspp -O format=csv means-simple.sps], [0], [dnl
39 Table: Case Processing Summary
40 ,Cases,,,,,
41 ,Included,,Excluded,,Total,
42 ,N,Percent,N,Percent,N,Percent
43 score * hand,19,100.0%,0,.0%,19,100.0%
44
45 Table: Report
46 hand,Mean,N
47 1.00,16.44,9
48 2.00,20.30,10
49 Total,18.47,19
50 ])
51
52 AT_CLEANUP
53
54 AT_SETUP([MEANS very simple])
55 AT_KEYWORDS([categorical categoricals])
56
57 AT_DATA([very-simple.sps], [dnl
58 data list notable list /score *.
59 begin data.
60 17
61 17
62 17
63 16
64 17
65 16
66 16
67 16
68 16
69 21
70 22
71 20
72 20
73 20
74 20
75 20
76 20
77 20
78 20
79 end data.
80
81 means tables = score
82  /cells = mean count.
83 ])
84
85 AT_CHECK([pspp -O format=csv very-simple.sps], [0], [dnl
86 Table: Case Processing Summary
87 ,Cases,,,,,
88 ,Included,,Excluded,,Total,
89 ,N,Percent,N,Percent,N,Percent
90 score,19,100.0%,0,.0%,19,100.0%
91
92 Table: Report
93 Mean,N
94 18.47,19
95 ])
96
97 AT_CLEANUP
98
99
100 AT_SETUP([MEANS empty factor spec])
101 AT_KEYWORDS([categorical categoricals])
102
103 AT_DATA([means-bad.sps], [dnl
104 data list list /outcome *.
105 begin data.
106 1
107 2
108 3
109 end data.
110
111 MEANS TABLES =  outcome
112         BY.
113 ])
114
115 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
116
117 AT_CLEANUP
118
119
120
121 AT_SETUP([MEANS parser bug])
122 AT_KEYWORDS([categorical categoricals])
123
124 dnl This bug caused an infinite loop
125 AT_DATA([means-bad.sps], [dnl
126 DATA LIST notable LIST /a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 fylo *.
127 begin data.
128 1 2 3 4 5 6 7 8 9 0 11
129 end data.
130
131 MEANS TABLES = a1 a2 a3 a4 a5 a6 a7 a8 a9 a10a BY fylo.
132 ])
133
134 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
135
136 AT_CLEANUP
137
138
139 dnl This example is based upon info from https://libguides.library.kent.edu/SPSS/CompareMeans
140 AT_SETUP([MEANS default missing behaviour])
141 AT_KEYWORDS([categorical categoricals])
142
143 AT_DATA([means-missing.sps], [dnl
144 data list notable list /w * score * a * b *.
145 begin data
146      12      . 0 0
147      13      . 0 1
148      11      . 1 0
149       7      . 1 1
150       5      1 0 .
151      91      1 0 0
152     130      1 0 1
153       4      1 1 .
154      90      1 1 0
155      72      1 1 1
156 end data.
157
158 weight by w.
159
160 MEANS tables=score
161         /cells = count.
162
163 MEANS tables=score by a
164         /cells = count.
165
166 MEANS tables=score by a by b
167       /cells = count.
168 ])
169
170 AT_CHECK([pspp -O format=csv means-missing.sps], [0], [dnl
171 Table: Case Processing Summary
172 ,Cases,,,,,
173 ,Included,,Excluded,,Total,
174 ,N,Percent,N,Percent,N,Percent
175 score,392,90.1%,43,9.9%,435,100.0%
176
177 Table: Report
178 N
179 392
180
181 Table: Case Processing Summary
182 ,Cases,,,,,
183 ,Included,,Excluded,,Total,
184 ,N,Percent,N,Percent,N,Percent
185 score * a,392,90.1%,43,9.9%,435,100.0%
186
187 Table: Report
188 a,N
189 .00,226
190 1.00,166
191 Total,392
192
193 Table: Case Processing Summary
194 ,Cases,,,,,
195 ,Included,,Excluded,,Total,
196 ,N,Percent,N,Percent,N,Percent
197 score * a * b,383,88.0%,52,12.0%,435,100.0%
198
199 Table: Report
200 a,b,N
201 .00,.00,91
202 ,1.00,130
203 ,Total,221
204 1.00,.00,90
205 ,1.00,72
206 ,Total,162
207 Total,.00,181
208 ,1.00,202
209 ,Total,383
210 ])
211
212 AT_CLEANUP
213
214
215 dnl This example from https://www.spss-tutorials.com/spss-means-command/
216 AT_SETUP([MEANS two way])
217 AT_KEYWORDS([categorical categoricals])
218
219 AT_DATA([means-freelancer.sps], [dnl
220 data list notable list /income_2010 * gender  sector_2010.
221 begin data
222 6072.40 0 5
223 12706.65 1 4
224 14912.82 0 2
225 16338.36 1 5
226 22606.99 0 .
227 23544.95 1 1
228 24985.21 0 2
229 26586.48 0 1
230 29076.24 1 3
231 31010.18 0 2
232 33190.63 1 1
233 35570.67 1 4
234 36202.60 1 4
235 36205.85 1 2
236 36262.56 1 .
237 38283.56 0 1
238 38569.91 1 5
239 39057.56 1 4
240 39594.68 1 5
241 42087.38 0 1
242 42370.92 0 2
243 42931.32 1 2
244 45907.58 0 4
245 45911.32 1 .
246 47227.09 1 3
247 50440.71 1 5
248 57440.17 1 3
249 58918.86 0 5
250 59430.07 1 2
251 61135.95 0 4
252 64193.85 0 4
253 64857.02 0 3
254 65903.42 0 4
255 66592.38 1 3
256 70986.10 0 3
257 71229.94 0 4
258 74663.05 1 4
259 76676.14 1 4
260 79260.80 0 4
261 80311.71 0 4
262 end data.
263
264 means income_2010 by gender by sector_2010
265         /cells count min mean stddev.
266 ])
267
268 AT_CHECK([pspp -O format=csv means-freelancer.sps], [0], [dnl
269 Table: Case Processing Summary
270 ,Cases,,,,,
271 ,Included,,Excluded,,Total,
272 ,N,Percent,N,Percent,N,Percent
273 income_2010 * gender * sector_2010,37,92.5%,3,7.5%,40,100.0%
274
275 Table: Report
276 gender,sector_2010,N,Minimum,Mean,Std. Deviation
277 .00,1.00,3,26586.48,35652.47,8078.46
278 ,2.00,4,14912.82,28319.78,11482.43
279 ,3.00,2,64857.02,67921.56,4333.91
280 ,4.00,7,45907.58,66849.04,11787.11
281 ,5.00,2,6072.40,32495.63,37368.09
282 ,Total,18,6072.40,49389.68,22371.48
283 1.00,1.00,2,23544.95,28367.79,6820.53
284 ,2.00,3,36205.85,46189.08,11949.93
285 ,3.00,4,29076.24,50083.97,16084.44
286 ,4.00,6,12706.65,45812.78,24995.16
287 ,5.00,4,16338.36,36235.92,14311.04
288 ,Total,19,12706.65,42918.90,17851.64
289 Total,1.00,5,23544.95,32738.60,7757.62
290 ,2.00,7,14912.82,35978.05,14309.27
291 ,3.00,6,29076.24,56029.83,15615.06
292 ,4.00,13,12706.65,57139.99,21187.85
293 ,5.00,6,6072.40,34989.15,20146.69
294 ,Total,37,6072.40,46066.84,20160.12
295 ])
296
297 AT_CLEANUP
298
299
300 dnl Check that rows are suppressed and that things generally work ok
301 dnl when there are a 2 way instance contains an unbalanced set of
302 dnl categorical values.
303 AT_SETUP([MEANS unbalanced])
304 AT_KEYWORDS([categorical categoricals])
305
306 AT_DATA([means-unbalanced.sps], [dnl
307 data list notable list /b c x *.
308 begin data.
309 4 1 123
310 3 1 123
311 5 0 246
312 4 0 246
313 3 0 246
314 end data.
315
316 * The data above lack a 5 1 case.
317
318 means
319         table=x by b by c
320         /cells = mean count
321         .
322 ])
323
324 AT_CHECK([pspp -O format=csv means-unbalanced.sps], [0], [dnl
325 Table: Case Processing Summary
326 ,Cases,,,,,
327 ,Included,,Excluded,,Total,
328 ,N,Percent,N,Percent,N,Percent
329 x * b * c,5,100.0%,0,.0%,5,100.0%
330
331 Table: Report
332 b,c,Mean,N
333 3.00,.00,246.00,1
334 ,1.00,123.00,1
335 ,Total,184.50,2
336 4.00,.00,246.00,1
337 ,1.00,123.00,1
338 ,Total,184.50,2
339 5.00,.00,246.00,1
340 ,Total,246.00,1
341 Total,.00,246.00,3
342 ,1.00,123.00,2
343 ,Total,196.80,5
344 ])
345
346 AT_CLEANUP
347
348 dnl This example kindly provided by Dana Williams
349 AT_SETUP([MEANS three way])
350 AT_KEYWORDS([categorical categoricals])
351
352 AT_DATA([means-threeway.sps], [dnl
353 data list notable list /score a b c.
354 begin data.
355 3  0 0 0
356 4  0 0 1
357 41 0 0 2
358 5  0 1 0
359 6  0 1 1
360 7  1 0 0
361 8  1 0 1
362 9  1 1 0
363 10 1 1 1
364 end data.
365
366 means score by a by b by c.
367 ])
368
369 AT_CHECK([pspp -O format=csv means-threeway.sps], [0], [dnl
370 Table: Case Processing Summary
371 ,Cases,,,,,
372 ,Included,,Excluded,,Total,
373 ,N,Percent,N,Percent,N,Percent
374 score * a * b * c,9,100.0%,0,.0%,9,100.0%
375
376 Table: Report
377 a,b,c,Mean,N,Std. Deviation
378 .00,.00,.00,3.00,1,NaN
379 ,,1.00,4.00,1,NaN
380 ,,2.00,41.00,1,NaN
381 ,,Total,16.00,3,21.66
382 ,1.00,.00,5.00,1,NaN
383 ,,1.00,6.00,1,NaN
384 ,,Total,5.50,2,.71
385 ,Total,.00,4.00,2,1.41
386 ,,1.00,5.00,2,1.41
387 ,,2.00,41.00,1,NaN
388 ,,Total,11.80,5,16.36
389 1.00,.00,.00,7.00,1,NaN
390 ,,1.00,8.00,1,NaN
391 ,,Total,7.50,2,.71
392 ,1.00,.00,9.00,1,NaN
393 ,,1.00,10.00,1,NaN
394 ,,Total,9.50,2,.71
395 ,Total,.00,8.00,2,1.41
396 ,,1.00,9.00,2,1.41
397 ,,Total,8.50,4,1.29
398 Total,.00,.00,5.00,2,2.83
399 ,,1.00,6.00,2,2.83
400 ,,2.00,41.00,1,NaN
401 ,,Total,12.60,5,16.01
402 ,1.00,.00,7.00,2,2.83
403 ,,1.00,8.00,2,2.83
404 ,,Total,7.50,4,2.38
405 ,Total,.00,6.00,4,2.58
406 ,,1.00,7.00,4,2.58
407 ,,2.00,41.00,1,NaN
408 ,,Total,10.33,9,11.73
409 ])
410
411 AT_CLEANUP
412
413 dnl The above example again, but with string variables for
414 dnl the control vars.
415 AT_SETUP([MEANS three way string])
416 AT_KEYWORDS([categorical categoricals])
417
418 AT_DATA([means-threeway-string.sps], [dnl
419 data list notable list /score (f22.2) a (a24) b (a16) c (a8).
420 begin data.
421 3  fooberrycrumblexzaQ  fosilationwereqd  zero
422 4  fooberrycrumblexzaQ  fosilationwereqd  one
423 41 fooberrycrumblexzaQ  fosilationwereqd  two
424 5  fooberrycrumblexzaQ  onlyonekonboys    zero
425 6  fooberrycrumblexzaQ  onlyonekonboys    one
426 7  wontledingbatsXASDF  fosilationwereqd  zero
427 8  wontledingbatsXASDF  fosilationwereqd  one
428 9  wontledingbatsXASDF  onlyonekonboys    zero
429 10 wontledingbatsXASDF  onlyonekonboys    one
430 end data.
431
432 means score by a by b by c.
433 ])
434
435 AT_CHECK([pspp -O format=csv means-threeway-string.sps], [0], [dnl
436 Table: Case Processing Summary
437 ,Cases,,,,,
438 ,Included,,Excluded,,Total,
439 ,N,Percent,N,Percent,N,Percent
440 score * a * b * c,9,100.0%,0,.0%,9,100.0%
441
442 Table: Report
443 a,b,c,Mean,N,Std. Deviation
444 fooberrycrumblexzaQ,fosilationwereqd,one,4.00,1,NaN
445 ,,two,41.00,1,NaN
446 ,,zero,3.00,1,NaN
447 ,,Total,16.00,3,21.66
448 ,onlyonekonboys,one,6.00,1,NaN
449 ,,zero,5.00,1,NaN
450 ,,Total,5.50,2,.71
451 ,Total,one,5.00,2,1.41
452 ,,two,41.00,1,NaN
453 ,,zero,4.00,2,1.41
454 ,,Total,11.80,5,16.36
455 wontledingbatsXASDF,fosilationwereqd,one,8.00,1,NaN
456 ,,zero,7.00,1,NaN
457 ,,Total,7.50,2,.71
458 ,onlyonekonboys,one,10.00,1,NaN
459 ,,zero,9.00,1,NaN
460 ,,Total,9.50,2,.71
461 ,Total,one,9.00,2,1.41
462 ,,zero,8.00,2,1.41
463 ,,Total,8.50,4,1.29
464 Total,fosilationwereqd,one,6.00,2,2.83
465 ,,two,41.00,1,NaN
466 ,,zero,5.00,2,2.83
467 ,,Total,12.60,5,16.01
468 ,onlyonekonboys,one,8.00,2,2.83
469 ,,zero,7.00,2,2.83
470 ,,Total,7.50,4,2.38
471 ,Total,one,7.00,4,2.58
472 ,,two,41.00,1,NaN
473 ,,zero,6.00,4,2.58
474 ,,Total,10.33,9,11.73
475 ])
476
477 AT_CLEANUP
478
479
480
481 dnl An example with multiple tables
482 AT_SETUP([MEANS multiple tables])
483 AT_KEYWORDS([categorical categoricals])
484
485 AT_DATA([means-multi-table.sps], [dnl
486 data list notable list /a * b * c * x * y *.
487 begin data.
488 6 3 0 123 456
489 6 3 1 123 456
490 6 4 0 123 456
491 6 4 1 123 456
492 6 5 0 123 456
493 6 5 1 123 456
494 7 3 0 123 456
495 7 3 1 123 456
496 7 4 0 123 456
497 7 4 1 123 456
498 7 5 0 123 456
499 7 5 1 123 456
500 8 3 0 123 456
501 8 3 1 123 456
502 8 4 0 123 456
503 8 4 1 123 456
504 8 5 0 123 456
505 8 5 1 123 456
506 9 3 0 123 456
507 9 3 1 123 456
508 9 4 0 123 456
509 9 4 1 123 456
510 9 5 0 123 456
511 9 5 1 123 456
512 end data.
513
514
515 means table = x by b by c
516         /x by b
517         /y by a by b
518   cells = min count  .
519 ])
520
521 AT_CHECK([pspp -O format=csv means-multi-table.sps], [0], [dnl
522 Table: Case Processing Summary
523 ,Cases,,,,,
524 ,Included,,Excluded,,Total,
525 ,N,Percent,N,Percent,N,Percent
526 x * b * c,24,100.0%,0,.0%,24,100.0%
527
528 Table: Report
529 b,c,Minimum,N
530 3.00,.00,123.00,4
531 ,1.00,123.00,4
532 ,Total,123.00,8
533 4.00,.00,123.00,4
534 ,1.00,123.00,4
535 ,Total,123.00,8
536 5.00,.00,123.00,4
537 ,1.00,123.00,4
538 ,Total,123.00,8
539 Total,.00,123.00,12
540 ,1.00,123.00,12
541 ,Total,123.00,24
542
543 Table: Case Processing Summary
544 ,Cases,,,,,
545 ,Included,,Excluded,,Total,
546 ,N,Percent,N,Percent,N,Percent
547 x * b,24,100.0%,0,.0%,24,100.0%
548
549 Table: Report
550 b,Minimum,N
551 3.00,123.00,8
552 4.00,123.00,8
553 5.00,123.00,8
554 Total,123.00,24
555
556 Table: Case Processing Summary
557 ,Cases,,,,,
558 ,Included,,Excluded,,Total,
559 ,N,Percent,N,Percent,N,Percent
560 y * a * b,24,100.0%,0,.0%,24,100.0%
561
562 Table: Report
563 a,b,Minimum,N
564 6.00,3.00,456.00,2
565 ,4.00,456.00,2
566 ,5.00,456.00,2
567 ,Total,456.00,6
568 7.00,3.00,456.00,2
569 ,4.00,456.00,2
570 ,5.00,456.00,2
571 ,Total,456.00,6
572 8.00,3.00,456.00,2
573 ,4.00,456.00,2
574 ,5.00,456.00,2
575 ,Total,456.00,6
576 9.00,3.00,456.00,2
577 ,4.00,456.00,2
578 ,5.00,456.00,2
579 ,Total,456.00,6
580 Total,3.00,456.00,8
581 ,4.00,456.00,8
582 ,5.00,456.00,8
583 ,Total,456.00,24
584 ])
585
586 AT_CLEANUP
587
588
589
590 dnl An example with more than one dependent variable.
591 dnl This case uses a somewhat different table layout.
592 AT_SETUP([MEANS multi variable])
593 AT_KEYWORDS([categorical categoricals])
594
595 AT_DATA([means-multi-variable.sps], [dnl
596 data list notable list /b c x y.
597 begin data.
598 5 1 123 55
599 5 1 123 55
600 5 1 123 55
601 5 1 123 55
602 4 1 456 44
603 4 1 456 44
604 4 1 456 44
605 4 1 456 44
606 3 1 789 55
607 3 1 789 55
608 3 1 789 55
609 3 1 789 55
610 5 0 246 99
611 5 0 246 99
612 5 0 246 99
613 5 0 246 .
614 4 0 987 99
615 4 0 987 99
616 4 0 987 99
617 4 0 987 99
618 3 0 654 11
619 3 0 654 11
620 3 0 654 11
621 3 0 654 11
622 end data.
623
624 means
625         table = x y by b by c
626         .
627 ])
628
629 AT_CHECK([pspp -O format=csv means-multi-variable.sps], [0], [dnl
630 Table: Case Processing Summary
631 ,Cases,,,,,
632 ,Included,,Excluded,,Total,
633 ,N,Percent,N,Percent,N,Percent
634 x * b * c,24,100.0%,0,.0%,24,100.0%
635 y * b * c,23,95.8%,1,4.2%,24,100.0%
636
637 Table: x * y * b * c
638 b,c,,x,y
639 3.00,.00,Mean,654.00,11.00
640 ,,N,4,4
641 ,,Std. Deviation,.00,.00
642 ,1.00,Mean,789.00,55.00
643 ,,N,4,4
644 ,,Std. Deviation,.00,.00
645 ,Total,Mean,721.50,33.00
646 ,,N,8,8
647 ,,Std. Deviation,72.16,23.52
648 4.00,.00,Mean,987.00,99.00
649 ,,N,4,4
650 ,,Std. Deviation,.00,.00
651 ,1.00,Mean,456.00,44.00
652 ,,N,4,4
653 ,,Std. Deviation,.00,.00
654 ,Total,Mean,721.50,71.50
655 ,,N,8,8
656 ,,Std. Deviation,283.83,29.40
657 5.00,.00,Mean,246.00,99.00
658 ,,N,4,3
659 ,,Std. Deviation,.00,.00
660 ,1.00,Mean,123.00,55.00
661 ,,N,4,4
662 ,,Std. Deviation,.00,.00
663 ,Total,Mean,184.50,73.86
664 ,,N,8,7
665 ,,Std. Deviation,65.75,23.52
666 Total,.00,Mean,629.00,67.00
667 ,,N,12,11
668 ,,Std. Deviation,316.50,44.40
669 ,1.00,Mean,456.00,51.33
670 ,,N,12,12
671 ,,Std. Deviation,283.98,5.42
672 ,Total,Mean,542.50,58.83
673 ,,N,24,23
674 ,,Std. Deviation,307.06,31.22
675 ])
676
677
678 AT_CLEANUP
679
680
681 dnl This example is based upon one kindly provided by Dana Williams
682 dnl It exercises the most complex case where there are multiple
683 dnl dependent variables AND multiple control variables in each layer.
684 AT_SETUP([MEANS multi combination])
685 AT_KEYWORDS([categorical categoricals])
686
687 AT_DATA([means-multi-combination.sps], [dnl
688 data list notable list /one (F22.5) two (F22.5) three four five six.
689 begin data
690 1 1 1 1 1 1
691 2 1 1 1 1 1
692 1 2 1 1 1 1
693 2 2 1 1 1 1
694 1 1 2 1 1 1
695 2 1 2 1 1 1
696 1 2 2 1 1 1
697 2 2 2 1 1 1
698 1 1 1 2 1 1
699 2 1 1 2 1 1
700 1 2 1 2 1 1
701 2 2 1 2 1 1
702 1 1 2 2 1 1
703 2 1 2 2 1 1
704 1 2 2 2 1 1
705 2 2 2 2 1 1
706 1 1 1 1 2 1
707 2 1 1 1 2 1
708 1 2 1 1 2 1
709 2 2 1 1 2 1
710 1 1 2 1 2 1
711 2 1 2 1 2 1
712 1 2 2 1 2 1
713 2 2 2 1 2 1
714 1 1 1 2 2 1
715 2 1 1 2 2 1
716 1 2 1 2 2 1
717 2 2 1 2 2 1
718 1 1 2 2 2 1
719 2 1 2 2 2 1
720 1 2 2 2 2 1
721 2 2 2 2 2 1
722 1 1 1 1 1 2
723 2 1 1 1 1 2
724 1 2 1 1 1 2
725 2 2 1 1 1 2
726 1 1 2 1 1 2
727 2 1 2 1 1 2
728 1 2 2 1 1 2
729 2 2 2 1 1 2
730 1 1 1 2 1 2
731 2 1 1 2 1 2
732 1 2 1 2 1 2
733 2 2 1 2 1 2
734 1 1 2 2 1 2
735 2 1 2 2 1 2
736 1 2 2 2 1 2
737 2 2 2 2 1 2
738 1 1 1 1 2 2
739 2 1 1 1 2 2
740 1 2 1 1 2 2
741 2 2 1 1 2 2
742 1 1 2 1 2 2
743 2 1 2 1 2 2
744 1 2 2 1 2 2
745 2 2 2 1 2 2
746 1 1 1 2 2 2
747 2 1 1 2 2 2
748 1 2 1 2 2 2
749 2 2 1 2 2 2
750 1 1 2 2 2 2
751 2 1 2 2 2 2
752 1 2 2 2 2 2
753 2 2 2 2 2 2
754 end data.
755
756 recode six  (2 = 62) (1 = 61).
757 recode five (2 = 52) (1 = 51).
758 recode four (2 = 42) (1 = 41).
759 recode three (2 = 32) (1 = 31).
760
761 means tables = one two BY three four BY five six.
762 ])
763
764 AT_CHECK([pspp -O format=csv means-multi-combination.sps], [0], [dnl
765 Table: Case Processing Summary
766 ,Cases,,,,,
767 ,Included,,Excluded,,Total,
768 ,N,Percent,N,Percent,N,Percent
769 one * three * five,64,100.0%,0,.0%,64,100.0%
770 two * three * five,64,100.0%,0,.0%,64,100.0%
771 one * three * six,64,100.0%,0,.0%,64,100.0%
772 two * three * six,64,100.0%,0,.0%,64,100.0%
773 one * four * five,64,100.0%,0,.0%,64,100.0%
774 two * four * five,64,100.0%,0,.0%,64,100.0%
775 one * four * six,64,100.0%,0,.0%,64,100.0%
776 two * four * six,64,100.0%,0,.0%,64,100.0%
777
778 Table: one * two * three * five
779 three,five,,one,two
780 31.00,51.00,Mean,1.50000,1.50000
781 ,,N,16,16
782 ,,Std. Deviation,.51640,.51640
783 ,52.00,Mean,1.50000,1.50000
784 ,,N,16,16
785 ,,Std. Deviation,.51640,.51640
786 ,Total,Mean,1.50000,1.50000
787 ,,N,32,32
788 ,,Std. Deviation,.50800,.50800
789 32.00,51.00,Mean,1.50000,1.50000
790 ,,N,16,16
791 ,,Std. Deviation,.51640,.51640
792 ,52.00,Mean,1.50000,1.50000
793 ,,N,16,16
794 ,,Std. Deviation,.51640,.51640
795 ,Total,Mean,1.50000,1.50000
796 ,,N,32,32
797 ,,Std. Deviation,.50800,.50800
798 Total,51.00,Mean,1.50000,1.50000
799 ,,N,32,32
800 ,,Std. Deviation,.50800,.50800
801 ,52.00,Mean,1.50000,1.50000
802 ,,N,32,32
803 ,,Std. Deviation,.50800,.50800
804 ,Total,Mean,1.50000,1.50000
805 ,,N,64,64
806 ,,Std. Deviation,.50395,.50395
807
808 Table: one * two * three * six
809 three,six,,one,two
810 31.00,61.00,Mean,1.50000,1.50000
811 ,,N,16,16
812 ,,Std. Deviation,.51640,.51640
813 ,62.00,Mean,1.50000,1.50000
814 ,,N,16,16
815 ,,Std. Deviation,.51640,.51640
816 ,Total,Mean,1.50000,1.50000
817 ,,N,32,32
818 ,,Std. Deviation,.50800,.50800
819 32.00,61.00,Mean,1.50000,1.50000
820 ,,N,16,16
821 ,,Std. Deviation,.51640,.51640
822 ,62.00,Mean,1.50000,1.50000
823 ,,N,16,16
824 ,,Std. Deviation,.51640,.51640
825 ,Total,Mean,1.50000,1.50000
826 ,,N,32,32
827 ,,Std. Deviation,.50800,.50800
828 Total,61.00,Mean,1.50000,1.50000
829 ,,N,32,32
830 ,,Std. Deviation,.50800,.50800
831 ,62.00,Mean,1.50000,1.50000
832 ,,N,32,32
833 ,,Std. Deviation,.50800,.50800
834 ,Total,Mean,1.50000,1.50000
835 ,,N,64,64
836 ,,Std. Deviation,.50395,.50395
837
838 Table: one * two * four * five
839 four,five,,one,two
840 41.00,51.00,Mean,1.50000,1.50000
841 ,,N,16,16
842 ,,Std. Deviation,.51640,.51640
843 ,52.00,Mean,1.50000,1.50000
844 ,,N,16,16
845 ,,Std. Deviation,.51640,.51640
846 ,Total,Mean,1.50000,1.50000
847 ,,N,32,32
848 ,,Std. Deviation,.50800,.50800
849 42.00,51.00,Mean,1.50000,1.50000
850 ,,N,16,16
851 ,,Std. Deviation,.51640,.51640
852 ,52.00,Mean,1.50000,1.50000
853 ,,N,16,16
854 ,,Std. Deviation,.51640,.51640
855 ,Total,Mean,1.50000,1.50000
856 ,,N,32,32
857 ,,Std. Deviation,.50800,.50800
858 Total,51.00,Mean,1.50000,1.50000
859 ,,N,32,32
860 ,,Std. Deviation,.50800,.50800
861 ,52.00,Mean,1.50000,1.50000
862 ,,N,32,32
863 ,,Std. Deviation,.50800,.50800
864 ,Total,Mean,1.50000,1.50000
865 ,,N,64,64
866 ,,Std. Deviation,.50395,.50395
867
868 Table: one * two * four * six
869 four,six,,one,two
870 41.00,61.00,Mean,1.50000,1.50000
871 ,,N,16,16
872 ,,Std. Deviation,.51640,.51640
873 ,62.00,Mean,1.50000,1.50000
874 ,,N,16,16
875 ,,Std. Deviation,.51640,.51640
876 ,Total,Mean,1.50000,1.50000
877 ,,N,32,32
878 ,,Std. Deviation,.50800,.50800
879 42.00,61.00,Mean,1.50000,1.50000
880 ,,N,16,16
881 ,,Std. Deviation,.51640,.51640
882 ,62.00,Mean,1.50000,1.50000
883 ,,N,16,16
884 ,,Std. Deviation,.51640,.51640
885 ,Total,Mean,1.50000,1.50000
886 ,,N,32,32
887 ,,Std. Deviation,.50800,.50800
888 Total,61.00,Mean,1.50000,1.50000
889 ,,N,32,32
890 ,,Std. Deviation,.50800,.50800
891 ,62.00,Mean,1.50000,1.50000
892 ,,N,32,32
893 ,,Std. Deviation,.50800,.50800
894 ,Total,Mean,1.50000,1.50000
895 ,,N,64,64
896 ,,Std. Deviation,.50395,.50395
897 ])
898
899 AT_CLEANUP
900
901
902 dnl This example was observed to cause a crash in the
903 dnl destructor.  Found by zzuf.
904 AT_SETUP([MEANS clean up])
905 AT_KEYWORDS([categorical categoricals])
906
907 AT_DATA([means-bad.sps], [dnl
908 data list notable list /one two three four five six.
909 begin data
910 1 1 1 1 1 1
911 2 1 1 1 1 !
912 1 2 2 2 2 2
913 2 2 2 2 2 2
914 end data.
915
916 means tables = one two BY thsee four BY five six.
917 ])
918
919 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
920
921 AT_CLEANUP
922
923
924 dnl Another example which caused a crash.
925 dnl Found by zzuf.
926 AT_SETUP([MEANS control all missing])
927 AT_KEYWORDS([categorical categoricals])
928
929 AT_DATA([means-bad.sps], [dnl
930 data list notable list /a * b *  y * uu *.
931 begin data.
932 6 3 . 5
933 6 3 . 5
934 6 4 . 5
935 end data.
936
937 means table = b by a by y by uu
938   .
939 ])
940
941 AT_CHECK([pspp -O format=csv means-bad.sps], [0], [dnl
942 Table: Case Processing Summary
943 ,Cases,,,,,
944 ,Included,,Excluded,,Total,
945 ,N,Percent,N,Percent,N,Percent
946 b * a * y * uu,0,.0%,3,100.0%,3,100.0%
947
948 "warning: The table ""a * y * uu"" has no non-empty control variables.  No result for this table will be displayed."
949 ])
950
951 AT_CLEANUP
952
953
954 dnl Do some tests on the MISSING keyword.
955 AT_SETUP([MEANS missing classes])
956 AT_KEYWORDS([categorical categoricals])
957
958 AT_DATA([means-missing-classes.sps], [dnl
959 data list notable list /hand * score *.
960 begin data.
961 1 17
962 1 17
963 1 17
964 1 16
965 1 17
966 1 16
967 1 16
968 1 .
969 1 99
970 2 21
971 2 22
972 2 20
973 2 20
974 2 20
975 2 20
976 2 20
977 2 20
978 2 20
979 2 20
980 9 55
981 end data.
982
983 missing values score (99).
984 missing values hand (9).
985
986 means tables=score  by hand
987         /cells = count max
988         /missing = dependent
989         .
990
991 means tables=score  by hand
992         /cells = count max
993         /missing = include
994         .
995
996 means tables=score  by hand
997         /cells = count max
998         .
999
1000 ])
1001
1002 AT_CHECK([pspp -O format=csv means-missing-classes.sps], [0], [dnl
1003 Table: Case Processing Summary
1004 ,Cases,,,,,
1005 ,Included,,Excluded,,Total,
1006 ,N,Percent,N,Percent,N,Percent
1007 score * hand,18,90.0%,2,10.0%,20,100.0%
1008
1009 Table: Report
1010 hand,N,Maximum
1011 1.00,7,17.00
1012 2.00,10,22.00
1013 9.00,1,55.00
1014 Total,18,55.00
1015
1016 Table: Case Processing Summary
1017 ,Cases,,,,,
1018 ,Included,,Excluded,,Total,
1019 ,N,Percent,N,Percent,N,Percent
1020 score * hand,19,95.0%,1,5.0%,20,100.0%
1021
1022 Table: Report
1023 hand,N,Maximum
1024 1.00,8,99.00
1025 2.00,10,22.00
1026 9.00,1,55.00
1027 Total,19,99.00
1028
1029 Table: Case Processing Summary
1030 ,Cases,,,,,
1031 ,Included,,Excluded,,Total,
1032 ,N,Percent,N,Percent,N,Percent
1033 score * hand,17,85.0%,3,15.0%,20,100.0%
1034
1035 Table: Report
1036 hand,N,Maximum
1037 1.00,7,17.00
1038 2.00,10,22.00
1039 Total,17,22.00
1040 ])
1041
1042 AT_CLEANUP
1043
1044
1045 dnl Make sure that behaviour with SPLIT is correct.
1046 AT_SETUP([MEANS split])
1047 AT_KEYWORDS([categorical categoricals])
1048
1049 AT_DATA([means-split.sps], [dnl
1050 data list notable list /b g *.
1051 begin data
1052 2    0
1053 2    0
1054 4    0
1055 4    0
1056 11   1
1057 11   1
1058 end data.
1059
1060 split file by g.
1061
1062 means b /cells = count mean.
1063 ])
1064
1065 AT_CHECK([pspp -O format=csv means-split.sps], [0], [dnl
1066 Table: Case Processing Summary
1067 ,Cases,,,,,
1068 ,Included,,Excluded,,Total,
1069 ,N,Percent,N,Percent,N,Percent
1070 b,4,100.0%,0,.0%,4,100.0%
1071
1072 Table: Report
1073 N,Mean
1074 4,3.00
1075
1076 Table: Case Processing Summary
1077 ,Cases,,,,,
1078 ,Included,,Excluded,,Total,
1079 ,N,Percent,N,Percent,N,Percent
1080 b,2,100.0%,0,.0%,2,100.0%
1081
1082 Table: Report
1083 N,Mean
1084 2,11.00
1085 ])
1086
1087 AT_CLEANUP
1088
1089
1090 dnl Test the output with unusual dependent variable formats
1091 AT_SETUP([MEANS formats])
1092 AT_KEYWORDS([categorical categoricals])
1093
1094 AT_DATA([means-formats.sps], [dnl
1095 data list notable list /hours (TIME11.0) rate (DOLLAR8.2).
1096 begin data
1097 12:00 4.09
1098 14:01 5.23
1099 end data.
1100
1101 means hours rate
1102  /cells = mean count max range.
1103 ])
1104
1105 AT_CHECK([pspp -O format=csv means-formats.sps], [0], [dnl
1106 Table: Case Processing Summary
1107 ,Cases,,,,,
1108 ,Included,,Excluded,,Total,
1109 ,N,Percent,N,Percent,N,Percent
1110 hours,2,100.0%,0,.0%,2,100.0%
1111 rate,2,100.0%,0,.0%,2,100.0%
1112
1113 Table: hours * rate
1114 ,hours,rate
1115 Mean,13:00:30,$4.66
1116 N,2,2
1117 Maximum,14:01:00,$5.23
1118 Range,02:01:00,$1.14
1119 ])
1120
1121 AT_CLEANUP
1122
1123 AT_SETUP([MEANS syntax errors])
1124 AT_DATA([means.sps], [dnl
1125 DATA LIST LIST NOTABLE/x y z.
1126 MEANS TABLES **.
1127 MEANS x BY **.
1128 MEANS x/MISSING=**.
1129 MEANS x/CELLS=**.
1130 MEANS x/ **.
1131 ])
1132 AT_CHECK([pspp -O format=csv means.sps], [1], [dnl
1133 "means.sps:2.14-2.15: error: MEANS: Syntax error expecting `='.
1134     2 | MEANS TABLES **.
1135       |              ^~"
1136
1137 "means.sps:3.12-3.13: error: MEANS: Syntax error expecting variable name.
1138     3 | MEANS x BY **.
1139       |            ^~"
1140
1141 "means.sps:4.17-4.18: error: MEANS: Syntax error expecting INCLUDE or DEPENDENT.
1142     4 | MEANS x/MISSING=**.
1143       |                 ^~"
1144
1145 "means.sps:5.15-5.16: error: MEANS: Syntax error expecting one of the following: MEAN, COUNT, STDDEV, SEMEAN, SUM, MIN, MAX, RANGE, VARIANCE, KURT, SEKURT, SKEW, SESKEW, FIRST, LAST, HARMONIC, GEOMETRIC.
1146     5 | MEANS x/CELLS=**.
1147       |               ^~"
1148
1149 "means.sps:6.10-6.11: error: MEANS: Syntax error expecting MISSING or CELLS.
1150     6 | MEANS x/ **.
1151       |          ^~"
1152 ])
1153 AT_CLEANUP