141c36fd8331e97e4ef558d9bd39cd58d08d4535
[pspp] / tests / language / stats / frequencies.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([FREQUENCIES procedure])
18
19 AT_SETUP([FREQUENCIES string variable])
20 AT_DATA([frequencies.sps],
21   [DATA LIST FREE/
22    name  (A8) value * quantity .
23 BEGIN DATA.
24 foo 1 5
25 bar 2 6
26 baz 1 9
27 quux 3 1
28 bar 1 2
29 baz 4 3
30 baz 1 4
31 baz 1 1
32 foo 6 0
33 quux 5 8
34 END DATA.
35 EXECUTE.
36
37 FREQUENCIES /VAR = name/ORDER=ANALYSIS.
38 ])
39 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
40 Table: name
41 ,,Frequency,Percent,Valid Percent,Cumulative Percent
42 Valid,bar,2,20.0%,20.0%,20.0%
43 ,baz,4,40.0%,40.0%,60.0%
44 ,foo,2,20.0%,20.0%,80.0%
45 ,quux,2,20.0%,20.0%,100.0%
46 Total,,10,100.0%,,
47 ])
48 AT_CLEANUP
49
50 # Tests for a bug where pspp would crash if two FREQUENCIES commands
51 # existed in a input file.
52 AT_SETUP([FREQUENCIES two runs crash])
53 AT_DATA([frequencies.sps],
54   [data list free /v1 v2.
55 begin data.
56 0 1
57 2 3 
58 4 5
59 3 4
60 end data.
61
62 frequencies v1 v2/statistics=none/ORDER=VARIABLE.
63 frequencies v1 v2/statistics=none.
64 ])
65 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
66 Table: v1
67 ,,Frequency,Percent,Valid Percent,Cumulative Percent
68 Valid,.00,1,25.0%,25.0%,25.0%
69 ,2.00,1,25.0%,25.0%,50.0%
70 ,3.00,1,25.0%,25.0%,75.0%
71 ,4.00,1,25.0%,25.0%,100.0%
72 Total,,4,100.0%,,
73
74 Table: v2
75 ,,Frequency,Percent,Valid Percent,Cumulative Percent
76 Valid,1.00,1,25.0%,25.0%,25.0%
77 ,3.00,1,25.0%,25.0%,50.0%
78 ,4.00,1,25.0%,25.0%,75.0%
79 ,5.00,1,25.0%,25.0%,100.0%
80 Total,,4,100.0%,,
81
82 Table: v1
83 ,,Frequency,Percent,Valid Percent,Cumulative Percent
84 Valid,.00,1,25.0%,25.0%,25.0%
85 ,2.00,1,25.0%,25.0%,50.0%
86 ,3.00,1,25.0%,25.0%,75.0%
87 ,4.00,1,25.0%,25.0%,100.0%
88 Total,,4,100.0%,,
89
90 Table: v2
91 ,,Frequency,Percent,Valid Percent,Cumulative Percent
92 Valid,1.00,1,25.0%,25.0%,25.0%
93 ,3.00,1,25.0%,25.0%,50.0%
94 ,4.00,1,25.0%,25.0%,75.0%
95 ,5.00,1,25.0%,25.0%,100.0%
96 Total,,4,100.0%,,
97 ])
98 AT_CLEANUP
99
100 # Test that the LIMIT specification works.
101 AT_SETUP([FREQUENCIES with LIMIT])
102 AT_DATA([frequencies.sps],
103   [data list free /v1 v2.
104 begin data.
105 0 1
106 2 5
107 4 3
108 3 5
109 end data.
110
111 frequencies v1 v2/statistics=none/FORMAT=LIMIT(3).
112 ])
113 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
114 Table: v2
115 ,,Frequency,Percent,Valid Percent,Cumulative Percent
116 Valid,1.00,1,25.0%,25.0%,25.0%
117 ,3.00,1,25.0%,25.0%,50.0%
118 ,5.00,2,50.0%,50.0%,100.0%
119 Total,,4,100.0%,,
120 ])
121 AT_CLEANUP
122
123 # Tests for a bug where PSPP would crash when a FREQUENCIES command
124 # was used with the HTML output driver.
125 AT_SETUP([FREQUENCIES HTML output crash])
126 AT_DATA([frequencies.sps],
127   [data list free /v1 v2.
128 begin data.
129 0 1
130 2 3 
131 4 5
132 3 4
133 end data.
134
135 list.
136
137 frequencies v1/statistics=none.
138 ])
139 AT_CHECK([pspp -o - -O format=csv -o pspp.html frequencies.sps], [0],
140   [Table: Data List
141 v1,v2
142 .00,1.00
143 2.00,3.00
144 4.00,5.00
145 3.00,4.00
146
147 Table: v1
148 ,,Frequency,Percent,Valid Percent,Cumulative Percent
149 Valid,.00,1,25.0%,25.0%,25.0%
150 ,2.00,1,25.0%,25.0%,50.0%
151 ,3.00,1,25.0%,25.0%,75.0%
152 ,4.00,1,25.0%,25.0%,100.0%
153 Total,,4,100.0%,,
154 ])
155 AT_CHECK([test -s pspp.html])
156 AT_CLEANUP
157
158 # Tests for a bug which crashed PSPP when a piechart with too many
159 # segments was requested.
160 AT_SETUP([FREQUENCIES pie chart crash])
161 AT_DATA([frequencies.sps],
162   [data list list /x * w *.
163 begin data.
164 1  4
165 34 10
166 -9 15
167 232 6
168 11  4
169 134 1
170 9  5
171 32 16
172 -2 6
173 2  16
174 20  6
175 end data.
176
177 weight by w.
178
179 frequencies /x /format=notable /statistics=none
180         /piechart.
181 ])
182 # Cannot use the CSV driver for this because it does not output charts
183 # at all.
184 AT_CHECK([pspp frequencies.sps], [0], [dnl
185 Reading free-form data from INLINE.
186 +--------+------+
187 |Variable|Format|
188 +--------+------+
189 |x       |F8.0  |
190 |w       |F8.0  |
191 +--------+------+
192 ])
193 AT_CLEANUP
194
195 dnl Check that histogram subcommand runs wihout crashing
196 AT_SETUP([FREQUENCIES histogram crash])
197 AT_DATA([frequencies.sps],
198   [data list notable list /x * w *.
199 begin data.
200 1  4
201 34 10
202 -9 15
203 232 6
204 11  4
205 134 1
206 9  5
207 32 16
208 -2 6
209 2  16
210 20  6
211 end data.
212
213 weight by w.
214
215 frequencies /x 
216             /format=notable 
217             /statistics=none
218             /histogram=minimum(0) maximum(50) percent(5) normal.
219 ])
220 # Cannot use the CSV driver for this because it does not output charts
221 # at all.
222 AT_CHECK([pspp -O format=pdf frequencies.sps], [0], [ignore])
223 AT_CLEANUP
224
225 # Tests for a bug which crashed PSPP when the median and a histogram
226 # were both requested.
227 AT_SETUP([FREQUENCIES median with histogram crash])
228 AT_DATA([frequencies.sps], [dnl
229 data list list notable /x.
230 begin data.
231 1
232 end data.
233
234 frequencies /x /histogram /STATISTICS=median.
235 ])
236 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [ignore])
237 dnl Ignore output - No crash test.
238 AT_CLEANUP
239
240 # Tests for a bug which caused FREQUENCIES following TEMPORARY to
241 # crash (bug #11492).
242 AT_SETUP([FREQUENCIES crash after TEMPORARY])
243 AT_DATA([frequencies.sps],
244   [DATA LIST LIST /SEX (A1) X *.
245 BEGIN DATA.
246 M 31
247 F 21
248 M 41
249 F 31
250 M 13
251 F 12
252 M 14
253 F 13
254 END DATA.
255
256
257 TEMPORARY
258 SELECT IF SEX EQ 'F'
259 FREQUENCIES /X .
260
261 FINISH
262 ])
263 AT_CHECK([pspp -o pspp.csv -o pspp.txt frequencies.sps])
264 AT_CHECK([cat pspp.csv], [0], [dnl
265 Table: Reading free-form data from INLINE.
266 Variable,Format
267 SEX,A1
268 X,F8.0
269
270 Table: Statistics
271 ,,X
272 N,Valid,4
273 ,Missing,0
274 Mean,,19.25
275 Std Dev,,8.81
276 Minimum,,12.00
277 Maximum,,31.00
278
279 Table: X
280 ,,Frequency,Percent,Valid Percent,Cumulative Percent
281 Valid,12.00,1,25.0%,25.0%,25.0%
282 ,13.00,1,25.0%,25.0%,50.0%
283 ,21.00,1,25.0%,25.0%,75.0%
284 ,31.00,1,25.0%,25.0%,100.0%
285 Total,,4,100.0%,,
286 ])
287 AT_CLEANUP
288
289 m4_define([FREQUENCIES_NTILES_OUTPUT], [dnl
290 Table: Statistics
291 ,,x
292 N,Valid,5
293 ,Missing,0
294 Mean,,3.00
295 Std Dev,,1.58
296 Minimum,,1.00
297 Maximum,,5.00
298 Percentiles,0,1.00
299 ,25,2.00
300 ,33,2.33
301 ,50,3.00
302 ,67,3.67
303 ,75,4.00
304 ,100,5.00
305 ])
306 AT_SETUP([FREQUENCIES basic percentiles])
307 AT_DATA([frequencies.sps],
308   [DATA LIST LIST notable /x * .
309 BEGIN DATA.
310
311
312
313
314 5
315 END DATA.
316
317 FREQUENCIES 
318         VAR=x
319         /FORMAT=NOTABLE
320         /PERCENTILES = 0 25 33.333 50 66.666 75 100.
321 ])
322 AT_CHECK([pspp -O format=csv frequencies.sps], [0],
323   [FREQUENCIES_NTILES_OUTPUT])
324 AT_CLEANUP
325
326 AT_SETUP([FREQUENCIES basic n-tiles])
327 AT_DATA([frequencies.sps],
328   [DATA LIST LIST notable /x * .
329 BEGIN DATA.
330
331
332
333
334 5
335 END DATA.
336
337 FREQUENCIES 
338         VAR=x
339         /FORMAT=NOTABLE
340         /NTILES = 3
341         /NTILES = 4.
342 ])
343 AT_CHECK([pspp -O format=csv frequencies.sps], [0],
344   [FREQUENCIES_NTILES_OUTPUT])
345 AT_CLEANUP
346
347 AT_SETUP([FREQUENCIES compatibility percentiles])
348 AT_DATA([frequencies.sps],
349   [DATA LIST LIST notable /X * .
350 BEGIN DATA.
351
352
353
354
355 5
356 END DATA.
357
358 FREQUENCIES 
359         VAR=x
360         /ALGORITHM=COMPATIBLE
361         /PERCENTILES = 0 25 50 75 100.
362 ])
363 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
364 Table: Statistics
365 ,,X
366 N,Valid,5
367 ,Missing,0
368 Mean,,3.00
369 Std Dev,,1.58
370 Minimum,,1.00
371 Maximum,,5.00
372 Percentiles,0,1.00
373 ,25,1.50
374 ,50,3.00
375 ,75,4.50
376 ,100,5.00
377
378 Table: X
379 ,,Frequency,Percent,Valid Percent,Cumulative Percent
380 Valid,1.00,1,20.0%,20.0%,20.0%
381 ,2.00,1,20.0%,20.0%,40.0%
382 ,3.00,1,20.0%,20.0%,60.0%
383 ,4.00,1,20.0%,20.0%,80.0%
384 ,5.00,1,20.0%,20.0%,100.0%
385 Total,,5,100.0%,,
386 ])
387 AT_CLEANUP
388
389 AT_SETUP([FREQUENCIES enhanced percentiles])
390 AT_DATA([frequencies.sps],
391   [DATA LIST LIST notable /X * .
392 BEGIN DATA.
393
394
395
396
397 5
398 END DATA.
399
400 FREQUENCIES 
401         VAR=x
402         /PERCENTILES = 0 25 50 75 100.
403 ])
404 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
405 Table: Statistics
406 ,,X
407 N,Valid,5
408 ,Missing,0
409 Mean,,3.00
410 Std Dev,,1.58
411 Minimum,,1.00
412 Maximum,,5.00
413 Percentiles,0,1.00
414 ,25,2.00
415 ,50,3.00
416 ,75,4.00
417 ,100,5.00
418
419 Table: X
420 ,,Frequency,Percent,Valid Percent,Cumulative Percent
421 Valid,1.00,1,20.0%,20.0%,20.0%
422 ,2.00,1,20.0%,20.0%,40.0%
423 ,3.00,1,20.0%,20.0%,60.0%
424 ,4.00,1,20.0%,20.0%,80.0%
425 ,5.00,1,20.0%,20.0%,100.0%
426 Total,,5,100.0%,,
427 ])
428 AT_CLEANUP
429
430 AT_SETUP([FREQUENCIES enhanced percentiles, weighted])
431 AT_DATA([frequencies.sps],
432   [DATA LIST LIST notable /X * F *.
433 BEGIN DATA.
434 1 2
435 2 2
436 3 2
437 4 1
438 4 1
439 5 1
440 5 1
441 END DATA.
442
443 WEIGHT BY f.
444
445 FREQUENCIES 
446         VAR=x
447         /PERCENTILES = 0 25 50 75 100.
448 ])
449 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
450 Table: Statistics
451 ,,X
452 N,Valid,10.00
453 ,Missing,.00
454 Mean,,3.00
455 Std Dev,,1.49
456 Minimum,,1.00
457 Maximum,,5.00
458 Percentiles,0,1.00
459 ,25,2.00
460 ,50,3.00
461 ,75,4.00
462 ,100,5.00
463
464 Table: X
465 ,,Frequency,Percent,Valid Percent,Cumulative Percent
466 Valid,1.00,2.00,20.0%,20.0%,20.0%
467 ,2.00,2.00,20.0%,20.0%,40.0%
468 ,3.00,2.00,20.0%,20.0%,60.0%
469 ,4.00,2.00,20.0%,20.0%,80.0%
470 ,5.00,2.00,20.0%,20.0%,100.0%
471 Total,,10.00,100.0%,,
472 ])
473 AT_CLEANUP
474
475 AT_SETUP([FREQUENCIES enhanced percentiles, weighted (2)])
476 AT_DATA([frequencies.sps],
477   [DATA LIST LIST notable /X * F *.
478 BEGIN DATA.
479 1 1
480 3 2
481 4 1
482 5 1
483 5 1
484 END DATA.
485
486 WEIGHT BY f.
487
488 FREQUENCIES 
489         VAR=x
490         /PERCENTILES = 0 25 50 75 100.
491 ])
492 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
493 Table: Statistics
494 ,,X
495 N,Valid,6.00
496 ,Missing,.00
497 Mean,,3.50
498 Std Dev,,1.52
499 Minimum,,1.00
500 Maximum,,5.00
501 Percentiles,0,1.00
502 ,25,3.00
503 ,50,3.50
504 ,75,4.75
505 ,100,5.00
506
507 Table: X
508 ,,Frequency,Percent,Valid Percent,Cumulative Percent
509 Valid,1.00,1.00,16.7%,16.7%,16.7%
510 ,3.00,2.00,33.3%,33.3%,50.0%
511 ,4.00,1.00,16.7%,16.7%,66.7%
512 ,5.00,2.00,33.3%,33.3%,100.0%
513 Total,,6.00,100.0%,,
514 ])
515 AT_CLEANUP
516
517 dnl Data for this test case from Fabio Bordignon <bordignon@demos.it>.
518 AT_SETUP([FREQUENCIES enhanced percentiles, weighted (3)])
519 AT_DATA([frequencies.sps],
520   [DATA LIST LIST notable /X * F *.
521 BEGIN DATA.
522 1 7
523 2 16
524 3 12
525 4 5
526 END DATA.
527
528 WEIGHT BY f.
529
530 FREQUENCIES 
531         VAR=x
532         /PERCENTILES = 0 25 50 75 100.
533 ])
534 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
535 Table: Statistics
536 ,,X
537 N,Valid,40.00
538 ,Missing,.00
539 Mean,,2.38
540 Std Dev,,.93
541 Minimum,,1.00
542 Maximum,,4.00
543 Percentiles,0,1.00
544 ,25,2.00
545 ,50,2.00
546 ,75,3.00
547 ,100,4.00
548
549 Table: X
550 ,,Frequency,Percent,Valid Percent,Cumulative Percent
551 Valid,1.00,7.00,17.5%,17.5%,17.5%
552 ,2.00,16.00,40.0%,40.0%,57.5%
553 ,3.00,12.00,30.0%,30.0%,87.5%
554 ,4.00,5.00,12.5%,12.5%,100.0%
555 Total,,40.00,100.0%,,
556 ])
557 AT_CLEANUP
558
559 AT_SETUP([FREQUENCIES enhanced percentiles, weighted, missing values])
560 AT_DATA([frequencies.sps],
561   [DATA LIST LIST notable /X * F *.
562 BEGIN DATA.
563 1 1
564 3 2
565 4 1
566 5 1
567 5 1
568 99 4
569 END DATA.
570
571 MISSING VALUE x (99.0) .
572 WEIGHT BY f.
573
574 FREQUENCIES 
575         VAR=x
576         /PERCENTILES = 0 25 50 75 100.
577 ])
578
579 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
580 Table: Statistics
581 ,,X
582 N,Valid,6.00
583 ,Missing,4.00
584 Mean,,3.50
585 Std Dev,,1.52
586 Minimum,,1.00
587 Maximum,,5.00
588 Percentiles,0,1.00
589 ,25,3.00
590 ,50,3.50
591 ,75,4.75
592 ,100,5.00
593
594 Table: X
595 ,,Frequency,Percent,Valid Percent,Cumulative Percent
596 Valid,1.00,1.00,10.0%,16.7%,16.7%
597 ,3.00,2.00,20.0%,33.3%,50.0%
598 ,4.00,1.00,10.0%,16.7%,66.7%
599 ,5.00,2.00,20.0%,33.3%,100.0%
600 Missing,99.00,4.00,40.0%,,
601 Total,,10.00,100.0%,,
602 ])
603 AT_CLEANUP
604
605 AT_SETUP([FREQUENCIES dichotomous histogram])
606 AT_DATA([frequencies.sps], [dnl
607 data list notable list /d4 *.
608 begin data.
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626 end data.
627
628 FREQUENCIES
629         /VARIABLES = d4
630         /FORMAT=AVALUE TABLE
631         /HISTOGRAM=NORMAL
632         .
633 ])
634
635 AT_CHECK([pspp frequencies.sps], [0],  [ignore])
636 AT_CLEANUP
637
638
639 AT_SETUP([FREQUENCIES median])
640 AT_DATA([median.sps], [dnl
641 data list notable list /x *.
642 begin data.
643 1
644 2
645 3000000
646 end data.
647
648 FREQUENCIES
649         /VARIABLES = x
650         /STATISTICS = MEDIAN
651         .
652 ])
653
654 AT_CHECK([pspp median.sps -O format=csv], [0], [dnl
655 Table: Statistics
656 ,,x
657 N,Valid,3
658 ,Missing,0
659 Median,,2.00
660
661 Table: x
662 ,,Frequency,Percent,Valid Percent,Cumulative Percent
663 Valid,1.00,1,33.3%,33.3%,33.3%
664 ,2.00,1,33.3%,33.3%,66.7%
665 ,3000000,1,33.3%,33.3%,100.0%
666 Total,,3,100.0%,,
667 ])
668 AT_CLEANUP
669
670 AT_SETUP([FREQUENCIES variance])
671 AT_DATA([variance.sps], [dnl
672 data list notable list /forename (A12) height.
673 begin data.
674 Ahmed 188
675 bertram 167
676 Catherine 134
677 David 109
678 end data.
679
680 FREQUENCIES
681    /VARIABLES = height
682    /STATISTICS = VARIANCE.
683 ])
684
685 AT_CHECK([pspp variance.sps -O format=csv], [0], [dnl
686 Table: Statistics
687 ,,height
688 N,Valid,4
689 ,Missing,0
690 Variance,,1223.00
691
692 Table: height
693 ,,Frequency,Percent,Valid Percent,Cumulative Percent
694 Valid,109.00,1,25.0%,25.0%,25.0%
695 ,134.00,1,25.0%,25.0%,50.0%
696 ,167.00,1,25.0%,25.0%,75.0%
697 ,188.00,1,25.0%,25.0%,100.0%
698 Total,,4,100.0%,,
699 ])
700 AT_CLEANUP
701
702 AT_SETUP([FREQUENCIES default statistics])
703 AT_DATA([median.sps], [dnl
704 data list notable list /x *.
705 begin data.
706 10
707 20
708 3000000
709 end data.
710
711 FREQUENCIES
712         /VARIABLES = x
713         /STATISTICS
714         .
715
716 FREQUENCIES
717         /VARIABLES = x
718         /STATISTICS = DEFAULT
719         .
720 ])
721
722 AT_CHECK([pspp median.sps -o pspp.csv -o pspp.txt])
723 AT_CHECK([cat pspp.csv], [0], [dnl
724 Table: Statistics
725 ,,x
726 N,Valid,3
727 ,Missing,0
728 Mean,,1000010
729 Std Dev,,1732042
730 Minimum,,10.00
731 Maximum,,3000000
732
733 Table: x
734 ,,Frequency,Percent,Valid Percent,Cumulative Percent
735 Valid,10.00,1,33.3%,33.3%,33.3%
736 ,20.00,1,33.3%,33.3%,66.7%
737 ,3000000,1,33.3%,33.3%,100.0%
738 Total,,3,100.0%,,
739
740 Table: Statistics
741 ,,x
742 N,Valid,3
743 ,Missing,0
744 Mean,,1000010
745 Std Dev,,1732042
746 Minimum,,10.00
747 Maximum,,3000000
748
749 Table: x
750 ,,Frequency,Percent,Valid Percent,Cumulative Percent
751 Valid,10.00,1,33.3%,33.3%,33.3%
752 ,20.00,1,33.3%,33.3%,66.7%
753 ,3000000,1,33.3%,33.3%,100.0%
754 Total,,3,100.0%,,
755 ])
756 AT_CLEANUP
757
758
759
760 AT_SETUP([FREQUENCIES no valid data])
761 AT_DATA([empty.sps], [dnl
762 data list notable list /x *.
763 begin data.
764 .
765 .
766 .
767 end data.
768
769 FREQUENCIES
770         /VARIABLES = x
771         /STATISTICS = ALL
772         .
773 ])
774
775 AT_CHECK([pspp empty.sps -O format=csv], [0],  [dnl
776 Table: Statistics
777 ,,x
778 N,Valid,0
779 ,Missing,3
780 Mean,,.  @&t@
781 S.E. Mean,,.  @&t@
782 Median,,.  @&t@
783 Mode,,.  @&t@
784 Std Dev,,.  @&t@
785 Variance,,.  @&t@
786 Kurtosis,,.  @&t@
787 S.E. Kurt,,.  @&t@
788 Skewness,,.  @&t@
789 S.E. Skew,,.  @&t@
790 Range,,.  @&t@
791 Minimum,,.  @&t@
792 Maximum,,.  @&t@
793 Sum,,.  @&t@
794
795 Table: x
796 ,,Frequency,Percent,Valid Percent,Cumulative Percent
797 Missing,.  ,3,100.0%,,
798 Total,,3,.0%,,
799 ])
800
801 AT_CLEANUP
802
803
804 AT_SETUP([FREQUENCIES histogram no valid cases])
805 AT_DATA([empty.sps], [dnl
806 data list notable list /x w *.
807 begin data.
808 1 .
809 2 .
810 3 .
811 end data.
812
813 weight by w.
814
815 FREQUENCIES
816         /VARIABLES = x
817         /histogram
818         .
819 ])
820
821 AT_CHECK([pspp empty.sps -O format=csv], [0],  [ignore])
822
823 AT_CLEANUP
824
825 AT_SETUP([FREQUENCIES percentiles + histogram bug#48128])
826 AT_DATA([bug.sps], [dnl
827 SET FORMAT=F8.0.
828
829 INPUT PROGRAM.
830         LOOP I=1 TO 10.
831                 COMPUTE SCORE=EXP(NORMAL(1)).
832                 END CASE.
833         END LOOP.
834         END FILE.
835 END INPUT PROGRAM.
836
837 FREQUENCIES VARIABLES=SCORE
838 /FORMAT=NOTABLE
839 /STATISTICS=ALL
840 /PERCENTILES=1 10 20 30 40 50 60 70 80 90 99
841 /HISTOGRAM.
842
843 ])
844
845 AT_CHECK([pspp bug.sps], [0],  [ignore])
846
847 AT_CLEANUP
848
849
850 AT_SETUP([FREQUENCIES vs. missing weights])
851 AT_DATA([warn.sps], [dnl
852 data list notable list /x w .
853 begin data.
854 1 1
855 2 1
856 1 1
857 3 1
858 3 .
859 4 .
860 end data.
861
862 weight by w.
863
864 frequencies /variables=x.
865 ])
866
867 AT_CHECK([pspp warn.sps -O format=csv], [0],  [dnl
868 "warn.sps:13: warning: FREQUENCIES: 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."
869
870 Table: Statistics
871 ,,x
872 N,Valid,4.00
873 ,Missing,.00
874 Mean,,1.75
875 Std Dev,,.96
876 Minimum,,1.00
877 Maximum,,4.00
878
879 Table: x
880 ,,Frequency,Percent,Valid Percent,Cumulative Percent
881 Valid,1.00,2.00,50.0%,50.0%,50.0%
882 ,2.00,1.00,25.0%,25.0%,75.0%
883 ,3.00,1.00,25.0%,25.0%,100.0%
884 ,4.00,.00,.0%,.0%,100.0%
885 Total,,4.00,100.0%,,
886 ])
887
888 AT_CLEANUP