Add copyright and licence notices to files which lack them.
[pspp] / tests / language / stats / examine.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 AT_BANNER([EXAMINE])
17
18 AT_SETUP([EXAMINE])
19 AT_DATA([examine.sps], [
20 DATA LIST LIST /QUALITY * W * BRAND * .
21 BEGIN DATA
22 3  1  1
23 2  2  1
24 1  2  1
25 1  1  1
26 4  1  1
27 4  1  1
28 5  1  2
29 2  1  2
30 4  4  2
31 2  1  2
32 3  1  2
33 7  1  3
34 4  2  3
35 5  3  3
36 3  1  3
37 6  1  3
38 END DATA
39
40 WEIGHT BY w.
41
42 VARIABLE LABELS brand   'Manufacturer'.
43 VARIABLE LABELS quality 'Breaking Strain'.
44
45 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
46
47 LIST /FORMAT=NUMBERED.
48
49 EXAMINE
50         quality BY brand
51         /STATISTICS descriptives extreme(3)
52         .
53 ])
54
55
56 dnl In the following data, only the extreme values have been checked.
57 dnl The descriptives have been blindly pasted.
58 AT_CHECK([pspp -O format=csv examine.sps], [0], [dnl
59 Table: Reading free-form data from INLINE.
60 Variable,Format
61 QUALITY,F8.0
62 W,F8.0
63 BRAND,F8.0
64
65 Table: Data List
66 Case Number,QUALITY,W,BRAND
67 1,3.00,1.00,1.00
68 2,2.00,2.00,1.00
69 3,1.00,2.00,1.00
70 4,1.00,1.00,1.00
71 5,4.00,1.00,1.00
72 6,4.00,1.00,1.00
73 7,5.00,1.00,2.00
74 8,2.00,1.00,2.00
75 9,4.00,4.00,2.00
76 10,2.00,1.00,2.00
77 11,3.00,1.00,2.00
78 12,7.00,1.00,3.00
79 13,4.00,2.00,3.00
80 14,5.00,3.00,3.00
81 15,3.00,1.00,3.00
82 16,6.00,1.00,3.00
83
84 Table: Case Processing Summary
85 ,Cases,,,,,
86 ,Valid,,Missing,,Total,
87 ,N,Percent,N,Percent,N,Percent
88 Breaking Strain,24.00,100%,.00,0%,24.00,100%
89
90 Table: Extreme Values
91 ,,,Case Number,Value
92 Breaking Strain,Highest,1,12,7.00
93 ,,2,16,6.00
94 ,,3,14,5.00
95 ,Lowest,1,3,1.00
96 ,,2,4,1.00
97 ,,3,2,2.00
98
99 Table: Descriptives
100 ,,,Statistic,Std. Error
101 Breaking Strain,Mean,,3.54,.32
102 ,95% Confidence Interval for Mean,Lower Bound,2.87,
103 ,,Upper Bound,4.21,
104 ,5% Trimmed Mean,,3.50,
105 ,Median,,4.00,
106 ,Variance,,2.52,
107 ,Std. Deviation,,1.59,
108 ,Minimum,,1.00,
109 ,Maximum,,7.00,
110 ,Range,,6.00,
111 ,Interquartile Range,,2.75,
112 ,Skewness,,.06,.47
113 ,Kurtosis,,-.36,.92
114
115 Table: Case Processing Summary
116 ,,Cases,,,,,
117 ,,Valid,,Missing,,Total,
118 ,Manufacturer,N,Percent,N,Percent,N,Percent
119 Breaking Strain,Aspeger,8.00,100%,.00,0%,8.00,100%
120 ,Bloggs,8.00,100%,.00,0%,8.00,100%
121 ,Charlies,8.00,100%,.00,0%,8.00,100%
122
123 Table: Extreme Values
124 ,Manufacturer,,,Case Number,Value
125 Breaking Strain,Aspeger,Highest,1,6,4.00
126 ,,,2,5,4.00
127 ,,,3,1,3.00
128 ,,Lowest,1,3,1.00
129 ,,,2,4,1.00
130 ,,,3,2,2.00
131 ,Bloggs,Highest,1,7,5.00
132 ,,,2,9,4.00
133 ,,,3,11,3.00
134 ,,Lowest,1,8,2.00
135 ,,,2,10,2.00
136 ,,,3,11,3.00
137 ,Charlies,Highest,1,12,7.00
138 ,,,2,16,6.00
139 ,,,3,14,5.00
140 ,,Lowest,1,15,3.00
141 ,,,2,13,4.00
142 ,,,3,14,5.00
143
144 Table: Descriptives
145 ,Manufacturer,,,Statistic,Std. Error
146 Breaking Strain,Aspeger,Mean,,2.25,.45
147 ,,95% Confidence Interval for Mean,Lower Bound,1.18,
148 ,,,Upper Bound,3.32,
149 ,,5% Trimmed Mean,,2.22,
150 ,,Median,,2.00,
151 ,,Variance,,1.64,
152 ,,Std. Deviation,,1.28,
153 ,,Minimum,,1.00,
154 ,,Maximum,,4.00,
155 ,,Range,,3.00,
156 ,,Interquartile Range,,2.75,
157 ,,Skewness,,.47,.75
158 ,,Kurtosis,,-1.55,1.48
159 ,Bloggs,Mean,,3.50,.38
160 ,,95% Confidence Interval for Mean,Lower Bound,2.61,
161 ,,,Upper Bound,4.39,
162 ,,5% Trimmed Mean,,3.50,
163 ,,Median,,4.00,
164 ,,Variance,,1.14,
165 ,,Std. Deviation,,1.07,
166 ,,Minimum,,2.00,
167 ,,Maximum,,5.00,
168 ,,Range,,3.00,
169 ,,Interquartile Range,,1.75,
170 ,,Skewness,,-.47,.75
171 ,,Kurtosis,,-.83,1.48
172 ,Charlies,Mean,,4.88,.44
173 ,,95% Confidence Interval for Mean,Lower Bound,3.83,
174 ,,,Upper Bound,5.92,
175 ,,5% Trimmed Mean,,4.86,
176 ,,Median,,5.00,
177 ,,Variance,,1.55,
178 ,,Std. Deviation,,1.25,
179 ,,Minimum,,3.00,
180 ,,Maximum,,7.00,
181 ,,Range,,4.00,
182 ,,Interquartile Range,,1.75,
183 ,,Skewness,,.30,.75
184 ,,Kurtosis,,.15,1.48
185 ])
186
187 AT_CLEANUP
188
189 AT_SETUP([EXAMINE -- extremes])
190 AT_DATA([examine.sps], [dnl
191 data list free /V1 W
192 begin data.
193 1  1
194 2  1
195 3  2
196 3  1
197 4  1
198 5  1
199 6  1
200 7  1
201 8  1
202 9  1
203 10 1
204 11 1
205 12 1
206 13 1
207 14 1
208 15 1
209 16 1
210 17 1
211 18 2
212 19 1
213 20 1
214 end data.
215
216 weight by w.
217
218 examine v1 
219  /statistics=extreme(6)
220  .
221 ])
222
223 AT_CHECK([pspp -O format=csv examine.sps], [0],[dnl
224 Table: Case Processing Summary
225 ,Cases,,,,,
226 ,Valid,,Missing,,Total,
227 ,N,Percent,N,Percent,N,Percent
228 V1,23.00,100%,.00,0%,23.00,100%
229
230 Table: Extreme Values
231 ,,,Case Number,Value
232 V1,Highest,1,21,20.00
233 ,,2,20,19.00
234 ,,3,19,18.00
235 ,,4,18,17.00
236 ,,5,17,16.00
237 ,,6,16,15.00
238 ,Lowest,1,1,1.00
239 ,,2,2,2.00
240 ,,3,3,3.00
241 ,,4,4,3.00
242 ,,5,5,4.00
243 ,,6,6,5.00
244 ])
245
246 AT_CLEANUP
247
248
249
250 AT_SETUP([EXAMINE -- extremes with fractional weights])
251 AT_DATA([extreme.sps], [dnl
252 set format=F20.3.
253 data list notable list /w * x *.
254 begin data.
255  0.88  300000
256  0.86  320000
257  0.98  480000
258  0.93  960000
259  1.35  960000
260  1.31  960000
261  0.88  960000
262  0.88  1080000
263  0.88  1080000
264  0.95  1200000
265  1.47  1200000
266  0.93  1200000
267  0.98  1320000
268  1.31  1380000
269  0.93  1440000
270  0.88  1560000
271  1.56  1560000
272  1.47  1560000
273 end data.
274
275 weight by w.
276
277
278 EXAMINE
279         x
280         /STATISTICS = DESCRIPTIVES EXTREME (5)
281         .
282 ])
283
284 AT_CHECK([pspp -O format=csv  extreme.sps], [0], [dnl
285 Table: Case Processing Summary
286 ,Cases,,,,,
287 ,Valid,,Missing,,Total,
288 ,N,Percent,N,Percent,N,Percent
289 x,19.430,100%,.000,0%,19.430,100%
290
291 Table: Extreme Values
292 ,,,Case Number,Value
293 x,Highest,1,18,1560000.000
294 ,,2,17,1560000.000
295 ,,3,16,1560000.000
296 ,,4,15,1440000.000
297 ,,5,14,1380000.000
298 ,Lowest,1,1,300000.000
299 ,,2,2,320000.000
300 ,,3,3,480000.000
301 ,,4,4,960000.000
302 ,,5,5,960000.000
303
304 Table: Descriptives
305 ,,,Statistic,Std. Error
306 x,Mean,,1120010.293,86222.178
307 ,95% Confidence Interval for Mean,Lower Bound,939166.693,
308 ,,Upper Bound,1300853.894,
309 ,5% Trimmed Mean,,1141017.899,
310 ,Median,,1200000.000,
311 ,Variance,,144447748124.869,
312 ,Std. Deviation,,380062.821,
313 ,Minimum,,300000.000,
314 ,Maximum,,1560000.000,
315 ,Range,,1260000.000,
316 ,Interquartile Range,,467258.065,
317 ,Skewness,,-.887,.519
318 ,Kurtosis,,.340,1.005
319 ])
320
321 AT_CLEANUP
322
323 dnl Test the PERCENTILES subcommand of the EXAMINE command.
324 dnl In particular test that it behaves properly when there are only 
325 dnl a few cases.
326 AT_SETUP([EXAMINE -- percentiles])
327 AT_DATA([examine.sps], [dnl
328 DATA LIST LIST /X *.
329 BEGIN DATA.
330 2.00 
331 8.00 
332 5.00 
333 END DATA.
334
335 EXAMINE /x
336         /PERCENTILES=HAVERAGE.
337
338 EXAMINE /x
339         /PERCENTILES=WAVERAGE.
340
341 EXAMINE /x
342         /PERCENTILES=ROUND.
343
344 EXAMINE /x
345         /PERCENTILES=EMPIRICAL.
346
347 EXAMINE /x
348         /PERCENTILES=AEMPIRICAL.
349 ])
350 AT_CHECK([pspp -o pspp.csv examine.sps])
351 AT_CHECK([cat pspp.csv], [0], [dnl
352 Table: Reading free-form data from INLINE.
353 Variable,Format
354 X,F8.0
355
356 Table: Case Processing Summary
357 ,Cases,,,,,
358 ,Valid,,Missing,,Total,
359 ,N,Percent,N,Percent,N,Percent
360 X,3,100%,0,0%,3,100%
361
362 Table: Percentiles
363 ,,Percentiles,,,,,,
364 ,,5,10,25,50,75,90,95
365 X,HAverage,.40,.80,2.00,5.00,8.00,8.00,8.00
366 ,Tukey's Hinges,,,3.50,5.00,6.50,,
367
368 Table: Case Processing Summary
369 ,Cases,,,,,
370 ,Valid,,Missing,,Total,
371 ,N,Percent,N,Percent,N,Percent
372 X,3,100%,0,0%,3,100%
373
374 Table: Percentiles
375 ,,Percentiles,,,,,,
376 ,,5,10,25,50,75,90,95
377 X,Weighted Average,.30,.60,1.50,3.50,5.75,7.10,7.55
378 ,Tukey's Hinges,,,3.50,5.00,6.50,,
379
380 Table: Case Processing Summary
381 ,Cases,,,,,
382 ,Valid,,Missing,,Total,
383 ,N,Percent,N,Percent,N,Percent
384 X,3,100%,0,0%,3,100%
385
386 Table: Percentiles
387 ,,Percentiles,,,,,,
388 ,,5,10,25,50,75,90,95
389 X,Rounded,.00,.00,2.00,5.00,5.00,8.00,8.00
390 ,Tukey's Hinges,,,3.50,5.00,6.50,,
391
392 Table: Case Processing Summary
393 ,Cases,,,,,
394 ,Valid,,Missing,,Total,
395 ,N,Percent,N,Percent,N,Percent
396 X,3,100%,0,0%,3,100%
397
398 Table: Percentiles
399 ,,Percentiles,,,,,,
400 ,,5,10,25,50,75,90,95
401 X,Empirical,2.00,2.00,2.00,5.00,8.00,8.00,8.00
402 ,Tukey's Hinges,,,3.50,5.00,6.50,,
403
404 Table: Case Processing Summary
405 ,Cases,,,,,
406 ,Valid,,Missing,,Total,
407 ,N,Percent,N,Percent,N,Percent
408 X,3,100%,0,0%,3,100%
409
410 Table: Percentiles
411 ,,Percentiles,,,,,,
412 ,,5,10,25,50,75,90,95
413 X,Empirical with averaging,2.00,2.00,2.00,5.00,8.00,8.00,8.00
414 ,Tukey's Hinges,,,3.50,5.00,6.50,,
415 ])
416 AT_CLEANUP
417
418 AT_SETUP([EXAMINE -- missing values])
419 AT_DATA([examine.sps], [dnl
420 DATA LIST LIST /x * y *.
421 BEGIN DATA.
422 1   1 
423 2   1
424 3   1
425 4   1
426 5   2
427 6   2
428 .   2
429 END DATA
430
431 EXAMINE /x by y
432         /MISSING = PAIRWISE
433         .
434 ])
435 AT_CHECK([pspp -o pspp.csv examine.sps])
436 AT_CHECK([cat pspp.csv], [0], [dnl
437 Table: Reading free-form data from INLINE.
438 Variable,Format
439 x,F8.0
440 y,F8.0
441
442 Table: Case Processing Summary
443 ,Cases,,,,,
444 ,Valid,,Missing,,Total,
445 ,N,Percent,N,Percent,N,Percent
446 x,6,85.7143%,1,14.2857%,7,100%
447
448 Table: Case Processing Summary
449 ,,Cases,,,,,
450 ,,Valid,,Missing,,Total,
451 ,y,N,Percent,N,Percent,N,Percent
452 x,1.00,4,100%,0,0%,4,100%
453 ,2.00,2,66.6667%,1,33.3333%,3,100%
454 ])
455 AT_CLEANUP
456
457
458 AT_SETUP([EXAMINE -- user missing values])
459 AT_DATA([examine-m.sps], [dnl
460 DATA LIST notable LIST /x * y *.
461 BEGIN DATA.
462 1                   2
463 9999999999          2
464 9999999999          99
465 END DATA.
466
467 MISSING VALUES x (9999999999).
468 MISSING VALUES y (99).
469
470 EXAMINE
471         /VARIABLES= x y
472         /MISSING=PAIRWISE.
473 ])
474 AT_CHECK([pspp -O format=csv examine-m.sps], [0], [dnl
475 Table: Case Processing Summary
476 ,Cases,,,,,
477 ,Valid,,Missing,,Total,
478 ,N,Percent,N,Percent,N,Percent
479 x,1,33.3333%,2,66.6667%,3,100%
480 y,2,66.6667%,1,33.3333%,3,100%
481 ])
482 AT_CLEANUP
483
484 AT_SETUP([EXAMINE -- missing values and percentiles])
485 AT_DATA([examine.sps], [dnl
486 DATA LIST LIST /X *.
487 BEGIN DATA.
488 99
489 99
490 5.00
491 END DATA.
492
493 MISSING VALUE X (99).
494
495 EXAMINE /x
496         /PERCENTILES=HAVERAGE.
497 ])
498 AT_CHECK([pspp -o pspp.csv examine.sps])
499 dnl Ignore output -- this is just a no-crash check.
500 AT_CLEANUP
501
502 dnl Tests the trimmed mean calculation in the case
503 dnl where the data is weighted towards the centre.
504 AT_SETUP([EXAMINE -- trimmed mean])
505 AT_DATA([examine.sps], [dnl
506 DATA LIST LIST /X * C *.
507 BEGIN DATA.
508 1 1
509 2 49
510 3 2
511 END DATA.
512
513 WEIGHT BY c.
514
515 EXAMINE
516         x
517         /STATISTICS=DESCRIPTIVES
518         .
519 ])
520 AT_CHECK([pspp -o pspp.csv examine.sps])
521 AT_CHECK([cat pspp.csv], [0], [dnl
522 Table: Reading free-form data from INLINE.
523 Variable,Format
524 X,F8.0
525 C,F8.0
526
527 Table: Case Processing Summary
528 ,Cases,,,,,
529 ,Valid,,Missing,,Total,
530 ,N,Percent,N,Percent,N,Percent
531 X,52.00,100%,.00,0%,52.00,100%
532
533 Table: Descriptives
534 ,,,Statistic,Std. Error
535 X,Mean,,2.02,.03
536 ,95% Confidence Interval for Mean,Lower Bound,1.95,
537 ,,Upper Bound,2.09,
538 ,5% Trimmed Mean,,2.00,
539 ,Median,,2.00,
540 ,Variance,,.06,
541 ,Std. Deviation,,.24,
542 ,Minimum,,1.00,
543 ,Maximum,,3.00,
544 ,Range,,2.00,
545 ,Interquartile Range,,.00,
546 ,Skewness,,1.19,.33
547 ,Kurtosis,,15.73,.65
548 ])
549 AT_CLEANUP
550
551 AT_SETUP([EXAMINE -- crash bug])
552 AT_DATA([examine.sps], [dnl
553 data list list /a * x * y *.
554 begin data.
555 3 1 3
556 5 1 4
557 7 2 3
558 end data.
559
560 examine a by x by y
561         /statistics=DESCRIPTIVES
562         . 
563 ])
564 AT_CHECK([pspp -o pspp.csv examine.sps])
565 dnl Ignore output -- this is just a no-crash check.
566 AT_CLEANUP
567
568 dnl Test that two consecutive EXAMINE commands don't crash PSPP.
569 AT_SETUP([EXAMINE -- consecutive runs don't crash])
570 AT_DATA([examine.sps], [dnl
571 data list list /y * z *.
572 begin data.
573 6 4
574 5 3
575 7 6
576 end data.
577
578 EXAMINE /VARIABLES= z BY y.
579
580 EXAMINE /VARIABLES= z. 
581 ])
582 AT_CHECK([pspp -o pspp.csv examine.sps])
583 dnl Ignore output -- this is just a no-crash check.
584 AT_CLEANUP
585
586 dnl Test that /DESCRIPTIVES does not crash in presence of missing values.
587 AT_SETUP([EXAMINE -- missing values don't crash])
588 AT_DATA([examine.sps], [dnl
589 data list list /x * y *.
590 begin data.
591 1 0
592 2 0
593 . 0
594 3 1
595 4 1
596 end data.
597 examine x by y /statistics=descriptives. 
598 ])
599 AT_CHECK([pspp -o pspp.csv examine.sps])
600 dnl Ignore output -- this is just a no-crash check.
601 AT_CLEANUP
602
603 dnl Test that having only a single case doesn't crash.
604 AT_SETUP([EXAMINE -- single case doesn't crash])
605 AT_DATA([examine.sps], [dnl
606 DATA LIST LIST /quality * .
607 BEGIN DATA
608 3  
609 END DATA
610
611
612 EXAMINE
613         quality 
614         /STATISTICS descriptives 
615         /PLOT = histogram
616         .
617 ])
618 AT_CHECK([pspp -o pspp.csv examine.sps], [0], [ignore])
619 dnl Ignore output -- this is just a no-crash check.
620 AT_CLEANUP
621
622 dnl Test that all-missing data doesn't crash.
623 AT_SETUP([EXAMINE -- all-missing data doesn't crash])
624 AT_DATA([examine.sps], [dnl
625 DATA LIST LIST /x *.
626 BEGIN DATA.
627 .
628 .
629 .
630 .
631 END DATA.
632
633 EXAMINE /x 
634         PLOT=HISTOGRAM BOXPLOT NPPLOT SPREADLEVEL(1) ALL
635         /ID=x
636         /STATISTICS = DESCRIPTIVES EXTREME (5) ALL
637         /PERCENTILE=AEMPIRICAL
638         .
639 ])
640 AT_CHECK([pspp -o pspp.csv examine.sps], [0], [ignore])
641 dnl Ignore output -- this is just a no-crash check.
642 AT_CLEANUP
643
644 dnl Test that big input doesn't crash (bug 11307).
645 AT_SETUP([EXAMINE -- big input doesn't crash])
646 AT_DATA([examine.sps], [dnl
647 INPUT PROGRAM.
648         LOOP #I=1 TO 50000.
649                 COMPUTE X=NORMAL(10).
650                 END CASE.
651         END LOOP.
652         END FILE.
653 END INPUT PROGRAM.
654
655
656 EXAMINE /x
657         /STATISTICS=DESCRIPTIVES.
658 ])
659 AT_CHECK([pspp -o pspp.csv examine.sps])
660 dnl Ignore output -- this is just a no-crash check.
661 AT_CLEANUP
662
663 dnl Another test that big input doesn't crash.
664 dnl The actual bug that this checks for has been lost.
665 AT_SETUP([EXAMINE -- big input doesn't crash 2])
666 AT_DATA([make-big-input.pl], 
667   [for ($i=0; $i<100000; $i++) { print "AB12\n" };
668    for ($i=0; $i<100000; $i++) { print "AB04\n" };
669 ])
670 AT_CHECK([$PERL make-big-input.pl > large.txt])
671 AT_DATA([examine.sps], [dnl
672 DATA LIST FILE='large.txt' /S 1-2 (A) X 3 .
673
674
675 AGGREGATE OUTFILE=* /BREAK=X /A=N.
676
677
678 EXAMINE /A BY X.
679 ])
680 AT_CHECK([pspp -o pspp.csv examine.sps])
681 dnl Ignore output -- this is just a no-crash check.
682 AT_DATA([more-big-input.pl], 
683   [for ($i=0; $i<25000; $i++) { print "AB04\nAB12\n" };
684 ])
685 AT_CHECK([$PERL more-big-input.pl >> large.txt])
686 AT_CHECK([pspp -o pspp.csv examine.sps])
687 dnl Ignore output -- this is just a no-crash check.
688 AT_CLEANUP
689
690
691 dnl Test that the ID command works with non-numberic variables
692 AT_SETUP([EXAMINE -- non-numeric ID])
693
694 AT_DATA([examine-id.sps], [dnl
695 data list notable list /x * y (a12).
696 begin data.
697 1  one
698 2  two
699 3  three
700 4  four
701 5  five
702 6  six
703 7  seven
704 8  eight
705 9  nine
706 10 ten
707 11 eleven
708 12 twelve
709 30 thirty
710 300 threehundred
711 end data.
712
713 examine x
714         /statistics = extreme
715         /id = y
716         /plot = boxplot
717         .
718 ])
719
720 AT_CHECK([pspp -O format=csv examine-id.sps], [0], 
721 [Table: Case Processing Summary
722 ,Cases,,,,,
723 ,Valid,,Missing,,Total,
724 ,N,Percent,N,Percent,N,Percent
725 x,14,100%,0,0%,14,100%
726
727 Table: Extreme Values
728 ,,,y,Value
729 x,Highest,1,threehundred,300.00
730 ,,2,thirty      ,30.00
731 ,,3,twelve      ,12.00
732 ,,4,eleven      ,11.00
733 ,,5,ten         ,10.00
734 ,Lowest,1,one         ,1.00
735 ,,2,two         ,2.00
736 ,,3,three       ,3.00
737 ,,4,four        ,4.00
738 ,,5,five        ,5.00
739 ])
740
741 AT_CLEANUP 
742
743 dnl Test for a crash which happened on cleanup from a bad input syntax
744 AT_SETUP([EXAMINE -- Bad Input])
745
746 AT_DATA([examine-bad.sps], [dnl
747 data list list /h * g *.
748 begin data.
749 1 1
750 2 1
751 3 1
752 4 1
753 5 2
754 6 2
755 7 2
756 8 2
757 9 2
758 end data.
759
760 EXAMINE 
761         /VARIABLES= h
762         BY  g
763         /STATISTICS = DESCRIPTIVES EXTREME
764         /PLOT = lkajsdas
765         .
766 ])
767
768 AT_CHECK([pspp -o pspp.csv examine-bad.sps], [1], [ignore])
769
770 AT_CLEANUP 
771
772
773 dnl Check the MISSING=REPORT option
774 AT_SETUP([EXAMINE -- MISSING=REPORT])
775
776
777 AT_DATA([examine-report.sps], [dnl
778 set format = F22.0.
779 data list list /x * g *.
780 begin data.
781 1   1
782 2   1
783 3   1
784 4   1
785 5   1
786 6   1
787 7   1
788 8   1
789 9   1
790 10   2
791 20   2
792 30   2
793 40   2
794 50   2
795 60   2
796 70   2
797 80   2
798 90   2
799 101   9
800 201   9
801 301   9
802 401   9
803 501   99
804 601   99
805 701   99
806 801   99
807 901   99
808 1001  .
809 2002  .
810 3003  .
811 4004  .
812 end data.
813
814 MISSING VALUES g (9, 99, 999).
815
816 EXAMINE
817         /VARIABLES = x
818         BY  g
819         /STATISTICS = EXTREME
820         /NOTOTAL
821         /MISSING = REPORT.
822 ])
823
824
825 AT_CHECK([pspp -O format=csv examine-report.sps], [0], [dnl
826 Table: Reading free-form data from INLINE.
827 Variable,Format
828 x,F8.0
829 g,F8.0
830
831 Table: Case Processing Summary
832 ,,Cases,,,,,
833 ,,Valid,,Missing,,Total,
834 ,g,N,Percent,N,Percent,N,Percent
835 x,. (missing),4,100%,0,0%,4,100%
836 ,1,9,100%,0,0%,9,100%
837 ,2,9,100%,0,0%,9,100%
838 ,9 (missing),4,100%,0,0%,4,100%
839 ,99 (missing),5,100%,0,0%,5,100%
840
841 Table: Extreme Values
842 ,g,,,Case Number,Value
843 x,. (missing),Highest,1,31,4004
844 ,,,2,30,3003
845 ,,,3,29,2002
846 ,,,4,28,1001
847 ,,,5,0,0
848 ,,Lowest,1,28,1001
849 ,,,2,29,2002
850 ,,,3,30,3003
851 ,,,4,31,4004
852 ,,,5,31,4004
853 ,1,Highest,1,9,9
854 ,,,2,8,8
855 ,,,3,7,7
856 ,,,4,6,6
857 ,,,5,5,5
858 ,,Lowest,1,1,1
859 ,,,2,2,2
860 ,,,3,3,3
861 ,,,4,4,4
862 ,,,5,5,5
863 ,2,Highest,1,18,90
864 ,,,2,17,80
865 ,,,3,16,70
866 ,,,4,15,60
867 ,,,5,14,50
868 ,,Lowest,1,10,10
869 ,,,2,11,20
870 ,,,3,12,30
871 ,,,4,13,40
872 ,,,5,14,50
873 ,9 (missing),Highest,1,22,401
874 ,,,2,21,301
875 ,,,3,20,201
876 ,,,4,19,101
877 ,,,5,0,0
878 ,,Lowest,1,19,101
879 ,,,2,20,201
880 ,,,3,21,301
881 ,,,4,22,401
882 ,,,5,22,401
883 ,99 (missing),Highest,1,27,901
884 ,,,2,26,801
885 ,,,3,25,701
886 ,,,4,24,601
887 ,,,5,23,501
888 ,,Lowest,1,23,501
889 ,,,2,24,601
890 ,,,3,25,701
891 ,,,4,26,801
892 ,,,5,27,901
893 ])
894
895
896 AT_CLEANUP 
897
898
899 dnl Run a test of the basic STATISTICS using a "real"
900 dnl dataset and comparing with "real" results kindly
901 dnl provided by Olaf Nöhring
902 AT_SETUP([EXAMINE -- sample unweighted])
903
904 AT_DATA([sample.sps], [dnl
905 set format = F22.4.
906 DATA LIST notable LIST /X *
907 BEGIN DATA.
908 461.19000000
909 466.38000000
910 479.46000000
911 480.10000000
912 483.43000000
913 488.30000000
914 489.00000000
915 491.62000000
916 505.62000000
917 511.30000000
918 521.53000000
919 526.70000000
920 528.25000000
921 538.70000000
922 540.22000000
923 540.58000000
924 546.10000000
925 548.17000000
926 553.99000000
927 566.21000000
928 575.90000000
929 584.38000000
930 593.40000000
931 357.05000000
932 359.73000000
933 360.48000000
934 373.98000000
935 374.13000000
936 381.45000000
937 383.72000000
938 390.00000000
939 400.34000000
940 415.32000000
941 415.91000000
942 418.30000000
943 421.03000000
944 422.43000000
945 426.93000000
946 433.25000000
947 436.89000000
948 445.33000000
949 446.33000000
950 446.55000000
951 456.44000000
952 689.49000000
953 691.92000000
954 695.00000000
955 695.36000000
956 698.21000000
957 699.46000000
958 706.61000000
959 710.69000000
960 715.82000000
961 715.82000000
962 741.39000000
963 752.27000000
964 756.73000000
965 757.74000000
966 759.57000000
967 796.07000000
968 813.78000000
969 817.25000000
970 825.48000000
971 831.28000000
972 849.24000000
973 890.00000000
974 894.78000000
975 935.65000000
976 935.90000000
977 945.90000000
978 1012.8600000
979 1022.6000000
980 1061.8100000
981 1063.5000000
982 1077.2300000
983 1151.6300000
984 1355.2800000
985 598.88000000
986 606.91000000
987 621.60000000
988 624.80000000
989 636.13000000
990 637.38000000
991 640.32000000
992 649.35000000
993 656.51000000
994 662.55000000
995 664.69000000
996 106.22000000
997 132.24000000
998 174.76000000
999 204.85000000
1000 264.93000000
1001 264.99000000
1002 269.84000000
1003 325.12000000
1004 331.67000000
1005 337.26000000
1006 347.68000000
1007 354.91000000
1008 END DATA.
1009
1010 EXAMINE
1011         x
1012         /STATISTICS=DESCRIPTIVES
1013         .
1014 ])
1015
1016 AT_CHECK([pspp -O format=csv sample.sps], [0], [dnl
1017 Table: Case Processing Summary
1018 ,Cases,,,,,
1019 ,Valid,,Missing,,Total,
1020 ,N,Percent,N,Percent,N,Percent
1021 X,100,100%,0,0%,100,100%
1022
1023 Table: Descriptives
1024 ,,,Statistic,Std. Error
1025 X,Mean,,587.6603,23.2665
1026 ,95% Confidence Interval for Mean,Lower Bound,541.4946,
1027 ,,Upper Bound,633.8260,
1028 ,5% Trimmed Mean,,579.7064,
1029 ,Median,,547.1350,
1030 ,Variance,,54132.8466,
1031 ,Std. Deviation,,232.6647,
1032 ,Minimum,,106.2200,
1033 ,Maximum,,1355.2800,
1034 ,Range,,1249.0600,
1035 ,Interquartile Range,,293.1575,
1036 ,Skewness,,.6331,.2414
1037 ,Kurtosis,,.5300,.4783
1038 ])
1039
1040 AT_CLEANUP 
1041
1042
1043
1044 dnl Test for a crash which happened on bad input syntax
1045 AT_SETUP([EXAMINE -- Empty Parentheses])
1046
1047 AT_DATA([examine-empty-parens.sps], [dnl
1048 DATA LIST notable LIST /X *
1049 BEGIN DATA.
1050 2
1051 3
1052 END DATA.
1053
1054
1055 EXAMINE
1056         x
1057         /PLOT = SPREADLEVEL()
1058         .
1059 ])
1060
1061 AT_CHECK([pspp -o pspp.csv examine-empty-parens.sps], [1], [ignore])
1062
1063 AT_CLEANUP 
1064
1065
1066
1067
1068 dnl Test for another crash which happened on bad input syntax
1069 AT_SETUP([EXAMINE -- Bad variable])
1070
1071 AT_DATA([examine-bad-variable.sps], [dnl
1072 data list list /h * g *.
1073 begin data.
1074 3 1
1075 4 1
1076 5 2
1077 end data.
1078
1079 EXAMINE
1080         /VARIABLES/ h
1081         BY  g
1082         .
1083 ])
1084
1085 AT_CHECK([pspp -o pspp.csv examine-bad-variable.sps], [1], [ignore])
1086
1087 AT_CLEANUP 
1088
1089
1090
1091 dnl Test for yet another crash. This time for extremes vs. missing weight values.\0
1092 AT_SETUP([EXAMINE -- Extremes vs. Missing Weights])
1093
1094 AT_DATA([examine-missing-weights.sps], [dnl
1095 data list notable list /h * g *.
1096 begin data.
1097 3 1
1098 4 .
1099 5 1
1100 2 1
1101 end data.
1102
1103 WEIGHT BY g.
1104
1105 EXAMINE h
1106         /STATISTICS extreme(3)
1107         .
1108 ])
1109
1110 AT_CHECK([pspp -O format=csv  examine-missing-weights.sps], [0], [dnl
1111 "examine-missing-weights.sps:13: warning: EXAMINE: At least one case in the data file had a weight value that was user-missing, system-missing, zero, or negative.  These case(s) were ignored."
1112
1113 Table: Case Processing Summary
1114 ,Cases,,,,,
1115 ,Valid,,Missing,,Total,
1116 ,N,Percent,N,Percent,N,Percent
1117 h,3.00,100%,.00,0%,3.00,100%
1118
1119 Table: Extreme Values
1120 ,,,Case Number,Value
1121 h,Highest,1,3,5.00
1122 ,,2,2,4.00
1123 ,,3,1,3.00
1124 ,Lowest,1,4,2.00
1125 ,,2,1,3.00
1126 ,,3,2,4.00
1127 ])
1128
1129 AT_CLEANUP 
1130
1131
1132