sys-file: Add functions for converting between codepage numbers and names.
[pspp-builds.git] / tests / language / stats / crosstabs.at
1 AT_BANNER([CROSSTABS procedure])
2
3 AT_SETUP([CROSSTABS integer mode crash])
4 AT_DATA([crosstabs.sps],
5   [DATA LIST LIST /A * B * X * Y * .
6 BEGIN DATA.
7 2 3 4 5
8 END DATA.
9
10 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
11 ])
12 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], 
13   [[Table: Reading free-form data from INLINE.
14 Variable,Format
15 A,F8.0
16 B,F8.0
17 X,F8.0
18 Y,F8.0
19
20 Table: Summary.
21 ,Cases,,,,,
22 ,Valid,,Missing,,Total,
23 ,N,Percent,N,Percent,N,Percent
24 X * Y,1,100.0%,0,0.0%,1,100.0%
25
26 Table: X * Y [count].
27 ,Y,,,,,,,
28 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
29 1.00,.0,.0,.0,.0,.0,.0,.0,.0
30 2.00,.0,.0,.0,.0,.0,.0,.0,.0
31 3.00,.0,.0,.0,.0,.0,.0,.0,.0
32 4.00,.0,.0,.0,.0,1.0,.0,.0,1.0
33 5.00,.0,.0,.0,.0,.0,.0,.0,.0
34 6.00,.0,.0,.0,.0,.0,.0,.0,.0
35 7.00,.0,.0,.0,.0,.0,.0,.0,.0
36 Total,.0,.0,.0,.0,1.0,.0,.0,1.0
37 ]])
38 AT_CLEANUP
39
40 # Bug #22037.
41 AT_SETUP([CROSSTABS long string crash])
42 AT_DATA([crosstabs.sps],
43   [data list list /x * y (a18).
44
45 begin data.
46
47    1. 'zero none'
48
49 1 'one unity'
50 2 'two duality'
51 3 'three lots'
52 end data.
53
54 CROSSTABS /TABLES = x BY y.
55 ])
56 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
57   [[Table: Reading free-form data from INLINE.
58 Variable,Format
59 x,F8.0
60 y,A18
61
62 "crosstabs.sps:4: warning: BEGIN DATA: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
63
64 "crosstabs.sps:6: warning: BEGIN DATA: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
65
66 Table: Summary.
67 ,Cases,,,,,
68 ,Valid,,Missing,,Total,
69 ,N,Percent,N,Percent,N,Percent
70 x * y,4,66.7%,2,33.3%,6,100.0%
71
72 Table: x * y [count].
73 ,y,,,,
74 x,one unity         ,three lots        ,two duality       ,zero none         ,Total
75 1.00,1.0,.0,.0,1.0,2.0
76 2.00,.0,.0,1.0,.0,1.0
77 3.00,.0,1.0,.0,.0,1.0
78 Total,1.0,1.0,1.0,1.0,4.0
79 ]])
80 AT_CLEANUP
81
82 AT_SETUP([CROSSTABS crash])
83 AT_DATA([crosstabs.sps],
84   [[DATA LIST FIXED
85      / x   1-2
86        y   3
87        z   4.
88
89 BEGIN DATA.
90 0111 
91 0222 
92 0311 
93 0412 
94 0521 
95 0612 
96 0711 
97 0811 
98 0912 
99 END DATA.
100
101 LIST.
102
103
104 CROSSTABS TABLES  y by z.
105 ]])
106 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
107   [[Table: Reading 1 record from INLINE.
108 Variable,Record,Columns,Format
109 x,1,1-  2,F2.0
110 y,1,3-  3,F1.0
111 z,1,4-  4,F1.0
112
113 Table: Data List
114 x,y,z
115 1,1,1
116 2,2,2
117 3,1,1
118 4,1,2
119 5,2,1
120 6,1,2
121 7,1,1
122 8,1,1
123 9,1,2
124
125 Table: Summary.
126 ,Cases,,,,,
127 ,Valid,,Missing,,Total,
128 ,N,Percent,N,Percent,N,Percent
129 y * z,9,100.0%,0,0.0%,9,100.0%
130
131 Table: y * z [count].
132 ,z,,
133 y,1,2,Total
134 1,4.0,3.0,7.0
135 2,1.0,1.0,2.0
136 Total,5.0,4.0,9.0
137 ]])
138 AT_CLEANUP
139
140 # Bug #26739, which caused CROSSTABS to crash or to fail to output
141 # chi-square results.
142 AT_SETUP([CROSSTABS chi-square crash])
143 AT_DATA([crosstabs.sps],
144   [[DATA LIST LIST /x * y *.
145 BEGIN DATA.
146 2 2
147 3 1
148 4 2
149 4 1
150 END DATA.
151
152 CROSSTABS
153         /TABLES= x BY y
154         /STATISTICS=CHISQ.
155 ]])
156 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
157   [[Table: Reading free-form data from INLINE.
158 Variable,Format
159 x,F8.0
160 y,F8.0
161
162 Table: Summary.
163 ,Cases,,,,,
164 ,Valid,,Missing,,Total,
165 ,N,Percent,N,Percent,N,Percent
166 x * y,4,100.0%,0,0.0%,4,100.0%
167
168 Table: x * y [count].
169 ,y,,
170 x,1.00,2.00,Total
171 2.00,.0,1.0,1.0
172 3.00,1.0,.0,1.0
173 4.00,1.0,1.0,2.0
174 Total,2.0,2.0,4.0
175
176 Table: Chi-square tests.
177 Statistic,Value,df,Asymp. Sig. (2-tailed)
178 Pearson Chi-Square,2.00,2,.37
179 Likelihood Ratio,2.77,2,.25
180 Linear-by-Linear Association,.27,1,.60
181 N of Valid Cases,4,,
182 ]])
183 AT_CLEANUP
184
185 # Bug #27883.
186 AT_SETUP([CROSSTABS crash with SPLIT FILE])
187 AT_DATA([crosstabs.sps],
188   [data list notable / v0 to v2 1-6 (A)
189 begin data.
190 a c e
191 a c e
192 a c e
193 a d e
194 a d f
195 b d f
196 b d f
197 b c f
198 b d e
199 a c f
200 end data.
201 SORT CASES BY v0.
202 SPLIT FILE SEPARATE BY v0.
203
204 CROSSTABS
205     /TABLES= v1 BY v2
206     /FORMAT=AVALUE LABELS TABLES PIVOT
207     /STATISTICS=CHISQ
208     /CELLS=COUNT ROW COLUMN TOTAL.
209 ])
210 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
211   [[Variable,Value,Label
212 v0,a ,
213
214 Table: Summary.
215 ,Cases,,,,,
216 ,Valid,,Missing,,Total,
217 ,N,Percent,N,Percent,N,Percent
218 v1 * v2,6,100.0%,0,0.0%,6,100.0%
219
220 "Table: v1 * v2 [count, row %, column %, total %]."
221 ,v2,,
222 v1,e ,f ,Total
223 c ,3.0,1.0,4.0
224 ,75.0%,25.0%,100.0%
225 ,75.0%,50.0%,66.7%
226 ,50.0%,16.7%,66.7%
227 d ,1.0,1.0,2.0
228 ,50.0%,50.0%,100.0%
229 ,25.0%,50.0%,33.3%
230 ,16.7%,16.7%,33.3%
231 Total,4.0,2.0,6.0
232 ,66.7%,33.3%,100.0%
233 ,100.0%,100.0%,100.0%
234 ,66.7%,33.3%,100.0%
235
236 Table: Chi-square tests.
237 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
238 Pearson Chi-Square,.38,1,.54,,
239 Likelihood Ratio,.37,1,.54,,
240 Fisher's Exact Test,,,,1.00,.60
241 Continuity Correction,.00,1,1.00,,
242 N of Valid Cases,6,,,,
243
244 Variable,Value,Label
245 v0,b ,
246
247 Table: Summary.
248 ,Cases,,,,,
249 ,Valid,,Missing,,Total,
250 ,N,Percent,N,Percent,N,Percent
251 v1 * v2,4,100.0%,0,0.0%,4,100.0%
252
253 "Table: v1 * v2 [count, row %, column %, total %]."
254 ,v2,,
255 v1,e ,f ,Total
256 c ,.0,1.0,1.0
257 ,.0%,100.0%,100.0%
258 ,.0%,33.3%,25.0%
259 ,.0%,25.0%,25.0%
260 d ,1.0,2.0,3.0
261 ,33.3%,66.7%,100.0%
262 ,100.0%,66.7%,75.0%
263 ,25.0%,50.0%,75.0%
264 Total,1.0,3.0,4.0
265 ,25.0%,75.0%,100.0%
266 ,100.0%,100.0%,100.0%
267 ,25.0%,75.0%,100.0%
268
269 Table: Chi-square tests.
270 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
271 Pearson Chi-Square,.44,1,.50,,
272 Likelihood Ratio,.68,1,.41,,
273 Fisher's Exact Test,,,,1.00,.75
274 Continuity Correction,.00,1,1.00,,
275 N of Valid Cases,4,,,,
276 ]])
277 AT_CLEANUP
278
279 # Bug #24752.
280 AT_SETUP([3-way CROSSTABS])
281 AT_DATA([crosstabs.sps],
282   [[DATA LIST FIXED
283      / x   1-2
284        y   3
285        z   4.
286
287 BEGIN DATA.
288 0111 
289 0222 
290 0311 
291 0412 
292 0521 
293 0612 
294 0711 
295 0811 
296 0912 
297 END DATA.
298
299 LIST.
300
301
302 CROSSTABS TABLES  x by y by z.
303 ]])
304 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
305   [[Table: Reading 1 record from INLINE.
306 Variable,Record,Columns,Format
307 x,1,1-  2,F2.0
308 y,1,3-  3,F1.0
309 z,1,4-  4,F1.0
310
311 Table: Data List
312 x,y,z
313 1,1,1
314 2,2,2
315 3,1,1
316 4,1,2
317 5,2,1
318 6,1,2
319 7,1,1
320 8,1,1
321 9,1,2
322
323 Table: Summary.
324 ,Cases,,,,,
325 ,Valid,,Missing,,Total,
326 ,N,Percent,N,Percent,N,Percent
327 x * y * z,9,100.0%,0,0.0%,9,100.0%
328
329 Table: x * y * z [count].
330 z,,y,,
331 ,x,1,2,Total
332 1,1,1.0,.0,1.0
333 ,3,1.0,.0,1.0
334 ,5,.0,1.0,1.0
335 ,7,1.0,.0,1.0
336 ,8,1.0,.0,1.0
337 Total,,4.0,1.0,5.0
338 2,2,.0,1.0,1.0
339 ,4,1.0,.0,1.0
340 ,6,1.0,.0,1.0
341 ,9,1.0,.0,1.0
342 Total,,3.0,1.0,4.0
343 ]])
344 AT_CLEANUP
345
346
347
348 AT_SETUP([CROSSTABS descending sort order])
349 AT_DATA([crosstabs-descending.sps],
350   [[DATA LIST NOTABLE LIST /x * y *.
351 BEGIN DATA.
352 2 2
353 2 2
354 3 1
355 4 1
356 3 2
357 3 2
358 END DATA.
359
360 CROSSTABS
361         /TABLES= x BY y
362         /FORMAT = DVALUE.
363 ]])
364
365 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
366   [[Table: Summary.
367 ,Cases,,,,,
368 ,Valid,,Missing,,Total,
369 ,N,Percent,N,Percent,N,Percent
370 x * y,6,100.0%,0,0.0%,6,100.0%
371
372 Table: x * y [count].
373 ,y,,
374 x,2.00,1.00,Total
375 4.00,.0,1.0,1.0
376 3.00,2.0,1.0,3.0
377 2.00,2.0,.0,2.0
378 Total,4.0,2.0,6.0
379 ]])
380 AT_CLEANUP
381
382 # Bug #31260.
383 AT_SETUP([CROSSTABS crash when all cases missing])
384 AT_DATA([crosstabs.sps], [dnl
385 DATA LIST LIST NOTABLE /X1 X2.
386 BEGIN DATA.
387 1 1
388 END DATA.
389
390 MISSING VALUES x2 (1).
391
392 CROSSTABS /TABLES= X1 by X2.
393 ])
394 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
395 Table: Summary.
396 ,Cases,,,,,
397 ,Valid,,Missing,,Total,
398 ,N,Percent,N,Percent,N,Percent
399 X1 * X2,0,0.0%,1,100.0%,1,100.0%
400
401 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
402 ])
403 AT_CLEANUP