1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
17 AT_BANNER([FREQUENCIES procedure])
19 AT_SETUP([FREQUENCIES string variable])
20 AT_DATA([frequencies.sps],
22 name (A8) value * quantity .
37 FREQUENCIES /VAR = name/ORDER=ANALYSIS.
39 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
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.
62 frequencies v1 v2/statistics=none/ORDER=VARIABLE.
63 frequencies v1 v2/statistics=none.
65 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
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%
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%
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%
100 # Test that the LIMIT specification works.
101 AT_SETUP([FREQUENCIES with LIMIT])
102 AT_DATA([frequencies.sps],
103 [data list free /v1 v2.
111 frequencies v1 v2/statistics=none/FORMAT=LIMIT(3).
113 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
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.
137 frequencies v1/statistics=none.
139 AT_CHECK([pspp -o - -O format=csv -o pspp.html frequencies.sps], [0],
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%
155 AT_CHECK([test -s pspp.html])
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 *.
179 frequencies /x /format=notable /statistics=none
182 # Cannot use the CSV driver for this because it does not output charts
184 AT_CHECK([pspp frequencies.sps], [0], [dnl
185 Reading free-form data from INLINE.
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 *.
218 /histogram=minimum(0) maximum(50) percent(5) normal.
220 # Cannot use the CSV driver for this because it does not output charts
222 AT_CHECK([pspp -O format=pdf frequencies.sps], [0], [ignore])
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.
234 frequencies /x /histogram /STATISTICS=median.
236 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [ignore])
237 dnl Ignore output - No crash test.
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 *.
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.
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%
289 m4_define([FREQUENCIES_NTILES_OUTPUT], [dnl
306 AT_SETUP([FREQUENCIES basic percentiles])
307 AT_DATA([frequencies.sps],
308 [DATA LIST LIST notable /x * .
320 /PERCENTILES = 0 25 33.333 50 66.666 75 100.
322 AT_CHECK([pspp -O format=csv frequencies.sps], [0],
323 [FREQUENCIES_NTILES_OUTPUT])
326 AT_SETUP([FREQUENCIES basic n-tiles])
327 AT_DATA([frequencies.sps],
328 [DATA LIST LIST notable /x * .
343 AT_CHECK([pspp -O format=csv frequencies.sps], [0],
344 [FREQUENCIES_NTILES_OUTPUT])
347 AT_SETUP([FREQUENCIES compatibility percentiles])
348 AT_DATA([frequencies.sps],
349 [DATA LIST LIST notable /X * .
360 /ALGORITHM=COMPATIBLE
361 /PERCENTILES = 0 25 50 75 100.
363 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
389 AT_SETUP([FREQUENCIES enhanced percentiles])
390 AT_DATA([frequencies.sps],
391 [DATA LIST LIST notable /X * .
402 /PERCENTILES = 0 25 50 75 100.
404 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
430 AT_SETUP([FREQUENCIES enhanced percentiles, weighted])
431 AT_DATA([frequencies.sps],
432 [DATA LIST LIST notable /X * F *.
447 /PERCENTILES = 0 25 50 75 100.
449 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%,,
475 AT_SETUP([FREQUENCIES enhanced percentiles, weighted (2)])
476 AT_DATA([frequencies.sps],
477 [DATA LIST LIST notable /X * F *.
490 /PERCENTILES = 0 25 50 75 100.
492 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%
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 *.
532 /PERCENTILES = 0 25 50 75 100.
534 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%,,
559 AT_SETUP([FREQUENCIES enhanced percentiles, weighted, missing values])
560 AT_DATA([frequencies.sps],
561 [DATA LIST LIST notable /X * F *.
571 MISSING VALUE x (99.0) .
576 /PERCENTILES = 0 25 50 75 100.
579 AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl
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%,,
605 AT_SETUP([FREQUENCIES dichotomous histogram])
606 AT_DATA([frequencies.sps], [dnl
607 data list notable list /d4 *.
635 AT_CHECK([pspp frequencies.sps], [0], [ignore])
639 AT_SETUP([FREQUENCIES median])
640 AT_DATA([median.sps], [dnl
641 data list notable list /x *.
654 AT_CHECK([pspp median.sps -O format=csv], [0], [dnl
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%
670 AT_SETUP([FREQUENCIES variance])
671 AT_DATA([variance.sps], [dnl
672 data list notable list /forename (A12) height.
682 /STATISTICS = VARIANCE.
685 AT_CHECK([pspp variance.sps -O format=csv], [0], [dnl
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%
702 AT_SETUP([FREQUENCIES default statistics])
703 AT_DATA([median.sps], [dnl
704 data list notable list /x *.
718 /STATISTICS = DEFAULT
722 AT_CHECK([pspp median.sps -o pspp.csv -o pspp.txt])
723 AT_CHECK([cat pspp.csv], [0], [dnl
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%
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%
760 AT_SETUP([FREQUENCIES no valid data])
761 AT_DATA([empty.sps], [dnl
762 data list notable list /x *.
775 AT_CHECK([pspp empty.sps -O format=csv], [0], [dnl
796 ,,Frequency,Percent,Valid Percent,Cumulative Percent
797 Missing,. ,3,100.0%,,
804 AT_SETUP([FREQUENCIES histogram no valid cases])
805 AT_DATA([empty.sps], [dnl
806 data list notable list /x w *.
821 AT_CHECK([pspp empty.sps -O format=csv], [0], [ignore])
825 AT_SETUP([FREQUENCIES percentiles + histogram bug#48128])
826 AT_DATA([bug.sps], [dnl
831 COMPUTE SCORE=EXP(NORMAL(1)).
837 FREQUENCIES VARIABLES=SCORE
840 /PERCENTILES=1 10 20 30 40 50 60 70 80 90 99
845 AT_CHECK([pspp bug.sps], [0], [ignore])
850 AT_SETUP([FREQUENCIES vs. missing weights])
851 AT_DATA([warn.sps], [dnl
852 data list notable list /x w .
864 frequencies /variables=x.
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."
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%