MEANS: Prevent parser from entering infinite loop.
[pspp] / tests / language / stats / means.at
1 AT_BANNER([MEANS procedure])
2
3 AT_SETUP([MEANS simple example])
4
5 AT_DATA([means-simple.sps], [dnl
6 SET FORMAT=F12.5.
7
8 data list notable list /score * factor *.
9 BEGIN DATA.
10 22 01
11 22 01
12 29 01
13 16 01
14 24 02
15 21 02
16 22 01
17 24 01
18 19 01
19 17 01
20 22 01
21 17 02
22 23 02
23 25 02
24 20 01
25 15 01
26 18 01
27 26 01
28 23 02
29 35 02
30 20 01
31 16 01
32 19 01
33 14 01
34 14 01
35 21 01
36 END DATA.
37
38 MEANS TABLES = score BY factor.
39 ])
40
41 AT_CHECK([pspp -O format=csv means-simple.sps], [0],
42   [dnl
43 Table: Case Processing Summary
44 ,Cases,,,,,
45 ,Included,,Excluded,,Total,
46 ,N,Percent,N,Percent,N,Percent
47 score: factor,26,100%,0,0%,26,100%
48 score: ,26,100%,0,0%,26,100%
49
50 Table: Report
51 ,factor,Mean,N,Std. Deviation
52 score,1.00000,19.78947,19.00000,4.03566
53 ,2.00000,24.00000,7.00000,5.50757
54
55 Table: Report
56 ,Mean,N,Std. Deviation
57 score,20.92308,26.00000,4.75750
58 ])
59
60 AT_CLEANUP
61
62
63
64 AT_SETUP([MEANS very simple example])
65
66 AT_DATA([means-vsimple.sps], [dnl
67 SET FORMAT=F12.5.
68
69 data list notable list /score.
70 begin data.
71 1
72 1
73 2
74 2
75 end data.
76
77 means tables = score.
78 ])
79
80 AT_CHECK([pspp -O format=csv means-vsimple.sps], [0],
81   [dnl
82 Table: Case Processing Summary
83 ,Cases,,,,,
84 ,Included,,Excluded,,Total,
85 ,N,Percent,N,Percent,N,Percent
86 score: ,4,100%,0,0%,4,100%
87
88 Table: Report
89 ,Mean,N,Std. Deviation
90 score,1.50000,4.00000,.57735
91 ])
92
93 AT_CLEANUP
94
95
96
97
98 AT_SETUP([MEANS default missing])
99
100 AT_DATA([means-dmiss.sps], [dnl
101 SET FORMAT=F12.2.
102 data list notable list /a * g1 * g2 *.
103 begin data.
104 3 1 . 
105 4 1 11
106 3 1 21
107 6 2 21
108 2 2 31
109 . 2 31
110 8 2 31
111 7 2 31
112 end data.
113
114 MEANS TABLES = 
115       a BY g1 g2
116       BY g2
117       /cells = MEAN COUNT
118       .
119 ])
120
121 AT_CHECK([pspp -O format=csv means-dmiss.sps], [0],
122   [dnl
123 Table: Case Processing Summary
124 ,Cases,,,,,
125 ,Included,,Excluded,,Total,
126 ,N,Percent,N,Percent,N,Percent
127 a: g1 * g2,6,75%,2,25%,8,100%
128 a: g2,6,75%,2,25%,8,100%
129 a: ,7,87.5%,1,12.5%,8,100%
130
131 Table: Report
132 ,g1,g2,Mean,N
133 a,1.00,11.00,4.00,1.00
134 ,1.00,21.00,3.00,1.00
135 ,2.00,21.00,6.00,1.00
136 ,2.00,31.00,5.67,3.00
137
138 Table: Report
139 ,g2,Mean,N
140 a,11.00,4.00,1.00
141 ,21.00,4.50,2.00
142 ,31.00,5.67,3.00
143
144 Table: Report
145 ,Mean,N
146 a,5.00,6.00
147 ])
148
149 AT_CLEANUP
150
151
152 AT_SETUP([MEANS linear stats])
153
154 dnl Slightly more involved example to test the linear statistics
155 AT_DATA([means-linear.sps], [dnl
156 set format F12.4.
157 data list notable list /id * group * test1 *
158 begin data.
159 1 1 85
160 2 1 90
161 3 1 82
162 4 1 75
163 5 1 99
164 6 2 70
165 7 2 66
166 8 2 52
167 9 2 71
168 10 2 50
169 end data.
170
171 add value labels /group 1 "experimental group" 2 "control group".
172
173 means test1 by group
174   /cells = mean count stddev sum min max range variance kurt skew
175   .
176 ])
177
178
179 AT_CHECK([pspp -O format=csv means-linear.sps], [0],
180   [dnl
181 Table: Case Processing Summary
182 ,Cases,,,,,
183 ,Included,,Excluded,,Total,
184 ,N,Percent,N,Percent,N,Percent
185 test1: group,10,100%,0,0%,10,100%
186 test1: ,10,100%,0,0%,10,100%
187
188 Table: Report
189 ,group,Mean,N,Std. Deviation,Sum,Min,Max,Range,Variance,Kurtosis,Skewness
190 test1,experimental group,86.2000,5.0000,8.9833,431.0000,75.0000,99.0000,24.0000,80.7000,.2727,.3858
191 ,control group,61.8000,5.0000,10.0598,309.0000,50.0000,71.0000,21.0000,101.2000,-3.0437,-.4830
192
193 Table: Report
194 ,Mean,N,Std. Deviation,Sum,Min,Max,Range,Variance,Kurtosis,Skewness
195 test1,74.0000,10.0000,15.6915,740.0000,50.0000,99.0000,49.0000,246.2222,-.5759,-.1262
196 ])
197
198 AT_CLEANUP
199
200
201 AT_SETUP([MEANS standard errors])
202
203 AT_DATA([means-stderr.sps], [dnl
204 set format F12.4.
205 data list notable list /id * group * test1 *
206 begin data.
207 1 1 85
208 2 1 90
209 3 1 82
210 4 1 75
211 5 1 99
212 6 1 70
213 7 2 66
214 8 2 52
215 9 2 71
216 10 2 50
217 end data.
218
219 means test1 by group 
220         /cells = mean count semean seskew sekurt.
221 ])
222
223
224 AT_CHECK([pspp -O format=csv means-stderr.sps], [0],
225   [dnl
226 Table: Case Processing Summary
227 ,Cases,,,,,
228 ,Included,,Excluded,,Total,
229 ,N,Percent,N,Percent,N,Percent
230 test1: group,10,100%,0,0%,10,100%
231 test1: ,10,100%,0,0%,10,100%
232
233 Table: Report
234 ,group,Mean,N,S.E. Mean,S.E. Skew,S.E. Kurt
235 test1,1.0000,83.5000,6.0000,4.2485,.8452,1.7408
236 ,2.0000,59.7500,4.0000,5.1700,1.0142,2.6186
237
238 Table: Report
239 ,Mean,N,S.E. Mean,S.E. Skew,S.E. Kurt
240 test1,74.0000,10.0000,4.9621,.6870,1.3342
241 ])
242
243 AT_CLEANUP
244
245
246
247 AT_SETUP([MEANS harmonic and geometric means])
248
249 AT_DATA([means-hg.sps], [dnl
250 set format F12.4.
251 data list notable list /x * y *.
252 begin data.
253 1 3
254 2 3
255 3 3
256 4 3
257 5 3
258 end data.
259
260
261 means x y
262         /cells = mean harmonic geometric
263 .
264 ])
265
266
267 AT_CHECK([pspp -O format=csv means-hg.sps], [0],
268   [dnl
269 Table: Case Processing Summary
270 ,Cases,,,,,
271 ,Included,,Excluded,,Total,
272 ,N,Percent,N,Percent,N,Percent
273 x: ,5,100%,0,0%,5,100%
274 y: ,5,100%,0,0%,5,100%
275
276 Table: Report
277 ,Mean,Harmonic Mean,Geom. Mean
278 x,3.0000,2.1898,2.6052
279 y,3.0000,3.0000,3.0000
280 ])
281
282 AT_CLEANUP
283
284
285
286
287
288
289 AT_SETUP([MEANS all/none/default])
290
291 dnl Make sure that /CELLS = {ALL,NONE,DEFAULT} work properly
292 AT_DATA([means-stat-keywords.sps], [dnl
293 SET FORMAT=F12.2.
294 SET DECIMAL=DOT.
295
296 DATA LIST NOTABLE LIST /score *.
297 BEGIN DATA.
298 22
299 22
300 29
301 16
302 23
303 END DATA.
304
305 MEANS score /CELLS = ALL.
306 MEANS score /CELLS = DEFAULT.
307 MEANS score /CELLS = NONE.
308 ])
309
310
311 AT_CHECK([pspp -O format=csv means-stat-keywords.sps], [0],
312   [dnl
313 Table: Case Processing Summary
314 ,Cases,,,,,
315 ,Included,,Excluded,,Total,
316 ,N,Percent,N,Percent,N,Percent
317 score: ,5,100%,0,0%,5,100%
318
319 Table: Report
320 ,Mean,N,Std. Deviation,S.E. Mean,Sum,Min,Max,Range,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,First,Last,Harmonic Mean,Geom. Mean
321 score,22.40,5.00,4.62,2.06,112.00,16.00,29.00,13.00,21.30,1.85,2.00,.11,.91,22.00,23.00,21.61,22.01
322
323 Table: Case Processing Summary
324 ,Cases,,,,,
325 ,Included,,Excluded,,Total,
326 ,N,Percent,N,Percent,N,Percent
327 score: ,5,100%,0,0%,5,100%
328
329 Table: Report
330 ,Mean,N,Std. Deviation
331 score,22.40,5.00,4.62
332
333 Table: Case Processing Summary
334 ,Cases,,,,,
335 ,Included,,Excluded,,Total,
336 ,N,Percent,N,Percent,N,Percent
337 score: ,5,100%,0,0%,5,100%
338
339 Table: Report
340
341 score
342 ])
343
344 AT_CLEANUP
345
346
347
348
349 AT_SETUP([MEANS missing=table ])
350
351 AT_DATA([means-miss-table.sps], [dnl
352 data list notable list /a * b * g1.
353 begin data.
354 1 9 1  
355 2 9 1 
356 3 9 1 
357 4 9 2 
358 5 9 2 
359 6 9 2 
360 7 . 2 
361 end data.
362
363 MEANS a b BY g1
364       /a  BY g1
365       /cells =  COUNT
366       /missing = TABLE
367       .
368
369 MEANS a b BY g1
370       /a  BY g1
371       /cells =  COUNT
372       .
373 ])
374
375
376 AT_CHECK([pspp -O format=csv means-miss-table.sps], [0],
377   [dnl
378 Table: Case Processing Summary
379 ,Cases,,,,,
380 ,Included,,Excluded,,Total,
381 ,N,Percent,N,Percent,N,Percent
382 a: g1,7,100%,0,0%,7,100%
383 a: ,7,100%,0,0%,7,100%
384 b: g1,6,85.7143%,1,14.2857%,7,100%
385 b: ,6,85.7143%,1,14.2857%,7,100%
386
387 Table: Report
388 ,g1,N
389 a,1.00,3.00
390 ,2.00,3.00
391 b,1.00,3.00
392 ,2.00,3.00
393
394 Table: Report
395 ,N
396 a,6.00
397 b,6.00
398
399 Table: Case Processing Summary
400 ,Cases,,,,,
401 ,Included,,Excluded,,Total,
402 ,N,Percent,N,Percent,N,Percent
403 a: g1,7,100%,0,0%,7,100%
404 a: ,7,100%,0,0%,7,100%
405
406 Table: Report
407 ,g1,N
408 a,1.00,3.00
409 ,2.00,4.00
410
411 Table: Report
412 ,N
413 a,7.00
414
415 Table: Case Processing Summary
416 ,Cases,,,,,
417 ,Included,,Excluded,,Total,
418 ,N,Percent,N,Percent,N,Percent
419 a: g1,7,100%,0,0%,7,100%
420 a: ,7,100%,0,0%,7,100%
421 b: g1,6,85.7143%,1,14.2857%,7,100%
422 b: ,6,85.7143%,1,14.2857%,7,100%
423
424 Table: Report
425 ,g1,N
426 a,1.00,3.00
427 ,2.00,4.00
428 b,1.00,3.00
429 ,2.00,3.00
430
431 Table: Report
432 ,N
433 a,7.00
434 b,6.00
435
436 Table: Case Processing Summary
437 ,Cases,,,,,
438 ,Included,,Excluded,,Total,
439 ,N,Percent,N,Percent,N,Percent
440 a: g1,7,100%,0,0%,7,100%
441 a: ,7,100%,0,0%,7,100%
442
443 Table: Report
444 ,g1,N
445 a,1.00,3.00
446 ,2.00,4.00
447
448 Table: Report
449 ,N
450 a,7.00
451 ])
452
453 AT_CLEANUP
454
455
456
457
458
459 AT_SETUP([MEANS user missing values])
460
461 AT_DATA([means-missing.sps], [dnl
462 data list notable list /a * b * g1.
463 begin data.
464 1 2 9  
465 2 2 1 
466 3 2 1 
467 4 2 2 
468 5 2 2 
469 6 2 2 
470 7 9 2 
471 end data.
472
473 MISSING VALUES a b g1 (9).
474
475 MEANS a b BY g1 /cells =  COUNT .
476
477 MEANS a b BY g1 /cells =  COUNT /missing = include .
478
479 MEANS a b BY g1 /cells =  COUNT /missing = dependent .
480 ])
481
482
483 AT_CHECK([pspp -O format=csv means-missing.sps], [0],
484   [dnl
485 Table: Case Processing Summary
486 ,Cases,,,,,
487 ,Included,,Excluded,,Total,
488 ,N,Percent,N,Percent,N,Percent
489 a: g1,6,85.7143%,1,14.2857%,7,100%
490 a: ,7,100%,0,0%,7,100%
491 b: g1,5,71.4286%,2,28.5714%,7,100%
492 b: ,6,85.7143%,1,14.2857%,7,100%
493
494 Table: Report
495 ,g1,N
496 a,1.00,2.00
497 ,2.00,4.00
498 b,1.00,2.00
499 ,2.00,3.00
500
501 Table: Report
502 ,N
503 a,6.00
504 b,5.00
505
506 Table: Case Processing Summary
507 ,Cases,,,,,
508 ,Included,,Excluded,,Total,
509 ,N,Percent,N,Percent,N,Percent
510 a: g1,7,100%,0,0%,7,100%
511 a: ,7,100%,0,0%,7,100%
512 b: g1,7,100%,0,0%,7,100%
513 b: ,7,100%,0,0%,7,100%
514
515 Table: Report
516 ,g1,N
517 a,1.00,2.00
518 ,2.00,4.00
519 ,9.00,1.00
520 b,1.00,2.00
521 ,2.00,4.00
522 ,9.00,1.00
523
524 Table: Report
525 ,N
526 a,7.00
527 b,7.00
528
529 Table: Case Processing Summary
530 ,Cases,,,,,
531 ,Included,,Excluded,,Total,
532 ,N,Percent,N,Percent,N,Percent
533 a: g1,7,100%,0,0%,7,100%
534 a: ,7,100%,0,0%,7,100%
535 b: g1,6,85.7143%,1,14.2857%,7,100%
536 b: ,6,85.7143%,1,14.2857%,7,100%
537
538 Table: Report
539 ,g1,N
540 a,1.00,2.00
541 ,2.00,4.00
542 ,9.00,1.00
543 b,1.00,2.00
544 ,2.00,3.00
545 ,9.00,1.00
546
547 Table: Report
548 ,N
549 a,7.00
550 b,6.00
551 ])
552
553 AT_CLEANUP
554
555
556
557 AT_SETUP([MEANS empty factor spec])
558
559 AT_DATA([means-bad.sps], [dnl
560 data list list /outcome *.
561 begin data.
562 1
563 2
564 3
565 end data.
566
567 MEANS TABLES =  outcome 
568         BY.
569 ])
570
571 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
572
573 AT_CLEANUP
574
575
576
577 AT_SETUP([MEANS parser bug])
578
579 dnl This bug caused an infinite loop
580 AT_DATA([means-bad.sps], [dnl
581 DATA LIST notable LIST /a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 fylo *.
582 begin data.
583 1 2 3 4 5 6 7 8 9 0 11
584 end data.
585
586 MEANS TABLES = a1 a2 a3 a4 a5 a6 a7 a8 a9 a10a BY fylo.
587 ])
588
589 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
590
591 AT_CLEANUP
592
593
594
595