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([AGGREGATE procedure])
19 dnl CHECK_AGGREGATE(OUTFILE, SORT, MISSING)
21 dnl Checks the AGGREGATE procedure with the specified combination of:
23 dnl - OUTFILE: One of "dataset", "active", or "external" according to
24 dnl where AGGREGATE's output should be directed.
26 dnl - SORT: Either "presorted" or "unsorted" according to whether
27 dnl AGGREGATE should received presorted input.
29 dnl - MISSING: Either "itemwise" or "columnwise" according to the basis
30 dnl on which missing values should be eliminated.
32 m4_define([CHECK_AGGREGATE], [
33 AT_SETUP([AGGREGATE $2 data to $1 file, $3 missing])
34 AT_DATA([aggregate.data],
48 AT_DATA([aggregate.sps],
49 [DATA LIST NOTABLE FILE='aggregate.data' /G N 1-2 S 3(a) W 4.
51 MISSING VALUES n(4) s('4').
52 m4_if([$1], [dataset], [DATASET DECLARE aggregate.])
53 m4_if([$2], [presorted], [SORT CASES BY g.])
55 m4_if([$1], [active], [OUTFILE=*],
56 [$1], [external], [OUTFILE='aggregate.sys'],
57 [outfile=aggregate]) dnl
58 m4_if([$2], [presorted], [/PRESORTED]) dnl
59 m4_if([$3], [columnwise], [/MISSING=COLUMNWISE])
69 /SFGT2I = fgt.(s, '2')
70 /NFIN23 = fin(n, 2, 3)
71 /NFIN23I = fin.(n, 2, 3)
72 /SFIN23 = fin(s, '2', '3')
73 /SFIN23I = fin.(s, '2', '3')
77 /SFLT2I = flt.(s, '2')
82 /NFOUT23 = fout(n, 3, 2)
83 /NFOUT23I = fout.(n, 3, 2)
84 /SFOUT23 = fout(s, '3', '2')
85 /SFOUT23I = fout.(s, '3', '2')
113 /NNUMISSI = numiss.(n)
115 /SNUMISSI = numiss.(s)
119 /SPGT2I = pgt.(s, '2')
120 /NPIN23 = pin(n, 2, 3)
121 /NPIN23I = pin.(n, 2, 3)
122 /SPIN23 = pin(s, '2', '3')
123 /SPIN23I = pin.(s, '2', '3')
127 /SPLT2I = plt.(s, '2')
128 /NPOUT23 = pout(n, 2, 3)
129 /NPOUT23I = pout.(n, 2, 3)
130 /SPOUT23 = pout(s, '2', '3')
131 /SPOUT23I = pout.(s, '2', '3')
133 /NMEDIANI = median.(n)
138 m4_if([$1], [external], [GET FILE='aggregate.sys'.],
139 [$1], [dataset], [DATASET ACTIVATE aggregate.])
142 AT_CHECK([pspp -O format=csv aggregate.sps], [0],
143 [m4_if([$3], [itemwise], [dnl
144 "aggregate.sps:29.28-29.31: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
145 29 | /NFOUT23 = fout(n, 3, 2)
148 "aggregate.sps:30.30-30.33: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
149 30 | /NFOUT23I = fout.(n, 3, 2)
152 "aggregate.sps:31.28-31.35: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
153 31 | /SFOUT23 = fout(s, '3', '2')
156 "aggregate.sps:32.30-32.37: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
157 32 | /SFOUT23I = fout.(s, '3', '2')
161 G,N,NI,NU,NUI,NFGT2,NFGT2I,SFGT2,SFGT2I,NFIN23,NFIN23I,SFIN23,SFIN23I,NFLT2,NFLT2I,SFLT2,SFLT2I,NFIRST,NFIRSTI,SFIRST,SFIRSTI,NFOUT23,NFOUT23I,SFOUT23,SFOUT23I,NLAST,NLASTI,SLAST,SLASTI,NMAX,NMAXI,SMAX,SMAXI,NMEAN,NMEANI,NMIN,NMINI,SMIN,SMINI,NN,NNI,SN,SNI,NNMISS,NNMISSI,SNMISS,SNMISSI,NNU,NNUI,SNU,SNUI,NNUMISS,NNUMISSI,SNUMISS,SNUMISSI,NPGT2,NPGT2I,SPGT2,SPGT2I,NPIN23,NPIN23I,SPIN23,SPIN23I,NPLT2,NPLT2I,SPLT2,SPLT2I,NPOUT23,NPOUT23I,SPOUT23,SPOUT23I,NMEDIAN,NMEDIANI,NSD,NSDI,NSUM,NSUMI
162 1,7.00,7.00,6,6,.333,.429,.333,.429,.333,.286,.333,.286,.500,.429,.500,.429,0,0,0,0,.667,.714,.667,.714,5,5,5,5,5,5,5,5,2.00,2.29,0,0,0,0,6.00,7.00,6.00,7.00,1.00,.00,1.00,.00,5,6,5,6,1,0,1,0,33.3,42.9,33.3,42.9,33.3,28.6,33.3,28.6,50.0,42.9,50.0,42.9,66.7,71.4,66.7,71.4,1.50,2.00,1.79,1.80,12.00,16.00
163 2,5.00,5.00,4,4,1.000,1.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,6,6,6,4,1.000,1.000,1.000,1.000,8,8,8,8,8,8,8,8,7.00,7.00,6,6,6,4,3.00,3.00,3.00,5.00,2.00,2.00,2.00,.00,3,3,3,4,1,1,1,0,100.0,100.0,100.0,100.0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,7.00,7.00,1.00,1.00,21.00,21.00
164 3,2.00,2.00,1,1,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,1.000,1.000,1,1,1,1,1.000,1.000,1.000,1.000,1,1,1,1,1,1,1,1,1.00,1.00,1,1,1,1,2.00,2.00,2.00,2.00,.00,.00,.00,.00,1,1,1,1,0,0,0,0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,1.00,1.00,.00,.00,2.00,2.00
165 4,1.00,1.00,1,1,. ,. ,. ,1.000,. ,. ,. ,.000,. ,. ,. ,.000,.,.,,4,. ,. ,. ,1.000,.,.,,4,.,.,,4,. ,. ,.,.,,4,.00,.00,.00,1.00,1.00,1.00,1.00,.00,0,0,0,1,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,NaN,NaN,. ,. ,. ,. @&t@
168 "aggregate.sps:29.28-29.31: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
169 29 | /NFOUT23 = fout(n, 3, 2)
172 "aggregate.sps:30.30-30.33: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
173 30 | /NFOUT23I = fout.(n, 3, 2)
176 "aggregate.sps:31.28-31.35: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
177 31 | /SFOUT23 = fout(s, '3', '2')
180 "aggregate.sps:32.30-32.37: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order. They will be treated as if they had been specified in the correct order.
181 32 | /SFOUT23I = fout.(s, '3', '2')
185 G,N,NI,NU,NUI,NFGT2,NFGT2I,SFGT2,SFGT2I,NFIN23,NFIN23I,SFIN23,SFIN23I,NFLT2,NFLT2I,SFLT2,SFLT2I,NFIRST,NFIRSTI,SFIRST,SFIRSTI,NFOUT23,NFOUT23I,SFOUT23,SFOUT23I,NLAST,NLASTI,SLAST,SLASTI,NMAX,NMAXI,SMAX,SMAXI,NMEAN,NMEANI,NMIN,NMINI,SMIN,SMINI,NN,NNI,SN,SNI,NNMISS,NNMISSI,SNMISS,SNMISSI,NNU,NNUI,SNU,SNUI,NNUMISS,NNUMISSI,SNUMISS,SNUMISSI,NPGT2,NPGT2I,SPGT2,SPGT2I,NPIN23,NPIN23I,SPIN23,SPIN23I,NPLT2,NPLT2I,SPLT2,SPLT2I,NPOUT23,NPOUT23I,SPOUT23,SPOUT23I,NMEDIAN,NMEDIANI,NSD,NSDI,NSUM,NSUMI
186 1,7.00,7.00,6,6,. ,.429,. ,.429,. ,.286,. ,.286,. ,.429,. ,.429,.,0,,0,. ,.714,. ,.714,.,5,,5,.,5,,5,. ,2.29,.,0,,0,6.00,7.00,6.00,7.00,1.00,.00,1.00,.00,5,6,5,6,1,0,1,0,. ,42.9,. ,42.9,. ,28.6,. ,28.6,. ,42.9,. ,42.9,. ,71.4,. ,71.4,. ,2.00,. ,1.80,. ,16.00
187 2,5.00,5.00,4,4,. ,. ,. ,1.000,. ,. ,. ,.000,. ,. ,. ,.000,.,.,,4,. ,. ,. ,1.000,.,.,,8,.,.,,8,. ,. ,.,.,,4,3.00,3.00,3.00,5.00,2.00,2.00,2.00,.00,3,3,3,4,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,. ,. ,. ,. ,. ,. @&t@
188 3,2.00,2.00,1,1,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,1.000,1.000,1,1,1,1,1.000,1.000,1.000,1.000,1,1,1,1,1,1,1,1,1.00,1.00,1,1,1,1,2.00,2.00,2.00,2.00,.00,.00,.00,.00,1,1,1,1,0,0,0,0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,1.00,1.00,.00,.00,2.00,2.00
189 4,1.00,1.00,1,1,. ,. ,. ,1.000,. ,. ,. ,.000,. ,. ,. ,.000,.,.,,4,. ,. ,. ,1.000,.,.,,4,.,.,,4,. ,. ,.,.,,4,.00,.00,.00,1.00,1.00,1.00,1.00,.00,0,0,0,1,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,. ,. ,. ,. ,. ,. @&t@
193 CHECK_AGGREGATE([dataset], [presorted], [itemwise])
194 CHECK_AGGREGATE([dataset], [presorted], [columnwise])
195 CHECK_AGGREGATE([dataset], [unsorted], [itemwise])
196 CHECK_AGGREGATE([dataset], [unsorted], [columnwise])
197 CHECK_AGGREGATE([active], [presorted], [itemwise])
198 CHECK_AGGREGATE([active], [presorted], [columnwise])
199 CHECK_AGGREGATE([active], [unsorted], [itemwise])
200 CHECK_AGGREGATE([active], [unsorted], [columnwise])
201 CHECK_AGGREGATE([external], [presorted], [itemwise])
202 CHECK_AGGREGATE([external], [presorted], [columnwise])
203 CHECK_AGGREGATE([external], [unsorted], [itemwise])
204 CHECK_AGGREGATE([external], [unsorted], [columnwise])
206 AT_SETUP([AGGREGATE crash with MAX function])
207 AT_DATA([aggregate.sps],
208 [DATA LIST LIST /X (F8.2) Y (a25).
216 AGGREGATE OUTFILE=* /BREAK=y /X=MAX(x).
219 AT_CHECK([pspp -O format=csv aggregate.sps], [0],
220 [Table: Reading free-form data from INLINE.
232 AT_SETUP([AGGREGATE crash with invalid syntax])
233 AT_DATA([aggregate.sps],
236 COMPUTE x=UNIFORM(10)
244 AT_CHECK([pspp -O format=csv aggregate.sps], [1], [ignore], [])
248 AT_SETUP([AGGREGATE mode=addvariables])
249 AT_DATA([addvariables.sps],
250 [data list notable list /x * cn * y *.
262 aggregate outfile=* mode=addvariables
266 /median = median (y).
271 AT_CHECK([pspp -O format=csv addvariables.sps], [0],
273 x,cn,y,sum,mean,median
274 1.00,1.00,2.00,2.00,2.00,2.00
275 3.00,2.00,3.00,7.00,3.50,3.50
276 3.00,3.00,4.00,7.00,3.50,3.50
277 5.00,4.00,6.00,6.00,6.00,6.00
278 7.00,5.00,8.00,37.00,12.33,9.00
279 7.00,6.00,9.00,37.00,12.33,9.00
280 7.00,7.00,20.00,37.00,12.33,9.00
281 9.00,8.00,11.00,11.00,11.00,11.00
287 AT_SETUP([AGGREGATE buggy duplicate variables])
288 dnl Test for a bug which crashed when duplicated
289 dnl variables were attempted.
290 AT_DATA([dup-variables.sps],
291 [DATA LIST NOTABLE LIST /x * .
308 AGGREGATE OUTFILE=* MODE=ADDVARIABLES
312 AGGREGATE OUTFILE=* MODE=ADDVARIABLES
317 AT_CHECK([pspp -O format=csv dup-variables.sps], [1],
318 ["dup-variables.sps:24: error: AGGREGATE: Variable name N_BREAK is not unique within the aggregate file dictionary, which contains the aggregate variables and the break variables."