1 AT_BANNER([AGGREGATE procedure])
3 dnl CHECK_AGGREGATE(OUTFILE, SORT, MISSING)
5 dnl Checks the AGGREGATE procedure with the specified combination of:
7 dnl - OUTFILE: One of "scratch", "active", or "external" according to
8 dnl where AGGREGATE's output should be directed.
10 dnl - SORT: Either "presorted" or "unsorted" according to whether
11 dnl AGGREGATE should received presorted input.
13 dnl - MISSING: Either "itemwise" or "columnwise" according to the basis
14 dnl on which missing values should be eliminated.
16 m4_define([CHECK_AGGREGATE], [
17 AT_SETUP([AGGREGATE $2 data to $1 file, $3 missing])
18 AT_DATA([aggregate.data],
32 AT_DATA([aggregate.sps],
33 [DATA LIST NOTABLE FILE='aggregate.data' /G N 1-2 S 3(a) W 4.
35 MISSING VALUES n(4) s('4').
36 m4_if([$2], [presorted], [SORT CASES BY g.])
38 m4_if([$1], [active], [OUTFILE=*],
39 [$1], [external], [OUTFILE='aggregate.sys'],
40 [outfile=@%:@AGGREGATE]) dnl
41 m4_if([$2], [presorted], [/PRESORTED]) dnl
42 m4_if([$3], [columnwise], [/MISSING=COLUMNWISE])
52 /SFGT2I = fgt.(s, '2')
53 /NFIN23 = fin(n, 2, 3)
54 /NFIN23I = fin.(n, 2, 3)
55 /SFIN23 = fin(s, '2', '3')
56 /SFIN23I = fin.(s, '2', '3')
60 /SFLT2I = flt.(s, '2')
65 /NFOUT23 = fout(n, 3, 2)
66 /NFOUT23I = fout.(n, 3, 2)
67 /SFOUT23 = fout(s, '3', '2')
68 /SFOUT23I = fout.(s, '3', '2')
96 /NNUMISSI = numiss.(n)
98 /SNUMISSI = numiss.(s)
102 /SPGT2I = pgt.(s, '2')
103 /NPIN23 = pin(n, 2, 3)
104 /NPIN23I = pin.(n, 2, 3)
105 /SPIN23 = pin(s, '2', '3')
106 /SPIN23I = pin.(s, '2', '3')
110 /SPLT2I = plt.(s, '2')
111 /NPOUT23 = pout(n, 2, 3)
112 /NPOUT23I = pout.(n, 2, 3)
113 /SPOUT23 = pout(s, '2', '3')
114 /SPOUT23I = pout.(s, '2', '3')
116 /NMEDIANI = median.(n)
121 m4_if([$1], [external], [GET FILE='aggregate.sys'.],
122 [$1], [scratch], [GET FILE=@%:@AGGREGATE.])
125 AT_CHECK([pspp -O format=csv aggregate.sps], [0], [stdout])
126 AT_CHECK([[sed 's/^[^:]*:[0-9]*: //' < stdout]], [0],
127 [m4_if([$3], [itemwise],
128 [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.
130 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.
132 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.
134 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.
137 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
138 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
139 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
140 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
141 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@
143 [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 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.
147 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 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.
152 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
153 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
154 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@
155 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
156 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@
160 CHECK_AGGREGATE([scratch], [presorted], [itemwise])
161 CHECK_AGGREGATE([scratch], [presorted], [columnwise])
162 CHECK_AGGREGATE([scratch], [unsorted], [itemwise])
163 CHECK_AGGREGATE([scratch], [unsorted], [columnwise])
164 CHECK_AGGREGATE([active], [presorted], [itemwise])
165 CHECK_AGGREGATE([active], [presorted], [columnwise])
166 CHECK_AGGREGATE([active], [unsorted], [itemwise])
167 CHECK_AGGREGATE([active], [unsorted], [columnwise])
168 CHECK_AGGREGATE([external], [presorted], [itemwise])
169 CHECK_AGGREGATE([external], [presorted], [columnwise])
170 CHECK_AGGREGATE([external], [unsorted], [itemwise])
171 CHECK_AGGREGATE([external], [unsorted], [columnwise])
173 AT_SETUP([AGGREGATE crash with MAX function])
174 AT_DATA([aggregate.sps],
175 [DATA LIST LIST /X (F8.2) Y (a25).
183 AGGREGATE OUTFILE=* /BREAK=y /X=MAX(x).
186 AT_CHECK([pspp -O format=csv aggregate.sps], [0],
187 [Table: Reading free-form data from INLINE.
199 AT_SETUP([AGGREGATE crash with invalid syntax])
200 AT_DATA([aggregate.sps],
203 COMPUTE x=UNIFORM(10)
211 AT_CHECK([pspp -O format=csv aggregate.sps], [1], [ignore], [])
215 AT_SETUP([AGGREGATE mode=addvariables])
216 AT_DATA([addvariables.sps],
217 [data list notable list /x * cn * y *.
229 aggregate outfile=* mode=addvariables
233 /median = median (y).
238 AT_CHECK([pspp -O format=csv addvariables.sps], [0],
240 x,cn,y,sum,mean,median
241 1.00,1.00,2.00,2.00,2.00,2.00
242 3.00,2.00,3.00,7.00,3.50,3.50
243 3.00,3.00,4.00,7.00,3.50,3.50
244 5.00,4.00,6.00,6.00,6.00,6.00
245 7.00,5.00,8.00,37.00,12.33,9.00
246 7.00,6.00,9.00,37.00,12.33,9.00
247 7.00,7.00,20.00,37.00,12.33,9.00
248 9.00,8.00,11.00,11.00,11.00,11.00
254 AT_SETUP([AGGREGATE buggy duplicate variables])
255 dnl Test for a bug which crashed when duplicated
256 dnl variables were attempted.
257 AT_DATA([dup-variables.sps],
258 [DATA LIST NOTABLE LIST /x * .
275 AGGREGATE OUTFILE=* MODE=ADDVARIABLES
279 AGGREGATE OUTFILE=* MODE=ADDVARIABLES
284 AT_CHECK([pspp -O format=csv dup-variables.sps], [1],
285 ["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."
287 dup-variables.sps:24: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.