432da3deb4df29a3fbce98c8c85423edf35cfe63
[pspp] / tests / language / stats / ctables.at
1 AT_BANNER([CTABLES])
2
3 dnl Features not yet tested:
4 dnl - Preprocessing to distinguish categorical from scale.
5 dnl - Testing details of missing value handling in summaries.
6 dnl - Test WEIGHT and adjustment weights.
7 dnl - Summary functions:
8 dnl   * Separate summary functions for totals and subtotals.
9 dnl   * )CILEVEL in summary label specification
10 dnl - CATEGORIES:
11 dnl   * Date values
12 dnl   * THRU (numeric ranges)
13 dnl   * OTHERNM
14 dnl - Date/time variables and values
15 dnl - Test PCOMPUTE:
16 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
17 dnl   * MISSING, OTHERNM
18 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
19 dnl   * dates
20 dnl - Summary functions:
21 dnl   * U-prefix for unweighted summaries.
22 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
23 dnl - SPLIT FILE with SEPARATE splits
24 dnl - Definition of columns/rows when labels are rotated from one axis to another.
25 dnl
26 dnl Not for v1:
27 dnl - Multiple response sets
28 dnl - MRSETS subcommand.
29 dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
30 dnl - SIGTEST
31 dnl - COMPARETEST
32 dnl - Summary functions:
33 dnl   * .LCL and .UCL suffixes.
34 dnl   * .SE suffixes.
35 dnl - CATEGORIES:
36 dnl   * Data-dependent sorting.
37
38 AT_SETUP([CTABLES parsing])
39 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
40 AT_DATA([ctables.sps],
41 [[GET 'nhtsa.sav'.
42 CTABLES
43     /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
44     /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
45     /FORMAT UNITS=CM EMPTY="(-)"
46     /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
47     /VLABELS VARIABLES=qn17 DISPLAY=NAME
48     /VLABELS VARIABLES=qns3a DISPLAY=LABEL
49     /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
50     /VLABELS VARIABLES=qn20 DISPLAY=NONE
51     /MRSETS COUNTDUPLICATES=NO
52     /MRSETS COUNTDUPLICATES=YES
53     /SMISSING VARIABLE
54     /SMISSING LISTWISE
55     /WEIGHT VARIABLE=qns3a
56     /HIDESMALLCOUNTS
57     /HIDESMALLCOUNTS COUNT=10
58     /TABLE qnsa1
59     /SLABELS POSITION=COLUMN VISIBLE=YES
60     /SLABELS VISIBLE=NO POSITION=ROW
61     /SLABELS POSITION=LAYER
62     /CLABELS AUTO
63     /CLABELS ROWLABELS=OPPOSITE
64     /CRITERIA CILEVEL=50
65     /CATEGORIES VARIABLES=qn1 qn17
66                 ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
67                 POSITION=BEFORE EMPTY=INCLUDE.
68 CTABLES /TABLE qnsa1 /CLABELS ROWLABELS=LAYER.
69 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=OPPOSITE.
70 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=LAYER.
71 ]])
72 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
73          Custom Tables
74 Count
75 ╭───────────────────┬────┬────╮
76 │                   │ RDD│CELL│
77 ├───────────────────┼────┼────┤
78 │Sa1. SAMPLE SOURCE:│5392│1607│
79 ╰───────────────────┴────┴────╯
80
81        Custom Tables
82 RDD
83 ╭───────────────────┬─────╮
84 │                   │Count│
85 ├───────────────────┼─────┤
86 │Sa1. SAMPLE SOURCE:│ 5392│
87 ╰───────────────────┴─────╯
88
89           Custom Tables
90 ╭────────────────────────┬─────╮
91 │                        │Count│
92 ├────────────────────────┼─────┤
93 │Sa1. SAMPLE SOURCE: RDD │ 5392│
94 │                    CELL│ 1607│
95 ╰────────────────────────┴─────╯
96
97           Custom Tables
98 ╭────────────────────────┬─────╮
99 │                        │Count│
100 ├────────────────────────┼─────┤
101 │Sa1. SAMPLE SOURCE: RDD │ 5392│
102 │                    CELL│ 1607│
103 ╰────────────────────────┴─────╯
104 ])
105 AT_CLEANUP
106
107 AT_SETUP([CTABLES parsing - negative])
108 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
109 AT_DATA([ctables.sps],
110 [[GET 'nhtsa.sav'.
111 CTABLES.
112 CTABLES /FORMAT MINCOLWIDTH='foo'.
113 CTABLES /TABLE qn1 [**].
114 CTABLES /TABLE qn1 [NOTAFUNCTION].
115 CTABLES /TABLE (qn1.
116 CTABLES /TABLE **.
117 CTABLES /TABLE NOTAVAR.
118 STRING string(A8).
119 CTABLES /TABLE string[S].
120 CTABLES /TABLE qn1 [PTILE 101].
121 CTABLES /TABLE qn1 [MEAN F0.1].
122 CTABLES /TABLE qn1 [MEAN NEGPAREN1.2].
123 CTABLES /TABLE qn1 [MEAN NEGPAREN3.4].
124 CTABLES /TABLE qn1 [MEAN TOTALS].
125 CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
126 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [SUBTOTAL=x].
127 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO **].
128 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO THRU x].
129 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1 THRU **].
130 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['x' THRU **].
131 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&**].
132 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
133 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 101).
134 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1.
135 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN.
136 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 MISSING=**.
137 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 TOTAL=**.
138 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 LABEL=**.
139 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 POSITION=**.
140 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 EMPTY=**.
141 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 **.
142 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1,2,3] **.
143 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[0]).
144 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[1**]).
145 CTABLES /PCOMPUTE &k=EXPR([LO **]).
146 CTABLES /PCOMPUTE &k=EXPR([LO THRU **]).
147 CTABLES /PCOMPUTE &k=EXPR([1 THRU **]).
148 CTABLES /PCOMPUTE &k=EXPR([1**]).
149 CTABLES /PCOMPUTE &k=EXPR((1x)).
150 CTABLES /PCOMPUTE **k.
151 CTABLES /PCOMPUTE &1.
152 CTABLES /PCOMPUTE &k**.
153 CTABLES /PCOMPUTE &k=**.
154 CTABLES /PCOMPUTE &k=EXPR**.
155 CTABLES /PCOMPUTE &k=EXPR(1x).
156 CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
157 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=NOTAFUNCTION.
158 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=PTILE **.
159 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k LABEL=**.
160 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k HIDESOURCECATS=**.
161 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k **.
162 CTABLES /FORMAT EMPTY=**.
163 CTABLES /FORMAT MISSING=**.
164 CTABLES /FORMAT **.
165 CTABLES /FORMAT MINCOLWIDTH=20 MAXCOLWIDTH=10/.
166 CTABLES /VLABELS **.
167 CTABLES /VLABELS VARIABLES=NOTAVAR.
168 CTABLES /VLABELS VARIABLES=qn1 **.
169 CTABLES /VLABELS VARIABLES=qn1 DISPLAY=**.
170 CTABLES /MRSETS **.
171 CTABLES /MRSETS COUNTDUPLICATES=**.
172 CTABLES /SMISSING **.
173 CTABLES /WEIGHT **.
174 CTABLES /WEIGHT VARIABLE=NOTAVAR.
175 CTABLES /HIDESMALLCOUNTS COUNT=1.
176 CTABLES /QUUX.
177 CTABLES /HIDESMALLCOUNTS COUNT=2.
178 CTABLES /TABLE qn1**.
179 CTABLES /TABLE qn1 /SLABELS POSITION=**.
180 CTABLES /TABLE qn1 /SLABELS VISIBLE=**.
181 CTABLES /TABLE qn1 /SLABELS **.
182 CTABLES /TABLE qn1 /CLABELS ROWLABELS=**.
183 CTABLES /TABLE qn1 /CLABELS COLLABELS=**.
184 CTABLES /TABLE qn1 /CLABELS **.
185 CTABLES /TABLE qn1 /CRITERIA **.
186 CTABLES /TABLE qn1 /CRITERIA CILEVEL=101.
187 CTABLES /TABLE qn1 /TITLES **.
188 CTABLES /TABLE qn1 /SIGTEST TYPE=**.
189 CTABLES /TABLE qn1 /SIGTEST ALPHA=**.
190 CTABLES /TABLE qn1 /SIGTEST INCLUDEMRSETS=**.
191 CTABLES /TABLE qn1 /SIGTEST CATEGORIES=**.
192 CTABLES /TABLE qn1 /SIGTEST **.
193 CTABLES /TABLE qn1 /COMPARETEST TYPE=**.
194 CTABLES /TABLE qn1 /COMPARETEST ALPHA=**.
195 CTABLES /TABLE qn1 /COMPARETEST ALPHA=0,5.
196 CTABLES /TABLE qn1 /COMPARETEST ADJUST=**.
197 CTABLES /TABLE qn1 /COMPARETEST INCLUDEMRSETS=**.
198 CTABLES /TABLE qn1 /COMPARETEST MEANSVARIANCE=**.
199 CTABLES /TABLE qn1 /COMPARETEST CATEGORIES=**.
200 CTABLES /TABLE qn1 /COMPARETEST MERGE=**.
201 CTABLES /TABLE qn1 /COMPARETEST STYLE=**.
202 CTABLES /TABLE qn1 /COMPARETEST SHOWSIG=**.
203 CTABLES /TABLE qn1 /COMPARETEST **.
204 CTABLES /TABLE qn1 / **.
205 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CLABELS COLLABELS=OPPOSITE.
206 CTABLES /TABLE qn20 > qnd1.
207 CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
208 NUMERIC datetime (DATETIME17.0).
209 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
210 ]])
211 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
212 [[ctables.sps:2.8: error: CTABLES: Syntax error at end of command: expecting `/'.
213
214 ctables.sps:3.29-3.33: error: CTABLES: Syntax error at `'foo'': Expected non-
215 negative number for MINCOLWIDTH.
216
217 ctables.sps:4.21-4.22: error: CTABLES: Syntax error at `**': expecting
218 identifier.
219
220 ctables.sps:5.21-5.32: error: CTABLES: Syntax error at `NOTAFUNCTION': Expecting
221 summary function name.
222
223 ctables.sps:6.20: error: CTABLES: Syntax error at end of command: expecting `@:}@'.
224
225 ctables.sps:7.16-7.17: error: CTABLES: Syntax error at `**': expecting
226 identifier.
227
228 ctables.sps:8: error: CTABLES: NOTAVAR is not a variable name.
229
230 ctables.sps:10.16-10.24: error: CTABLES: Cannot use string variable string as a
231 scale variable.
232    10 | CTABLES /TABLE string[S].
233       |                ^~~~~~~~~
234
235 ctables.sps:11.27-11.29: error: CTABLES: Syntax error at `101': Expected number
236 between 0 and 100 for PTILE.
237
238 ctables.sps:12: error: CTABLES: Output format F0.1 specifies width 0, but F
239 requires a width between 1 and 40.
240
241 ctables.sps:13.26-13.36: error: CTABLES: Syntax error at `NEGPAREN1.2': Output
242 format NEGPAREN requires width 2 or greater.
243
244 ctables.sps:14.26-14.36: error: CTABLES: Syntax error at `NEGPAREN3.4': Output
245 format NEGPAREN requires width greater than decimals.
246
247 ctables.sps:15.21-15.24: error: CTABLES: Summary function MEAN applies only to
248 scale variables.
249    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
250       |                     ^~~~
251
252 ctables.sps:15.16-15.18: note: CTABLES: 'QN1' is not a scale variable.
253    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
254       |                ^~~
255
256 ctables.sps:15.32: error: CTABLES: Syntax error at `@:>@': expecting `@<:@'.
257
258 ctables.sps:16.21-16.24: error: CTABLES: Summary function MEAN applies only to
259 scale variables.
260    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
261       |                     ^~~~
262
263 ctables.sps:16.16-16.18: note: CTABLES: 'QN1' is not a scale variable.
264    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
265       |                ^~~
266
267 ctables.sps:16.40: error: CTABLES: Syntax error at `%': expecting `@:>@'.
268
269 ctables.sps:17.56: error: CTABLES: Syntax error at `x': expecting string.
270
271 ctables.sps:18.50-18.51: error: CTABLES: Syntax error at `**': expecting THRU.
272
273 ctables.sps:19.55: error: CTABLES: Syntax error at `x': expecting number.
274
275 ctables.sps:20.54-20.55: error: CTABLES: Syntax error at `**': expecting number.
276
277 ctables.sps:21.56-21.57: error: CTABLES: Syntax error at `**': expecting string.
278
279 ctables.sps:22.48-22.49: error: CTABLES: Syntax error at `**': expecting
280 identifier.
281
282 ctables.sps:23.47-23.48: error: CTABLES: Unknown postcompute &x.
283    23 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
284       |                                               ^~
285
286 ctables.sps:24.61-24.63: error: CTABLES: Syntax error at `101': Expected number
287 between 0 and 100 for PTILE.
288
289 ctables.sps:25.58: error: CTABLES: Syntax error at end of command: expecting
290 `@:}@'.
291
292 ctables.sps:26.54: error: CTABLES: Syntax error at end of command: expecting
293 `@{:@'.
294
295 ctables.sps:27.54-27.55: error: CTABLES: Syntax error at `**': expecting INCLUDE
296 or EXCLUDE.
297
298 ctables.sps:28.52-28.53: error: CTABLES: Syntax error at `**': expecting YES or
299 NO.
300
301 ctables.sps:29.52-29.53: error: CTABLES: Syntax error at `**': expecting string.
302
303 ctables.sps:30.55-30.56: error: CTABLES: Syntax error at `**': expecting BEFORE
304 or AFTER.
305
306 ctables.sps:31.52-31.53: error: CTABLES: Syntax error at `**': expecting INCLUDE
307 or EXCLUDE.
308
309 ctables.sps:32.46-32.47: error: CTABLES: Syntax error at `**': expecting ORDER,
310 KEY, MISSING, TOTAL, LABEL, POSITION, or EMPTY.
311
312 ctables.sps:33.54-33.55: error: CTABLES: Syntax error at `**': expecting TOTAL,
313 LABEL, POSITION, or EMPTY.
314
315 ctables.sps:34.36: error: CTABLES: Syntax error at `0': Expected positive
316 integer for SUBTOTAL.
317
318 ctables.sps:35.37-35.38: error: CTABLES: Syntax error at `**': expecting `@:>@'.
319
320 ctables.sps:36.31-36.32: error: CTABLES: Syntax error at `**': expecting THRU.
321
322 ctables.sps:37.36-37.37: error: CTABLES: Syntax error at `**': expecting number.
323
324 ctables.sps:38.35-38.36: error: CTABLES: Syntax error at `**': expecting number.
325
326 ctables.sps:39.29-39.30: error: CTABLES: Syntax error at `**': expecting `@:>@'.
327
328 ctables.sps:40.29: error: CTABLES: Syntax error at `x': expecting `@:}@'.
329
330 ctables.sps:41.19-41.20: error: CTABLES: Syntax error at `**': expecting &.
331
332 ctables.sps:42.20: error: CTABLES: Syntax error at `1': expecting identifier.
333
334 ctables.sps:43.21-43.22: error: CTABLES: Syntax error at `**': expecting `='.
335
336 ctables.sps:44.22-44.23: error: CTABLES: Syntax error at `**': expecting EXPR.
337
338 ctables.sps:45.26-45.27: error: CTABLES: Syntax error at `**': expecting `('.
339
340 ctables.sps:46.28: error: CTABLES: Syntax error at `x': expecting `)'.
341
342 ctables.sps:47.31-47.49: warning: CTABLES: New definition of &k will override
343 the previous definition.
344    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
345       |                               ^~~~~~~~~~~~~~~~~~~
346
347 ctables.sps:47.10-47.28: note: CTABLES: This is the previous definition.
348    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
349       |          ^~~~~~~~~~~~~~~~~~~
350
351 ctables.sps:47.50: error: CTABLES: Syntax error at end of command: expecting
352 `/'.
353
354 ctables.sps:48.53-48.64: error: CTABLES: Syntax error at `NOTAFUNCTION':
355 Expecting summary function name.
356
357 ctables.sps:49.59-49.60: error: CTABLES: Syntax error at `**': Expected number
358 between 0 and 100 for PTILE.
359
360 ctables.sps:50.52-50.53: error: CTABLES: Syntax error at `**': expecting string.
361
362 ctables.sps:51.61-51.62: error: CTABLES: Syntax error at `**': expecting YES or
363 NO.
364
365 ctables.sps:52.46-52.47: error: CTABLES: Syntax error at `**': expecting LABEL,
366 FORMAT, or HIDESOURCECATS.
367
368 ctables.sps:53.23-53.24: error: CTABLES: Syntax error at `**': expecting string.
369
370 ctables.sps:54.25-54.26: error: CTABLES: Syntax error at `**': expecting string.
371
372 ctables.sps:55.17-55.18: error: CTABLES: Syntax error at `**': expecting
373 MINCOLWIDTH, MAXCOLWIDTH, UNITS, EMPTY, or MISSING.
374
375 ctables.sps:56: error: CTABLES: MINCOLWIDTH must not be greater than
376 MAXCOLWIDTH.
377
378 ctables.sps:57.18-57.19: error: CTABLES: Syntax error at `**': expecting
379 VARIABLES.
380
381 ctables.sps:58: error: CTABLES: NOTAVAR is not a variable name.
382
383 ctables.sps:59.32-59.33: error: CTABLES: Syntax error at `**': expecting
384 DISPLAY.
385
386 ctables.sps:60.40-60.41: error: CTABLES: Syntax error at `**': expecting
387 DEFAULT, NAME, LABEL, BOTH, or NONE.
388
389 ctables.sps:61.17-61.18: error: CTABLES: Syntax error at `**': expecting
390 COUNTDUPLICATES.
391
392 ctables.sps:62.33-62.34: error: CTABLES: Syntax error at `**': expecting YES or
393 NO.
394
395 ctables.sps:63.19-63.20: error: CTABLES: Syntax error at `**': expecting
396 VARIABLE or LISTWISE.
397
398 ctables.sps:64.17-64.18: error: CTABLES: Syntax error at `**': expecting
399 VARIABLE.
400
401 ctables.sps:65: error: CTABLES: NOTAVAR is not a variable name.
402
403 ctables.sps:66.32: error: CTABLES: Syntax error at `1': Expected integer 2 or
404 greater for HIDESMALLCOUNTS COUNT.
405
406 ctables.sps:67.10-67.13: error: CTABLES: Syntax error at `QUUX': expecting
407 FORMAT, VLABELS, MRSETS, SMISSING, PCOMPUTE, PPROPERTIES, WEIGHT,
408 HIDESMALLCOUNTS, or TABLE.
409
410 ctables.sps:68.33: error: CTABLES: Syntax error at end of command: expecting
411 `/'.
412
413 ctables.sps:69.19-69.20: error: CTABLES: Syntax error at `**': expecting `/'.
414
415 ctables.sps:70.38-70.39: error: CTABLES: Syntax error at `**': expecting COLUMN,
416 ROW, or LAYER.
417
418 ctables.sps:71.37-71.38: error: CTABLES: Syntax error at `**': expecting YES or
419 NO.
420
421 ctables.sps:72.29-72.30: error: CTABLES: Syntax error at `**': expecting
422 POSITION or VISIBLE.
423
424 ctables.sps:73.39-73.40: error: CTABLES: Syntax error at `**': expecting
425 OPPOSITE or LAYER.
426
427 ctables.sps:74.39-74.40: error: CTABLES: Syntax error at `**': expecting
428 OPPOSITE or LAYER.
429
430 ctables.sps:75.29-75.30: error: CTABLES: Syntax error at `**': expecting AUTO,
431 ROWLABELS, or COLLABELS.
432
433 ctables.sps:76.30-76.31: error: CTABLES: Syntax error at `**': expecting
434 CILEVEL.
435
436 ctables.sps:77.38-77.40: error: CTABLES: Syntax error at `101': Expected number
437 in @<:@0,100@:}@ for CILEVEL.
438
439 ctables.sps:78.28-78.29: error: CTABLES: Syntax error at `**': expecting
440 CAPTION, CORNER, or TITLE.
441
442 ctables.sps:79.34-79.35: error: CTABLES: Syntax error at `**': expecting
443 CHISQUARE.
444
445 ctables.sps:80.35-80.36: error: CTABLES: Syntax error at `**': Expected number
446 in @<:@0,1@:}@ for ALPHA.
447
448 ctables.sps:81.43-81.44: error: CTABLES: Syntax error at `**': expecting YES or
449 NO.
450
451 ctables.sps:82.40-82.41: error: CTABLES: Syntax error at `**': expecting
452 ALLVISIBLE or SUBTOTALS.
453
454 ctables.sps:83.29-83.30: error: CTABLES: Syntax error at `**': expecting TYPE,
455 ALPHA, INCLUDEMRSETS, or CATEGORIES.
456
457 ctables.sps:84.38-84.39: error: CTABLES: Syntax error at `**': expecting PROP or
458 MEAN.
459
460 ctables.sps:85.39-85.40: error: CTABLES: Syntax error at `**': Expected number
461 in (0,1) for ALPHA.
462
463 ctables.sps:86.39: error: CTABLES: Syntax error at `0': Expected number in (0,1)
464 for ALPHA.
465
466 ctables.sps:87.40-87.41: error: CTABLES: Syntax error at `**': expecting
467 BONFERRONI, BH, or NONE.
468
469 ctables.sps:88.47-88.48: error: CTABLES: Syntax error at `**': expecting YES or
470 NO.
471
472 ctables.sps:89.47-89.48: error: CTABLES: Syntax error at `**': expecting ALLCATS
473 or TESTEDCATS.
474
475 ctables.sps:90.44-90.45: error: CTABLES: Syntax error at `**': expecting
476 ALLVISIBLE or SUBTOTALS.
477
478 ctables.sps:91.39-91.40: error: CTABLES: Syntax error at `**': expecting YES or
479 NO.
480
481 ctables.sps:92.39-92.40: error: CTABLES: Syntax error at `**': expecting APA or
482 SIMPLE.
483
484 ctables.sps:93.41-93.42: error: CTABLES: Syntax error at `**': expecting YES or
485 NO.
486
487 ctables.sps:94.33-94.34: error: CTABLES: Syntax error at `**': expecting TYPE,
488 ALPHA, ADJUST, INCLUDEMRSETS, MEANSVARIANCE, CATEGORIES, MERGE, STYLE, or
489 SHOWSIG.
490
491 ctables.sps:95.22-95.23: error: CTABLES: Syntax error at `**': expecting TABLE,
492 SLABELS, CLABELS, CRITERIA, CATEGORIES, TITLES, SIGTEST, or COMPARETEST.
493
494 ctables.sps:96: error: CTABLES: ROWLABELS and COLLABELS may not both be
495 specified.
496
497 ctables.sps:97.16-97.26: error: CTABLES: Cannot nest scale variables.
498    97 | CTABLES /TABLE qn20 > qnd1.
499       |                ^~~~~~~~~~~
500
501 ctables.sps:97.16-97.19: note: CTABLES: This is an outer scale variable.
502    97 | CTABLES /TABLE qn20 > qnd1.
503       |                ^~~~
504
505 ctables.sps:97.23-97.26: note: CTABLES: This is an inner scale variable.
506    97 | CTABLES /TABLE qn20 > qnd1.
507       |                       ^~~~
508
509 ctables.sps:98.16-98.35: error: CTABLES: Summaries may only be requested for
510 categorical variables at the innermost nesting level.
511    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
512       |                ^~~~~~~~~~~~~~~~~~~~
513
514 ctables.sps:98.16-98.18: note: CTABLES: This outer categorical variable has a
515 summary.
516    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
517       |                ^~~
518
519 ctables.sps:100.52-100.56: error: CTABLES: Failed to parse category
520 specification as format DATETIME: Day (123) must be between 1 and 31..
521   100 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
522       |                                                    ^~~~~
523 ]])
524 AT_CLEANUP
525
526 AT_SETUP([CTABLES parsing - more negative])
527 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
528 AT_DATA([ctables.sps],
529 [[GET 'nhtsa.sav'.
530 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
531 CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
532 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
533
534 STRING string(A8).
535 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
536 CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
537
538 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1).
539
540 CTABLES /TABLE qnd1 /CLABELS ROWLABELS=OPPOSITE.
541 CTABLES /TABLE qn1 + string /CLABELS ROWLABELS=OPPOSITE.
542 CTABLES /TABLE qn1 + qnsa1 /CLABELS ROWLABELS=OPPOSITE.
543 CTABLES /TABLE qn105ba + qn105bb /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn105ba [1,2,3].
544
545 CTABLES /PCOMPUTE &x=EXPR(1**2**3).
546 CTABLES /PCOMPUTE &x=EXPR([**]).
547 CTABLES /PCOMPUTE &x=EXPR(**).
548
549 CTABLES /TABLE.
550
551 CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. 
552 ]])
553 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
554 [[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a
555 category not included in the category list.
556     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
557 VARIABLES=qn1 [&pc].
558       |
559 ^~~
560
561 ctables.sps:2.28-2.35: note: CTABLES: This is the missing category.
562     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
563 VARIABLES=qn1 [&pc].
564       |                            ^~~~~~~~
565
566 ctables.sps:2.76-2.79: note: CTABLES: To fix the problem, add subtotals to the
567 list of categories here.
568     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
569 VARIABLES=qn1 [&pc].
570       |
571 ^~~~
572
573 ctables.sps:3.73-3.75: error: CTABLES: Computed category &pc references a
574 category not included in the category list.
575     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
576 [&pc].
577       |
578 ^~~
579
580 ctables.sps:3.28-3.32: note: CTABLES: This is the missing category.
581     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
582 [&pc].
583       |                            ^~~~~
584
585 ctables.sps:3: note: CTABLES: To fix the problem, add TOTAL=YES to the
586 variable's CATEGORIES specification.
587
588 ctables.sps:4.76-4.99: error: CTABLES: These categories include 2 instances of
589 SUBTOTAL or HSUBTOTAL, so references from computed categories must refer to
590 subtotals by position, e.g. SUBTOTAL[1].
591     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
592 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
593       |
594 ^~~~~~~~~~~~~~~~~~~~~~~~
595
596 ctables.sps:4.28-4.35: note: CTABLES: This is the reference that lacks a
597 position.
598     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
599 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
600       |                            ^~~~~~~~
601
602 ctables.sps:7.47-7.54: error: CTABLES: This category specification may be
603 applied only to string variables, but this subcommand tries to apply it to
604 numeric variable QN1.
605     7 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
606       |                                               ^~~~~~~~
607
608 ctables.sps:8.53: error: CTABLES: This category specification may be applied
609 only to numeric variables, but this subcommand tries to apply it to string
610 variable string.
611     8 | CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
612       |                                                     ^
613
614 ctables.sps:10: error: CTABLES: ROWLABELS=OPPOSITE is not allowed with sorting
615 based on a summary function.
616
617 ctables.sps:12: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
618 moved to be categorical, but qnd1 is a scale variable.
619
620 ctables.sps:13: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
621 moved to have the same width, but QN1 has width 0 and string has width 8.
622
623 ctables.sps:14: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
624 moved to have the same value labels, but QN1 and QNSA1 have different value
625 labels.
626
627 ctables.sps:15: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
628 moved to have the same category specifications, but QN105BA and QN105BB have
629 different category specifications.
630
631 ctables.sps:17.27-17.33: warning: CTABLES: The exponentiation operator (`**') is
632 left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'.  To disable
633 this warning, insert parentheses.
634    17 | CTABLES /PCOMPUTE &x=EXPR(1**2**3).
635       |                           ^~~~~~~
636
637 ctables.sps:17.35: error: CTABLES: Syntax error at end of command: expecting
638 `/'.
639
640 ctables.sps:18.28-18.29: error: CTABLES: Syntax error at `**'.
641
642 ctables.sps:19.27-19.28: error: CTABLES: Syntax error at `**'.
643
644 ctables.sps:21.15: error: CTABLES: Syntax error at end of command: At least one
645 variable must be specified.
646
647 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
648
649 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
650 summary.
651    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
652       |                                                  ^~~~~
653
654 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
655 summary.
656    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
657       |                ^~~~~
658
659 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
660 summary.
661    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
662       |                                 ^~~~~
663
664 ctables.sps:23.33-23.37: note: CTABLES: This is a scale variable, so it always
665 has a summary even if the syntax does not explicitly specify one.
666    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
667       |                                 ^~~~~
668 ]])
669 AT_CLEANUP
670
671 AT_SETUP([CTABLES one categorical variable])
672 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
673 AT_DATA([ctables.sps],
674 [[GET 'nhtsa.sav'.
675 CTABLES /TABLE qn1.
676 CTABLES /TABLE BY qn1.
677 CTABLES /TABLE BY BY qn1.
678 ]])
679 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
680                                   Custom Tables
681 ╭────────────────────────────────────────────────────────────────────────┬─────╮
682 │                                                                        │Count│
683 ├────────────────────────────────────────────────────────────────────────┼─────┤
684 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
685 │motor vehicle?                                     Several days a week  │ 1274│
686 │                                                   Once a week or less  │  361│
687 │                                                   Only certain times a │  130│
688 │                                                   year                 │     │
689 │                                                   Never                │  540│
690 ╰────────────────────────────────────────────────────────────────────────┴─────╯
691
692                                   Custom Tables
693 ╭──────────────────────────────────────────────────────────────────────────────╮
694 │        1. How often do you usually drive a car or other motor vehicle?       │
695 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
696 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
697 │Every day│       week       │       less       │          year          │Never│
698 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
699 │  Count  │       Count      │       Count      │          Count         │Count│
700 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
701 │     4667│              1274│               361│                     130│  540│
702 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
703
704 Custom Tables
705 Every day
706 ╭─────╮
707 │Count│
708 ├─────┤
709 │ 4667│
710 ╰─────╯
711 ])
712 AT_CLEANUP
713
714 AT_SETUP([CTABLES one string variable])
715 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
716 AT_DATA([ctables.sps],
717 [[GET 'nhtsa.sav'.
718 STRING licensed(A8).
719 MISSING VALUES licensed('DontKnow', 'Refused').
720 RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
721 CTABLES /TABLE licensed.
722 CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
723 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
724 * Notice that the string matching is case-sensitive.
725 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
726 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
727 CTABLES
728     /PCOMPUTE &notyes=EXPR(['No']+['DontKnow']+['Refused'])
729     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
730     /TABLE licensed
731     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'No', 'DontKnow', 'Refused'].
732 CTABLES
733     /PCOMPUTE &notyes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
734     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
735     /TABLE licensed
736     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'DontKnow' THRU 'No', 'Refused'].
737 ]])
738 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
739     Custom Tables
740 ╭────────────┬─────╮
741 │            │Count│
742 ├────────────┼─────┤
743 │licensed No │  572│
744 │         Yes│ 6379│
745 ╰────────────┴─────╯
746
747           Custom Tables
748 ╭─────────────────┬─────┬───────╮
749 │                 │Count│Valid N│
750 ├─────────────────┼─────┼───────┤
751 │licensed DontKnow│    4│       │
752 │         No      │  572│       │
753 │         Refused │   44│       │
754 │         Yes     │ 6379│       │
755 │         Total   │ 6999│   6951│
756 ╰─────────────────┴─────┴───────╯
757
758      Custom Tables
759 ╭──────────────┬─────╮
760 │              │Count│
761 ├──────────────┼─────┤
762 │licensed Yes  │ 6379│
763 │         No   │  572│
764 │         Total│ 6951│
765 ╰──────────────┴─────╯
766
767      Custom Tables
768 ╭──────────────┬─────╮
769 │              │Count│
770 ├──────────────┼─────┤
771 │licensed Yes  │ 6379│
772 │         no   │    0│
773 │         Total│ 6379│
774 ╰──────────────┴─────╯
775
776       Custom Tables
777 ╭────────────────┬─────╮
778 │                │Count│
779 ├────────────────┼─────┤
780 │licensed No     │  572│
781 │         Refused│   44│
782 │         Yes    │ 6379│
783 │         Total  │ 6995│
784 ╰────────────────┴─────╯
785
786       Custom Tables
787 ╭────────────────┬─────╮
788 │                │Count│
789 ├────────────────┼─────┤
790 │licensed Yes    │ 6379│
791 │         Not Yes│  620│
792 ╰────────────────┴─────╯
793
794       Custom Tables
795 ╭────────────────┬─────╮
796 │                │Count│
797 ├────────────────┼─────┤
798 │licensed Yes    │ 6379│
799 │         Not Yes│  620│
800 ╰────────────────┴─────╯
801 ])
802 AT_CLEANUP
803
804 AT_SETUP([CTABLES one scale variable])
805 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
806 AT_DATA([ctables.sps],
807 [[GET 'nhtsa.sav'.
808 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
809 CTABLES /TABLE BY qnd1.
810 CTABLES /TABLE BY BY qnd1.
811 ]])
812 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
813                                   Custom Tables
814 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
815 │                      │     │       │       │    │     Std    │       │       │
816 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
817 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
818 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
819 │age?                  │     │       │       │    │            │       │       │
820 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
821
822         Custom Tables
823 ╭──────────────────────────╮
824 │D1. AGE: What is your age?│
825 ├──────────────────────────┤
826 │           Mean           │
827 ├──────────────────────────┤
828 │                        48│
829 ╰──────────────────────────╯
830
831 Custom Tables
832 D1. AGE: What is your age?
833 ╭────╮
834 │Mean│
835 ├────┤
836 │  48│
837 ╰────╯
838 ])
839 AT_CLEANUP
840
841 AT_SETUP([CTABLES simple stacking])
842 AT_KEYWORDS([stack stacked])
843 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
844 AT_DATA([ctables.sps],
845 [[GET 'nhtsa.sav'.
846 CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
847 ]])
848 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
849                                   Custom Tables
850 ╭───────────────────────────────────────────────────────────────┬──────────────╮
851 │                                                               │ S3a. GENDER: │
852 │                                                               ├──────┬───────┤
853 │                                                               │ Male │ Female│
854 │                                                               ├──────┼───────┤
855 │                                                               │Column│ Column│
856 │                                                               │   %  │   %   │
857 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
858 │105b. How likely is it that drivers who have had   Almost      │   10%│    11%│
859 │too much to drink to drive safely will A. Get      certain     │      │       │
860 │stopped by the police?                             Very likely │   21%│    22%│
861 │                                                   Somewhat    │   38%│    42%│
862 │                                                   likely      │      │       │
863 │                                                   Somewhat    │   21%│    18%│
864 │                                                   unlikely    │      │       │
865 │                                                   Very        │   10%│     8%│
866 │                                                   unlikely    │      │       │
867 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
868 │105b. How likely is it that drivers who have had   Almost      │   14%│    18%│
869 │too much to drink to drive safely will B. Have an  certain     │      │       │
870 │accident?                                          Very likely │   36%│    45%│
871 │                                                   Somewhat    │   39%│    32%│
872 │                                                   likely      │      │       │
873 │                                                   Somewhat    │    9%│     4%│
874 │                                                   unlikely    │      │       │
875 │                                                   Very        │    3%│     2%│
876 │                                                   unlikely    │      │       │
877 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
878 │105b. How likely is it that drivers who have had   Almost      │   18%│    16%│
879 │too much to drink to drive safely will C. Be       certain     │      │       │
880 │convicted for drunk driving?                       Very likely │   32%│    28%│
881 │                                                   Somewhat    │   27%│    32%│
882 │                                                   likely      │      │       │
883 │                                                   Somewhat    │   15%│    15%│
884 │                                                   unlikely    │      │       │
885 │                                                   Very        │    9%│     9%│
886 │                                                   unlikely    │      │       │
887 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
888 │105b. How likely is it that drivers who have had   Almost      │   16%│    16%│
889 │too much to drink to drive safely will D. Be       certain     │      │       │
890 │arrested for drunk driving?                        Very likely │   26%│    27%│
891 │                                                   Somewhat    │   32%│    35%│
892 │                                                   likely      │      │       │
893 │                                                   Somewhat    │   17%│    15%│
894 │                                                   unlikely    │      │       │
895 │                                                   Very        │    9%│     7%│
896 │                                                   unlikely    │      │       │
897 ╰───────────────────────────────────────────────────────────────┴──────┴───────╯
898 ])
899 AT_CLEANUP
900
901 AT_SETUP([CTABLES show or hide empty categories])
902 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
903 AT_DATA([ctables.sps],
904 [[GET 'nhtsa.sav'.
905 IF (qn105ba = 2) qn105ba = 1.
906 IF (qns3a = 1) qns3a = 2.
907 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
908 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
909     /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
910 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
911     /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
912 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
913     /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
914 ]])
915 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
916                                   Custom Tables
917 ╭──────────────────────────────────────────────────────────────┬───────────────╮
918 │                                                              │  S3a. GENDER: │
919 │                                                              ├───────┬───────┤
920 │                                                              │  Male │ Female│
921 │                                                              ├───────┼───────┤
922 │                                                              │ Column│ Column│
923 │                                                              │   %   │   %   │
924 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
925 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
926 │too much to drink to drive safely will A. Get      certain    │       │       │
927 │stopped by the police?                             Very likely│      .│     0%│
928 │                                                   Somewhat   │      .│    40%│
929 │                                                   likely     │       │       │
930 │                                                   Somewhat   │      .│    19%│
931 │                                                   unlikely   │       │       │
932 │                                                   Very       │      .│     9%│
933 │                                                   unlikely   │       │       │
934 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
935
936                                   Custom Tables
937 ╭──────────────────────────────────────────────────────────────┬───────────────╮
938 │                                                              │  S3a. GENDER: │
939 │                                                              ├───────┬───────┤
940 │                                                              │  Male │ Female│
941 │                                                              ├───────┼───────┤
942 │                                                              │ Column│ Column│
943 │                                                              │   %   │   %   │
944 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
945 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
946 │too much to drink to drive safely will A. Get      certain    │       │       │
947 │stopped by the police?                             Somewhat   │      .│    40%│
948 │                                                   likely     │       │       │
949 │                                                   Somewhat   │      .│    19%│
950 │                                                   unlikely   │       │       │
951 │                                                   Very       │      .│     9%│
952 │                                                   unlikely   │       │       │
953 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
954
955                                   Custom Tables
956 ╭────────────────────────────────────────────────────────────────────┬─────────╮
957 │                                                                    │   S3a.  │
958 │                                                                    │ GENDER: │
959 │                                                                    ├─────────┤
960 │                                                                    │  Female │
961 │                                                                    ├─────────┤
962 │                                                                    │ Column %│
963 ├────────────────────────────────────────────────────────────────────┼─────────┤
964 │105b. How likely is it that drivers who have had too    Almost      │      32%│
965 │much to drink to drive safely will A. Get stopped by    certain     │         │
966 │the police?                                             Very likely │       0%│
967 │                                                        Somewhat    │      40%│
968 │                                                        likely      │         │
969 │                                                        Somewhat    │      19%│
970 │                                                        unlikely    │         │
971 │                                                        Very        │       9%│
972 │                                                        unlikely    │         │
973 ╰────────────────────────────────────────────────────────────────────┴─────────╯
974
975                                   Custom Tables
976 ╭────────────────────────────────────────────────────────────────────┬─────────╮
977 │                                                                    │   S3a.  │
978 │                                                                    │ GENDER: │
979 │                                                                    ├─────────┤
980 │                                                                    │  Female │
981 │                                                                    ├─────────┤
982 │                                                                    │ Column %│
983 ├────────────────────────────────────────────────────────────────────┼─────────┤
984 │105b. How likely is it that drivers who have had too    Almost      │      32%│
985 │much to drink to drive safely will A. Get stopped by    certain     │         │
986 │the police?                                             Somewhat    │      40%│
987 │                                                        likely      │         │
988 │                                                        Somewhat    │      19%│
989 │                                                        unlikely    │         │
990 │                                                        Very        │       9%│
991 │                                                        unlikely    │         │
992 ╰────────────────────────────────────────────────────────────────────┴─────────╯
993 ])
994 AT_CLEANUP
995
996 AT_SETUP([CTABLES sorting categories])
997 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
998 AT_DATA([ctables.sps],
999 [[GET 'nhtsa.sav'.
1000 IF (QND5A=6) QND5A=-1.
1001 IF (QND5A=5) QND5A=-2.
1002 CTABLES /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=A
1003         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=D
1004         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=A
1005         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=D.
1006 ]])
1007 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1008                                   Custom Tables
1009 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1010 │                                                                        │Count│
1011 ├────────────────────────────────────────────────────────────────────────┼─────┤
1012 │D5a. What would you say is your primary ethnic  -2.00                   │   52│
1013 │background?                                     -1.00                   │   78│
1014 │                                                Cuban                   │   20│
1015 │                                                Mexican                 │  311│
1016 │                                                Spanish                 │   48│
1017 │                                                South American          │   34│
1018 │                                                Central American        │    0│
1019 │                                                Puerto Rican, OR        │    0│
1020 │                                                Something else          │   68│
1021 │                                                Multiple - cannot choose│    7│
1022 │                                                one                     │     │
1023 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1024
1025                                   Custom Tables
1026 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1027 │                                                                        │Count│
1028 ├────────────────────────────────────────────────────────────────────────┼─────┤
1029 │D5a. What would you say is your primary ethnic  Multiple - cannot choose│    7│
1030 │background?                                     one                     │     │
1031 │                                                Something else          │   68│
1032 │                                                Puerto Rican, OR        │    0│
1033 │                                                Central American        │    0│
1034 │                                                South American          │   34│
1035 │                                                Spanish                 │   48│
1036 │                                                Mexican                 │  311│
1037 │                                                Cuban                   │   20│
1038 │                                                -1.00                   │   78│
1039 │                                                -2.00                   │   52│
1040 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1041
1042                                   Custom Tables
1043 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1044 │                                                                        │Count│
1045 ├────────────────────────────────────────────────────────────────────────┼─────┤
1046 │D5a. What would you say is your primary ethnic  Central American        │    0│
1047 │background?                                     Cuban                   │   20│
1048 │                                                Mexican                 │  311│
1049 │                                                Multiple - cannot choose│    7│
1050 │                                                one                     │     │
1051 │                                                Puerto Rican, OR        │    0│
1052 │                                                Something else          │   68│
1053 │                                                South American          │   34│
1054 │                                                Spanish                 │   48│
1055 │                                                -2.00                   │   52│
1056 │                                                -1.00                   │   78│
1057 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1058
1059                                   Custom Tables
1060 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1061 │                                                                        │Count│
1062 ├────────────────────────────────────────────────────────────────────────┼─────┤
1063 │D5a. What would you say is your primary ethnic  Spanish                 │   48│
1064 │background?                                     South American          │   34│
1065 │                                                Something else          │   68│
1066 │                                                Puerto Rican, OR        │    0│
1067 │                                                Multiple - cannot choose│    7│
1068 │                                                one                     │     │
1069 │                                                Mexican                 │  311│
1070 │                                                Cuban                   │   20│
1071 │                                                Central American        │    0│
1072 │                                                -1.00                   │   78│
1073 │                                                -2.00                   │   52│
1074 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1075 ])
1076 AT_CLEANUP
1077
1078 AT_SETUP([CTABLES simple nesting])
1079 AT_KEYWORDS([nest nested])
1080 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1081 AT_DATA([ctables.sps],
1082 [[GET 'nhtsa.sav'.
1083 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
1084   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
1085 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
1086   /CATEGORIES VARIABLES=qns3a TOTAL=YES
1087   /CLABELS ROW=OPPOSITE.
1088 ]])
1089 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1090                                   Custom Tables
1091 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
1092 │                                                                 │     │ Table│
1093 │                                                                 │Count│   %  │
1094 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1095 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
1096 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
1097 │drive safely will A. Get stopped by                        Total │  700│   10%│
1098 │the police?                           ╶──────────────────────────┼─────┼──────┤
1099 │                                       Very       S3a.     Male  │  660│   10%│
1100 │                                       likely     GENDER:  Female│  842│   12%│
1101 │                                                           Total │ 1502│   22%│
1102 │                                      ╶──────────────────────────┼─────┼──────┤
1103 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
1104 │                                       likely     GENDER:  Female│ 1589│   23%│
1105 │                                                           Total │ 2763│   40%│
1106 │                                      ╶──────────────────────────┼─────┼──────┤
1107 │                                       Somewhat   S3a.     Male  │  640│    9%│
1108 │                                       unlikely   GENDER:  Female│  667│   10%│
1109 │                                                           Total │ 1307│   19%│
1110 │                                      ╶──────────────────────────┼─────┼──────┤
1111 │                                       Very       S3a.     Male  │  311│    5%│
1112 │                                       unlikely   GENDER:  Female│  298│    4%│
1113 │                                                           Total │  609│    9%│
1114 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1115 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
1116 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
1117 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
1118 │                                      ╶──────────────────────────┼─────┼──────┤
1119 │                                       Very       S3a.     Male  │ 1104│   16%│
1120 │                                       likely     GENDER:  Female│ 1715│   25%│
1121 │                                                           Total │ 2819│   41%│
1122 │                                      ╶──────────────────────────┼─────┼──────┤
1123 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
1124 │                                       likely     GENDER:  Female│ 1214│   18%│
1125 │                                                           Total │ 2417│   35%│
1126 │                                      ╶──────────────────────────┼─────┼──────┤
1127 │                                       Somewhat   S3a.     Male  │  262│    4%│
1128 │                                       unlikely   GENDER:  Female│  168│    2%│
1129 │                                                           Total │  430│    6%│
1130 │                                      ╶──────────────────────────┼─────┼──────┤
1131 │                                       Very       S3a.     Male  │   81│    1%│
1132 │                                       unlikely   GENDER:  Female│   59│    1%│
1133 │                                                           Total │  140│    2%│
1134 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1135 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
1136 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
1137 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
1138 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1139 │                                       Very       S3a.     Male  │  988│   14%│
1140 │                                       likely     GENDER:  Female│ 1049│   15%│
1141 │                                                           Total │ 2037│   30%│
1142 │                                      ╶──────────────────────────┼─────┼──────┤
1143 │                                       Somewhat   S3a.     Male  │  822│   12%│
1144 │                                       likely     GENDER:  Female│ 1210│   18%│
1145 │                                                           Total │ 2032│   30%│
1146 │                                      ╶──────────────────────────┼─────┼──────┤
1147 │                                       Somewhat   S3a.     Male  │  446│    7%│
1148 │                                       unlikely   GENDER:  Female│  548│    8%│
1149 │                                                           Total │  994│   15%│
1150 │                                      ╶──────────────────────────┼─────┼──────┤
1151 │                                       Very       S3a.     Male  │  268│    4%│
1152 │                                       unlikely   GENDER:  Female│  354│    5%│
1153 │                                                           Total │  622│    9%│
1154 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1155 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
1156 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
1157 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
1158 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1159 │                                       Very       S3a.     Male  │  805│   12%│
1160 │                                       likely     GENDER:  Female│ 1029│   15%│
1161 │                                                           Total │ 1834│   27%│
1162 │                                      ╶──────────────────────────┼─────┼──────┤
1163 │                                       Somewhat   S3a.     Male  │  975│   14%│
1164 │                                       likely     GENDER:  Female│ 1332│   19%│
1165 │                                                           Total │ 2307│   34%│
1166 │                                      ╶──────────────────────────┼─────┼──────┤
1167 │                                       Somewhat   S3a.     Male  │  535│    8%│
1168 │                                       unlikely   GENDER:  Female│  560│    8%│
1169 │                                                           Total │ 1095│   16%│
1170 │                                      ╶──────────────────────────┼─────┼──────┤
1171 │                                       Very       S3a.     Male  │  270│    4%│
1172 │                                       unlikely   GENDER:  Female│  279│    4%│
1173 │                                                           Total │  549│    8%│
1174 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1175
1176                                   Custom Tables
1177 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
1178 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
1179 │                                 │ certain│likely│  likely │ unlikely│unlikely│
1180 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
1181 │                                 │        │ Table│         │         │        │
1182 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
1183 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1184 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
1185 │GENDER:        is it that drivers│        │      │         │         │        │
1186 │               who have had too  │        │      │         │         │        │
1187 │               much to drink to  │        │      │         │         │        │
1188 │               drive safely will │        │      │         │         │        │
1189 │               A. Get stopped by │        │      │         │         │        │
1190 │               the police?       │        │      │         │         │        │
1191 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1192 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
1193 │               is it that drivers│        │      │         │         │        │
1194 │               who have had too  │        │      │         │         │        │
1195 │               much to drink to  │        │      │         │         │        │
1196 │               drive safely will │        │      │         │         │        │
1197 │               A. Get stopped by │        │      │         │         │        │
1198 │               the police?       │        │      │         │         │        │
1199 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1200 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
1201 │               is it that drivers│        │      │         │         │        │
1202 │               who have had too  │        │      │         │         │        │
1203 │               much to drink to  │        │      │         │         │        │
1204 │               drive safely will │        │      │         │         │        │
1205 │               A. Get stopped by │        │      │         │         │        │
1206 │               the police?       │        │      │         │         │        │
1207 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1208 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
1209 │GENDER:        is it that drivers│        │      │         │         │        │
1210 │               who have had too  │        │      │         │         │        │
1211 │               much to drink to  │        │      │         │         │        │
1212 │               drive safely will │        │      │         │         │        │
1213 │               B. Have an        │        │      │         │         │        │
1214 │               accident?         │        │      │         │         │        │
1215 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1216 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
1217 │               is it that drivers│        │      │         │         │        │
1218 │               who have had too  │        │      │         │         │        │
1219 │               much to drink to  │        │      │         │         │        │
1220 │               drive safely will │        │      │         │         │        │
1221 │               B. Have an        │        │      │         │         │        │
1222 │               accident?         │        │      │         │         │        │
1223 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1224 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
1225 │               is it that drivers│        │      │         │         │        │
1226 │               who have had too  │        │      │         │         │        │
1227 │               much to drink to  │        │      │         │         │        │
1228 │               drive safely will │        │      │         │         │        │
1229 │               B. Have an        │        │      │         │         │        │
1230 │               accident?         │        │      │         │         │        │
1231 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1232 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
1233 │GENDER:        is it that drivers│        │      │         │         │        │
1234 │               who have had too  │        │      │         │         │        │
1235 │               much to drink to  │        │      │         │         │        │
1236 │               drive safely will │        │      │         │         │        │
1237 │               C. Be convicted   │        │      │         │         │        │
1238 │               for drunk driving?│        │      │         │         │        │
1239 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1240 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
1241 │               is it that drivers│        │      │         │         │        │
1242 │               who have had too  │        │      │         │         │        │
1243 │               much to drink to  │        │      │         │         │        │
1244 │               drive safely will │        │      │         │         │        │
1245 │               C. Be convicted   │        │      │         │         │        │
1246 │               for drunk driving?│        │      │         │         │        │
1247 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1248 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
1249 │               is it that drivers│        │      │         │         │        │
1250 │               who have had too  │        │      │         │         │        │
1251 │               much to drink to  │        │      │         │         │        │
1252 │               drive safely will │        │      │         │         │        │
1253 │               C. Be convicted   │        │      │         │         │        │
1254 │               for drunk driving?│        │      │         │         │        │
1255 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1256 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
1257 │GENDER:        is it that drivers│        │      │         │         │        │
1258 │               who have had too  │        │      │         │         │        │
1259 │               much to drink to  │        │      │         │         │        │
1260 │               drive safely will │        │      │         │         │        │
1261 │               D. Be arrested for│        │      │         │         │        │
1262 │               drunk driving?    │        │      │         │         │        │
1263 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1264 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
1265 │               is it that drivers│        │      │         │         │        │
1266 │               who have had too  │        │      │         │         │        │
1267 │               much to drink to  │        │      │         │         │        │
1268 │               drive safely will │        │      │         │         │        │
1269 │               D. Be arrested for│        │      │         │         │        │
1270 │               drunk driving?    │        │      │         │         │        │
1271 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1272 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
1273 │               is it that drivers│        │      │         │         │        │
1274 │               who have had too  │        │      │         │         │        │
1275 │               much to drink to  │        │      │         │         │        │
1276 │               drive safely will │        │      │         │         │        │
1277 │               D. Be arrested for│        │      │         │         │        │
1278 │               drunk driving?    │        │      │         │         │        │
1279 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
1280 ])
1281 AT_CLEANUP
1282
1283 AT_SETUP([CTABLES nesting and scale variables])
1284 AT_KEYWORDS([nest nested])
1285 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1286 AT_DATA([ctables.sps],
1287 [[GET 'nhtsa.sav'.
1288 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
1289 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
1290 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
1291   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
1292 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
1293 ]])
1294 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1295                                   Custom Tables
1296 ╭─────────────────────────────────────────────────────────────────┬────────────╮
1297 │                                                                 │S3a. GENDER:│
1298 │                                                                 ├─────┬──────┤
1299 │                                                                 │ Male│Female│
1300 │                                                                 ├─────┼──────┤
1301 │                                                                 │ Mean│ Mean │
1302 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1303 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
1304 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
1305 │                                                  week           │     │      │
1306 │                                                  Once a week or │   44│    54│
1307 │                                                  less           │     │      │
1308 │                                                  Only certain   │   34│    41│
1309 │                                                  times a year   │     │      │
1310 │                                                  Never          │   39│    55│
1311 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1312
1313                                   Custom Tables
1314 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
1315 │                                                         │Minimum│Maximum│Mean│
1316 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1317 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
1318 │What is  GENDER:         months, has there been a        │       │       │    │
1319 │your                     time when you felt you          │       │       │    │
1320 │age?                     should cut down on your      No │     16│     86│  46│
1321 │                         drinking?                       │       │       │    │
1322 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1323 │                  Female 26. During the last 12       Yes│     16│     86│  43│
1324 │                         months, has there been a        │       │       │    │
1325 │                         time when you felt you          │       │       │    │
1326 │                         should cut down on your      No │     16│     86│  48│
1327 │                         drinking?                       │       │       │    │
1328 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1329 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
1330 │What is  GENDER:         months, has there been a        │       │       │    │
1331 │your                     time when people criticized  No │     16│     86│  46│
1332 │age?                     your drinking?                  │       │       │    │
1333 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1334 │                  Female 27. During the last 12       Yes│     17│     69│  37│
1335 │                         months, has there been a        │       │       │    │
1336 │                         time when people criticized  No │     16│     86│  48│
1337 │                         your drinking?                  │       │       │    │
1338 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
1339
1340                                   Custom Tables
1341 ╭─────────────────────────────┬────────────────────────────────────────────────╮
1342 │                             │S1. Including yourself, how many members of this│
1343 │                             │         household are age 16 or older?         │
1344 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
1345 │                             │      │      │      │      │      │      │ 6 or │
1346 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
1347 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1348 │                             │Column│Column│Column│Column│Column│Column│Column│
1349 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
1350 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1351 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
1352 │SAMPLE      How      certain │      │      │      │      │      │      │      │
1353 │SOURCE:     likely           │      │      │      │      │      │      │      │
1354 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
1355 │            that     likely  │      │      │      │      │      │      │      │
1356 │            drivers          │      │      │      │      │      │      │      │
1357 │            who have         │      │      │      │      │      │      │      │
1358 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
1359 │            much to  likely  │      │      │      │      │      │      │      │
1360 │            drink to         │      │      │      │      │      │      │      │
1361 │            drive            │      │      │      │      │      │      │      │
1362 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
1363 │            will A.  unlikely│      │      │      │      │      │      │      │
1364 │            Get              │      │      │      │      │      │      │      │
1365 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
1366 │            by the   unlikely│      │      │      │      │      │      │      │
1367 │            police?          │      │      │      │      │      │      │      │
1368 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
1369
1370                                   Custom Tables
1371 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
1372 │                                                              │    │    Std   │
1373 │                                                              │Mean│ Deviation│
1374 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
1375 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
1376 │group           typical month did you have one or more        │    │          │
1377 │                alcoholic beverages to drink?                 │    │          │
1378 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1379 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
1380 │                typical month did you have one or more        │    │          │
1381 │                alcoholic beverages to drink?                 │    │          │
1382 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1383 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
1384 │                typical month did you have one or more        │    │          │
1385 │                alcoholic beverages to drink?                 │    │          │
1386 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1387 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
1388 │                typical month did you have one or more        │    │          │
1389 │                alcoholic beverages to drink?                 │    │          │
1390 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1391 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
1392 │                typical month did you have one or more        │    │          │
1393 │                alcoholic beverages to drink?                 │    │          │
1394 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1395 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
1396 │       older    typical month did you have one or more        │    │          │
1397 │                alcoholic beverages to drink?                 │    │          │
1398 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
1399 ])
1400 AT_CLEANUP
1401
1402
1403 AT_SETUP([CTABLES SLABELS])
1404 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1405 AT_DATA([ctables.sps],
1406 [[GET 'nhtsa.sav'.
1407 CTABLES /TABLE qn1 [COUNT COLPCT].
1408 CTABLES /TABLE qn1 [COUNT COLPCT]
1409     /SLABELS POSITION=ROW.
1410 CTABLES /TABLE qn1 [COUNT COLPCT]
1411     /SLABELS POSITION=ROW VISIBLE=NO.
1412 ]])
1413 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1414                                   Custom Tables
1415 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
1416 │                                                                │     │ Column│
1417 │                                                                │Count│   %   │
1418 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
1419 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
1420 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
1421 │                                             Once a week or less│  361│   5.2%│
1422 │                                             Only certain times │  130│   1.9%│
1423 │                                             a year             │     │       │
1424 │                                             Never              │  540│   7.7%│
1425 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
1426
1427                                   Custom Tables
1428 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1429 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
1430 │other motor vehicle?                                             Column │66.9%│
1431 │                                                                 %      │     │
1432 │                                            ╶───────────────────────────┼─────┤
1433 │                                             Several days a week Count  │ 1274│
1434 │                                                                 Column │18.3%│
1435 │                                                                 %      │     │
1436 │                                            ╶───────────────────────────┼─────┤
1437 │                                             Once a week or less Count  │  361│
1438 │                                                                 Column │ 5.2%│
1439 │                                                                 %      │     │
1440 │                                            ╶───────────────────────────┼─────┤
1441 │                                             Only certain times  Count  │  130│
1442 │                                             a year              Column │ 1.9%│
1443 │                                                                 %      │     │
1444 │                                            ╶───────────────────────────┼─────┤
1445 │                                             Never               Count  │  540│
1446 │                                                                 Column │ 7.7%│
1447 │                                                                 %      │     │
1448 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1449
1450                                   Custom Tables
1451 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1452 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
1453 │motor vehicle?                                                          │66.9%│
1454 │                                                   Several days a week  │ 1274│
1455 │                                                                        │18.3%│
1456 │                                                   Once a week or less  │  361│
1457 │                                                                        │ 5.2%│
1458 │                                                   Only certain times a │  130│
1459 │                                                   year                 │ 1.9%│
1460 │                                                   Never                │  540│
1461 │                                                                        │ 7.7%│
1462 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1463 ])
1464 AT_CLEANUP
1465
1466 AT_SETUP([CTABLES simple totals])
1467 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1468 AT_DATA([ctables.sps],
1469 [[GET 'nhtsa.sav'.
1470 CTABLES /TABLE=qn17
1471     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
1472 DESCRIPTIVES qn18/STATISTICS=MEAN.
1473 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
1474     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
1475 ]])
1476 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1477                                   Custom Tables
1478 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1479 │                                                                        │Count│
1480 ├────────────────────────────────────────────────────────────────────────┼─────┤
1481 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
1482 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
1483 │                                                      Light beer        │  620│
1484 │                                                      Wine              │ 1418│
1485 │                                                      Wine coolers      │  137│
1486 │                                                      Hard liquor or    │  888│
1487 │                                                      mixed drinks      │     │
1488 │                                                      Flavored malt     │   83│
1489 │                                                      drinks            │     │
1490 │                                                      Number responding │ 4221│
1491 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1492
1493                              Descriptive Statistics
1494 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
1495 │                                                                    │  N │Mean│
1496 ├────────────────────────────────────────────────────────────────────┼────┼────┤
1497 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
1498 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
1499 │Valid N (listwise)                                                  │6999│    │
1500 │Missing N (listwise)                                                │2781│    │
1501 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
1502
1503                                   Custom Tables
1504 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
1505 │                                                      │    │     │ Valid│Total│
1506 │                                                      │Mean│Count│   N  │  N  │
1507 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1508 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
1509 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1510 │                you usually drink per sitting?        │    │     │      │     │
1511 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1512 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
1513 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1514 │                you usually drink per sitting?        │    │     │      │     │
1515 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1516 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
1517 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1518 │                you usually drink per sitting?        │    │     │      │     │
1519 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1520 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
1521 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1522 │                you usually drink per sitting?        │    │     │      │     │
1523 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1524 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
1525 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1526 │                you usually drink per sitting?        │    │     │      │     │
1527 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
1528 ])
1529 AT_CLEANUP
1530
1531 AT_SETUP([CTABLES subtotals])
1532 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1533 AT_DATA([ctables.sps],
1534 [[GET 'nhtsa.sav'.
1535 CTABLES /TABLE=qn105ba BY qns1
1536     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1537 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
1538     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
1539 CTABLES /TABLE=qn105ba BY qns1
1540     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
1541     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1542 ]])
1543 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1544                                                       Custom Tables
1545 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1546 │                                                         │ S1. Including yourself, how many members of this household │
1547 │                                                         │                    are age 16 or older?                    │
1548 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1549 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1550 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1551 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1552 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1553 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1554 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1555 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1556 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1557 │                                              likely     │       │       │         │       │        │      │          │
1558 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1559 │                                              unlikely   │       │       │         │       │        │      │          │
1560 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1561 │                                              unlikely   │       │       │         │       │        │      │          │
1562 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1563
1564                                                       Custom Tables
1565 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1566 │                                                        │  S1. Including yourself, how many members of this household │
1567 │                                                        │                     are age 16 or older?                    │
1568 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
1569 │                                                        │        │        │        │        │       │        │  6 or  │
1570 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
1571 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1572 │                                                        │        │        │        │        │ Column│        │        │
1573 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
1574 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1575 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
1576 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
1577 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
1578 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
1579 │                                             likely     │        │        │        │        │       │        │        │
1580 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
1581 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
1582 │                                             unlikely   │        │        │        │        │       │        │        │
1583 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
1584 │                                             unlikely   │        │        │        │        │       │        │        │
1585 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
1586 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
1587
1588                                                       Custom Tables
1589 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1590 │                                                         │ S1. Including yourself, how many members of this household │
1591 │                                                         │                    are age 16 or older?                    │
1592 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1593 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1594 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1595 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1596 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1597 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1598 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1599 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1600 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1601 │                                              likely     │       │       │         │       │        │      │          │
1602 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
1603 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1604 │                                              unlikely   │       │       │         │       │        │      │          │
1605 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1606 │                                              unlikely   │       │       │         │       │        │      │          │
1607 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
1608 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1609 ])
1610 AT_CLEANUP
1611
1612 AT_SETUP([CTABLES PCOMPUTE])
1613 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1614 AT_DATA([ctables.sps],
1615 [[GET 'nhtsa.sav'.
1616 CTABLES
1617     /PCOMPUTE &x=EXPR([3] + [4])
1618     /PCOMPUTE &y=EXPR([4] + [5])
1619     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
1620     /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]'
1621     /TABLE=qn105ba BY qns1
1622     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
1623 ]])
1624 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1625                                                       Custom Tables
1626 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1627 │                                                        │  S1. Including yourself, how many members of this household │
1628 │                                                        │                     are age 16 or older?                    │
1629 │                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
1630 │                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
1631 │                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1632 │                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
1633 ├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1634 │105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
1635 │had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
1636 │A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
1637 │                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
1638 │                                             likely     │       │       │          │       │        │      │          │
1639 │                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
1640 │                                             unlikely   │       │       │          │       │        │      │          │
1641 │                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
1642 │                                             unlikely   │       │       │          │       │        │      │          │
1643 ╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
1644 ])
1645 AT_CLEANUP
1646
1647 AT_SETUP([CTABLES CLABELS])
1648 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1649 AT_DATA([ctables.sps],
1650 [[GET 'nhtsa.sav'.
1651 CTABLES /TABLE AgeGroup BY qns3a.
1652 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1653 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1654 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
1655 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
1656 ]])
1657 pwd
1658 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
1659              Custom Tables
1660 ╭───────────────────────┬────────────╮
1661 │                       │S3a. GENDER:│
1662 │                       ├─────┬──────┤
1663 │                       │ Male│Female│
1664 │                       ├─────┼──────┤
1665 │                       │Count│ Count│
1666 ├───────────────────────┼─────┼──────┤
1667 │Age group 15 or younger│    0│     0│
1668 │          16 to 25     │  594│   505│
1669 │          26 to 35     │  476│   491│
1670 │          36 to 45     │  489│   548│
1671 │          46 to 55     │  526│   649│
1672 │          56 to 65     │  516│   731│
1673 │          66 or older  │  531│   943│
1674 ╰───────────────────────┴─────┴──────╯
1675
1676                                                       Custom Tables
1677 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1678 │       │                                                 S3a. GENDER:                                                 │
1679 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
1680 │       │                         Male                         │                         Female                        │
1681 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
1682 │       │  15 or  │ 16 to │ 26 to│ 36 to│ 46 to│ 56 to │ 66 or │   15 or  │ 16 to│ 26 to │ 36 to│ 46 to│ 56 to│  66 or │
1683 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
1684 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1685 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
1686 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1687 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
1688 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
1689 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
1690
1691                 Custom Tables
1692 ╭──────────────────────────────┬────────────╮
1693 │                              │S3a. GENDER:│
1694 │                              ├────────────┤
1695 │                              │    Count   │
1696 ├──────────────────────────────┼────────────┤
1697 │Age group 15 or younger Male  │           0│
1698 │                        Female│           0│
1699 │         ╶────────────────────┼────────────┤
1700 │          16 to 25      Male  │         594│
1701 │                        Female│         505│
1702 │         ╶────────────────────┼────────────┤
1703 │          26 to 35      Male  │         476│
1704 │                        Female│         491│
1705 │         ╶────────────────────┼────────────┤
1706 │          36 to 45      Male  │         489│
1707 │                        Female│         548│
1708 │         ╶────────────────────┼────────────┤
1709 │          46 to 55      Male  │         526│
1710 │                        Female│         649│
1711 │         ╶────────────────────┼────────────┤
1712 │          56 to 65      Male  │         516│
1713 │                        Female│         731│
1714 │         ╶────────────────────┼────────────┤
1715 │          66 or older   Male  │         531│
1716 │                        Female│         943│
1717 ╰──────────────────────────────┴────────────╯
1718
1719       Custom Tables
1720 15 or younger
1721 ╭─────────┬────────────╮
1722 │         │S3a. GENDER:│
1723 │         ├─────┬──────┤
1724 │         │ Male│Female│
1725 │         ├─────┼──────┤
1726 │         │Count│ Count│
1727 ├─────────┼─────┼──────┤
1728 │Age group│    0│     0│
1729 ╰─────────┴─────┴──────╯
1730
1731       Custom Tables
1732 16 to 25
1733 ╭─────────┬────────────╮
1734 │         │S3a. GENDER:│
1735 │         ├─────┬──────┤
1736 │         │ Male│Female│
1737 │         ├─────┼──────┤
1738 │         │Count│ Count│
1739 ├─────────┼─────┼──────┤
1740 │Age group│  594│   505│
1741 ╰─────────┴─────┴──────╯
1742
1743       Custom Tables
1744 26 to 35
1745 ╭─────────┬────────────╮
1746 │         │S3a. GENDER:│
1747 │         ├─────┬──────┤
1748 │         │ Male│Female│
1749 │         ├─────┼──────┤
1750 │         │Count│ Count│
1751 ├─────────┼─────┼──────┤
1752 │Age group│  476│   491│
1753 ╰─────────┴─────┴──────╯
1754
1755       Custom Tables
1756 36 to 45
1757 ╭─────────┬────────────╮
1758 │         │S3a. GENDER:│
1759 │         ├─────┬──────┤
1760 │         │ Male│Female│
1761 │         ├─────┼──────┤
1762 │         │Count│ Count│
1763 ├─────────┼─────┼──────┤
1764 │Age group│  489│   548│
1765 ╰─────────┴─────┴──────╯
1766
1767       Custom Tables
1768 46 to 55
1769 ╭─────────┬────────────╮
1770 │         │S3a. GENDER:│
1771 │         ├─────┬──────┤
1772 │         │ Male│Female│
1773 │         ├─────┼──────┤
1774 │         │Count│ Count│
1775 ├─────────┼─────┼──────┤
1776 │Age group│  526│   649│
1777 ╰─────────┴─────┴──────╯
1778
1779       Custom Tables
1780 56 to 65
1781 ╭─────────┬────────────╮
1782 │         │S3a. GENDER:│
1783 │         ├─────┬──────┤
1784 │         │ Male│Female│
1785 │         ├─────┼──────┤
1786 │         │Count│ Count│
1787 ├─────────┼─────┼──────┤
1788 │Age group│  516│   731│
1789 ╰─────────┴─────┴──────╯
1790
1791       Custom Tables
1792 66 or older
1793 ╭─────────┬────────────╮
1794 │         │S3a. GENDER:│
1795 │         ├─────┬──────┤
1796 │         │ Male│Female│
1797 │         ├─────┼──────┤
1798 │         │Count│ Count│
1799 ├─────────┼─────┼──────┤
1800 │Age group│  531│   943│
1801 ╰─────────┴─────┴──────╯
1802
1803              Custom Tables
1804 Male
1805 ╭───────────────────────┬────────────╮
1806 │                       │S3a. GENDER:│
1807 │                       ├────────────┤
1808 │                       │    Count   │
1809 ├───────────────────────┼────────────┤
1810 │Age group 15 or younger│           0│
1811 │          16 to 25     │         594│
1812 │          26 to 35     │         476│
1813 │          36 to 45     │         489│
1814 │          46 to 55     │         526│
1815 │          56 to 65     │         516│
1816 │          66 or older  │         531│
1817 ╰───────────────────────┴────────────╯
1818
1819              Custom Tables
1820 Female
1821 ╭───────────────────────┬────────────╮
1822 │                       │S3a. GENDER:│
1823 │                       ├────────────┤
1824 │                       │    Count   │
1825 ├───────────────────────┼────────────┤
1826 │Age group 15 or younger│           0│
1827 │          16 to 25     │         505│
1828 │          26 to 35     │         491│
1829 │          36 to 45     │         548│
1830 │          46 to 55     │         649│
1831 │          56 to 65     │         731│
1832 │          66 or older  │         943│
1833 ╰───────────────────────┴────────────╯
1834 ])
1835 AT_CLEANUP
1836
1837 AT_SETUP([CTABLES missing values])
1838 AT_DATA([ctables.sps],
1839 [[DATA LIST LIST NOTABLE/x y.
1840 BEGIN DATA.
1841 1 1
1842 1 2
1843 1 3
1844 1 4
1845 1 5
1846 1 .
1847 2 1
1848 2 2
1849 2 3
1850 2 4
1851 2 5
1852 2 .
1853 3 1
1854 3 2
1855 3 3
1856 3 4
1857 3 5
1858 3 .
1859 4 1
1860 4 2
1861 4 3
1862 4 4
1863 4 5
1864 4 .
1865 5 1
1866 5 2
1867 5 3
1868 5 4
1869 5 5
1870 5 .
1871 . 1
1872 . 2
1873 . 3
1874 . 4
1875 . 5
1876 . .
1877 END DATA.
1878 MISSING VALUES x (1, 2) y (2, 3).
1879 VARIABLE LEVEL ALL (NOMINAL).
1880
1881 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1882                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1883     /CATEGORIES VARIABLES=ALL TOTAL=YES.
1884 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1885                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1886     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
1887 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1888                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1889     /CATEGORIES VARIABLES=ALL TOTAL=YES
1890     /SLABELS POSITION=ROW.
1891 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1892                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1893     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
1894     /SLABELS POSITION=ROW.
1895 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1896                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1897     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
1898     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
1899     /SLABELS POSITION=ROW.
1900 ]])
1901 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1902                                Custom Tables
1903 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1904 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1905 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1906 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1907 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1908 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1909 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
1910 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1911 dnl Note that Column Total N % doesn't add up to 100 because missing
1912 dnl values are included in the total but not shown as a category and this
1913 dnl is expected behavior.
1914
1915                                Custom Tables
1916 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1917 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1918 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1919 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1920 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1921 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1922 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1923 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1924 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
1925 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1926 dnl Note that Column Total N % doesn't add up to 100 because system-missing
1927 dnl values are included in the total but not shown as a category and this
1928 dnl is expected behavior.
1929
1930                      Custom Tables
1931 ╭────────────────────────┬───────────────────────────╮
1932 │                        │             y             │
1933 │                        ├──────┬──────┬──────┬──────┤
1934 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
1935 ├────────────────────────┼──────┼──────┼──────┼──────┤
1936 │x 3.00  Count           │     1│     1│     1│     3│
1937 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1938 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1939 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1940 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1941 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1942 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1943 │        Valid N         │      │      │      │     3│
1944 │        Total N         │      │      │      │     6│
1945 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1946 │  4.00  Count           │     1│     1│     1│     3│
1947 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1948 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1949 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1950 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1951 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1952 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1953 │        Valid N         │      │      │      │     3│
1954 │        Total N         │      │      │      │     6│
1955 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1956 │  5.00  Count           │     1│     1│     1│     3│
1957 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1958 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1959 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1960 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1961 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1962 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1963 │        Valid N         │      │      │      │     3│
1964 │        Total N         │      │      │      │     6│
1965 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1966 │  Total Count           │     3│     3│     3│     9│
1967 │        Column %        │100.0%│100.0%│100.0%│     .│
1968 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
1969 │        Column Total N %│100.0%│100.0%│100.0%│     .│
1970 │        Row %           │     .│     .│     .│     .│
1971 │        Row Valid N %   │     .│     .│     .│     .│
1972 │        Row Total N %   │     .│     .│     .│     .│
1973 │        Valid N         │     3│     3│     3│     9│
1974 │        Total N         │     6│     6│     6│    36│
1975 ╰────────────────────────┴──────┴──────┴──────┴──────╯
1976
1977                             Custom Tables
1978 ╭────────────────────────┬─────────────────────────────────────────╮
1979 │                        │                    y                    │
1980 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
1981 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1982 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1983 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
1984 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1985 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1986 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1987 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1988 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1989 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1990 │        Valid N         │      │      │      │      │      │     0│
1991 │        Total N         │      │      │      │      │      │     6│
1992 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1993 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
1994 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1995 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1996 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1997 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1998 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1999 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2000 │        Valid N         │      │      │      │      │      │     0│
2001 │        Total N         │      │      │      │      │      │     6│
2002 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2003 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
2004 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2005 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2006 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2007 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2008 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2009 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2010 │        Valid N         │      │      │      │      │      │     3│
2011 │        Total N         │      │      │      │      │      │     6│
2012 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2013 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
2014 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2015 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2016 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2017 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2018 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2019 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2020 │        Valid N         │      │      │      │      │      │     3│
2021 │        Total N         │      │      │      │      │      │     6│
2022 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2023 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
2024 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2025 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2026 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2027 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2028 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2029 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2030 │        Valid N         │      │      │      │      │      │     3│
2031 │        Total N         │      │      │      │      │      │     6│
2032 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2033 │  Total Count           │     5│     5│     5│     5│     5│    25│
2034 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2035 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
2036 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2037 │        Row %           │     .│     .│     .│     .│     .│     .│
2038 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2039 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
2040 │        Valid N         │     3│     0│     0│     3│     3│     9│
2041 │        Total N         │     6│     6│     6│     6│     6│    36│
2042 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
2043
2044                         Custom Tables
2045 ╭────────────────────────┬──────────────────────────────────╮
2046 │                        │                 y                │
2047 │                        ├──────┬──────┬──────┬──────┬──────┤
2048 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
2049 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
2050 │x 1.00  Count           │     1│     1│     1│     1│     4│
2051 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2052 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2053 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2054 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2055 │        Row Valid N %   │     .│     .│     .│     .│     .│
2056 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2057 │        Valid N         │      │      │      │      │     0│
2058 │        Total N         │      │      │      │      │     6│
2059 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2060 │  2.00  Count           │     1│     1│     1│     1│     4│
2061 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2062 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2063 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2064 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2065 │        Row Valid N %   │     .│     .│     .│     .│     .│
2066 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2067 │        Valid N         │      │      │      │      │     0│
2068 │        Total N         │      │      │      │      │     6│
2069 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2070 │  3.00  Count           │     1│     1│     1│     1│     4│
2071 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2072 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2073 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2074 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2075 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2076 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2077 │        Valid N         │      │      │      │      │     3│
2078 │        Total N         │      │      │      │      │     6│
2079 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2080 │  4.00  Count           │     1│     1│     1│     1│     4│
2081 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2082 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2083 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2084 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2085 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2086 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2087 │        Valid N         │      │      │      │      │     3│
2088 │        Total N         │      │      │      │      │     6│
2089 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2090 │  Total Count           │     4│     4│     4│     4│    16│
2091 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
2092 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
2093 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
2094 │        Row %           │     .│     .│     .│     .│     .│
2095 │        Row Valid N %   │     .│     .│     .│     .│     .│
2096 │        Row Total N %   │     .│     .│     .│     .│     .│
2097 │        Valid N         │     2│     0│     2│     2│     6│
2098 │        Total N         │     5│     5│     5│     5│    30│
2099 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
2100 ])
2101 AT_CLEANUP
2102
2103 AT_SETUP([CTABLES SMISSING=LISTWISE])
2104 AT_KEYWORDS([SMISSING LISTWISE])
2105 AT_DATA([ctables.sps],
2106 [[DATA LIST LIST NOTABLE/x y z.
2107 BEGIN DATA.
2108 1  . 40
2109 1 10 50
2110 1 20 60
2111 1  .  .
2112 1 30  .
2113 END DATA.
2114 VARIABLE LEVEL x (NOMINAL).
2115
2116 CTABLES /TABLE (y + z) > x.
2117 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
2118
2119 * The following doesn't come out as listwise because the tables are
2120 separate, not linked by an > operator.
2121 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
2122 ]])
2123 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2124   Custom Tables
2125 ╭────────┬─────╮
2126 │        │ Mean│
2127 ├────────┼─────┤
2128 │y x 1.00│20.00│
2129 ├────────┼─────┤
2130 │z x 1.00│50.00│
2131 ╰────────┴─────╯
2132
2133   Custom Tables
2134 ╭────────┬─────╮
2135 │        │ Mean│
2136 ├────────┼─────┤
2137 │y x 1.00│15.00│
2138 ├────────┼─────┤
2139 │z x 1.00│55.00│
2140 ╰────────┴─────╯
2141
2142   Custom Tables
2143 ╭────────┬─────╮
2144 │        │ Mean│
2145 ├────────┼─────┤
2146 │y x 1.00│20.00│
2147 ├────────┼─────┤
2148 │z x 1.00│50.00│
2149 ╰────────┴─────╯
2150 ])
2151 AT_CLEANUP
2152
2153 AT_SETUP([CTABLES VLABELS - variables on different axes])
2154 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2155 AT_DATA([ctables.sps],
2156 [[GET 'nhtsa.sav'.
2157 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=DEFAULT /TABLE qnd5a BY qns3a.
2158 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NAME    /TABLE qnd5a BY qns3a.
2159 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=LABEL   /TABLE qnd5a BY qns3a.
2160 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=BOTH    /TABLE qnd5a BY qns3a.
2161 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE    /TABLE qnd5a BY qns3a.
2162 ]])
2163 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2164                                  Custom Tables
2165 ╭────────────────────────────────────────────────────────────────┬────────────╮
2166 │                                                                │S3a. GENDER:│
2167 │                                                                ├─────┬──────┤
2168 │                                                                │ Male│Female│
2169 │                                                                ├─────┼──────┤
2170 │                                                                │Count│ Count│
2171 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2172 │D5a. What would you say is your primary    Cuban                │   13│     7│
2173 │ethnic background?                         Mexican              │  175│   136│
2174 │                                           Spanish              │   20│    28│
2175 │                                           South American       │   21│    13│
2176 │                                           Central American     │   27│    25│
2177 │                                           Puerto Rican, OR     │   37│    41│
2178 │                                           Something else       │   35│    33│
2179 │                                           Multiple - cannot    │    2│     5│
2180 │                                           choose one           │     │      │
2181 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2182
2183                   Custom Tables
2184 ╭──────────────────────────────────┬────────────╮
2185 │                                  │    QNS3A   │
2186 │                                  ├─────┬──────┤
2187 │                                  │ Male│Female│
2188 │                                  ├─────┼──────┤
2189 │                                  │Count│ Count│
2190 ├──────────────────────────────────┼─────┼──────┤
2191 │QND5A Cuban                       │   13│     7│
2192 │      Mexican                     │  175│   136│
2193 │      Spanish                     │   20│    28│
2194 │      South American              │   21│    13│
2195 │      Central American            │   27│    25│
2196 │      Puerto Rican, OR            │   37│    41│
2197 │      Something else              │   35│    33│
2198 │      Multiple - cannot choose one│    2│     5│
2199 ╰──────────────────────────────────┴─────┴──────╯
2200
2201                                  Custom Tables
2202 ╭────────────────────────────────────────────────────────────────┬────────────╮
2203 │                                                                │S3a. GENDER:│
2204 │                                                                ├─────┬──────┤
2205 │                                                                │ Male│Female│
2206 │                                                                ├─────┼──────┤
2207 │                                                                │Count│ Count│
2208 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2209 │D5a. What would you say is your primary    Cuban                │   13│     7│
2210 │ethnic background?                         Mexican              │  175│   136│
2211 │                                           Spanish              │   20│    28│
2212 │                                           South American       │   21│    13│
2213 │                                           Central American     │   27│    25│
2214 │                                           Puerto Rican, OR     │   37│    41│
2215 │                                           Something else       │   35│    33│
2216 │                                           Multiple - cannot    │    2│     5│
2217 │                                           choose one           │     │      │
2218 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2219
2220                                  Custom Tables
2221 ╭────────────────────────────────────────────────────────────┬────────────────╮
2222 │                                                            │   QNS3A S3a.   │
2223 │                                                            │     GENDER:    │
2224 │                                                            ├───────┬────────┤
2225 │                                                            │  Male │ Female │
2226 │                                                            ├───────┼────────┤
2227 │                                                            │ Count │  Count │
2228 ├────────────────────────────────────────────────────────────┼───────┼────────┤
2229 │QND5A D5a. What would you say is your    Cuban              │     13│       7│
2230 │primary ethnic background?               Mexican            │    175│     136│
2231 │                                         Spanish            │     20│      28│
2232 │                                         South American     │     21│      13│
2233 │                                         Central American   │     27│      25│
2234 │                                         Puerto Rican, OR   │     37│      41│
2235 │                                         Something else     │     35│      33│
2236 │                                         Multiple - cannot  │      2│       5│
2237 │                                         choose one         │       │        │
2238 ╰────────────────────────────────────────────────────────────┴───────┴────────╯
2239
2240                Custom Tables
2241 ╭────────────────────────────┬─────┬──────╮
2242 │                            │ Male│Female│
2243 │                            ├─────┼──────┤
2244 │                            │Count│ Count│
2245 ├────────────────────────────┼─────┼──────┤
2246 │Cuban                       │   13│     7│
2247 │Mexican                     │  175│   136│
2248 │Spanish                     │   20│    28│
2249 │South American              │   21│    13│
2250 │Central American            │   27│    25│
2251 │Puerto Rican, OR            │   37│    41│
2252 │Something else              │   35│    33│
2253 │Multiple - cannot choose one│    2│     5│
2254 ╰────────────────────────────┴─────┴──────╯
2255 ])
2256 AT_CLEANUP
2257
2258 AT_SETUP([CTABLES VLABELS - stacked variables])
2259 AT_KEYWORDS([stack stacking])
2260 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2261 AT_DATA([ctables.sps],
2262 [[GET 'nhtsa.sav'.
2263 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a + qns3a.
2264 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a + qns3a.
2265 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a + qns3a.
2266 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
2267 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
2268 ]])
2269 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2270                                  Custom Tables
2271 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2272 │                                                                       │Count│
2273 ├───────────────────────────────────────────────────────────────────────┼─────┤
2274 │D5a. What would you say is your primary ethnic  Cuban                  │   20│
2275 │background?                                     Mexican                │  311│
2276 │                                                Spanish                │   48│
2277 │                                                South American         │   34│
2278 │                                                Central American       │   52│
2279 │                                                Puerto Rican, OR       │   78│
2280 │                                                Something else         │   68│
2281 │                                                Multiple - cannot      │    7│
2282 │                                                choose one             │     │
2283 ├───────────────────────────────────────────────────────────────────────┼─────┤
2284 │QNS3A                                           Male                   │ 3132│
2285 │                                                Female                 │ 3867│
2286 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2287
2288                   Custom Tables
2289 ╭─────────────────────────────────────────┬─────╮
2290 │                                         │Count│
2291 ├─────────────────────────────────────────┼─────┤
2292 │QND5A        Cuban                       │   20│
2293 │             Mexican                     │  311│
2294 │             Spanish                     │   48│
2295 │             South American              │   34│
2296 │             Central American            │   52│
2297 │             Puerto Rican, OR            │   78│
2298 │             Something else              │   68│
2299 │             Multiple - cannot choose one│    7│
2300 ├─────────────────────────────────────────┼─────┤
2301 │S3a. GENDER: Male                        │ 3132│
2302 │             Female                      │ 3867│
2303 ╰─────────────────────────────────────────┴─────╯
2304
2305                                  Custom Tables
2306 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2307 │                                                                       │Count│
2308 ├───────────────────────────────────────────────────────────────────────┼─────┤
2309 │D5a. What would you say is your primary ethnic  Cuban                  │   20│
2310 │background?                                     Mexican                │  311│
2311 │                                                Spanish                │   48│
2312 │                                                South American         │   34│
2313 │                                                Central American       │   52│
2314 │                                                Puerto Rican, OR       │   78│
2315 │                                                Something else         │   68│
2316 │                                                Multiple - cannot      │    7│
2317 │                                                choose one             │     │
2318 ├───────────────────────────────────────────────────────────────────────┼─────┤
2319 │Male                                                                   │ 3132│
2320 ├───────────────────────────────────────────────────────────────────────┼─────┤
2321 │Female                                                                 │ 3867│
2322 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2323
2324             Custom Tables
2325 ╭─────────────────────────────┬─────╮
2326 │                             │Count│
2327 ├─────────────────────────────┼─────┤
2328 │Cuban                        │   20│
2329 ├─────────────────────────────┼─────┤
2330 │Mexican                      │  311│
2331 ├─────────────────────────────┼─────┤
2332 │Spanish                      │   48│
2333 ├─────────────────────────────┼─────┤
2334 │South American               │   34│
2335 ├─────────────────────────────┼─────┤
2336 │Central American             │   52│
2337 ├─────────────────────────────┼─────┤
2338 │Puerto Rican, OR             │   78│
2339 ├─────────────────────────────┼─────┤
2340 │Something else               │   68│
2341 ├─────────────────────────────┼─────┤
2342 │Multiple - cannot choose one │    7│
2343 ├─────────────────────────────┼─────┤
2344 │S3a. GENDER:     Male        │ 3132│
2345 │                 Female      │ 3867│
2346 ╰─────────────────────────────┴─────╯
2347
2348             Custom Tables
2349 ╭────────────────────────────┬─────╮
2350 │                            │Count│
2351 ├────────────────────────────┼─────┤
2352 │Cuban                       │   20│
2353 │Mexican                     │  311│
2354 │Spanish                     │   48│
2355 │South American              │   34│
2356 │Central American            │   52│
2357 │Puerto Rican, OR            │   78│
2358 │Something else              │   68│
2359 │Multiple - cannot choose one│    7│
2360 │Male                        │ 3132│
2361 │Female                      │ 3867│
2362 ╰────────────────────────────┴─────╯
2363 ])
2364 AT_CLEANUP
2365
2366 AT_SETUP([CTABLES VLABELS - nested variables])
2367 AT_KEYWORDS([nest nesting])
2368 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2369 AT_DATA([ctables.sps],
2370 [[GET 'nhtsa.sav'.
2371 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a > qns3a.
2372 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a > qns3a.
2373 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a > qns3a.
2374 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
2375 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
2376 ]])
2377 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2378                                  Custom Tables
2379 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2380 │                                                                       │Count│
2381 ├───────────────────────────────────────────────────────────────────────┼─────┤
2382 │D5a. What would you say is your       Cuban                QNS3A Male  │   13│
2383 │primary ethnic background?                                       Female│    7│
2384 │                                     ╶─────────────────────────────────┼─────┤
2385 │                                      Mexican              QNS3A Male  │  175│
2386 │                                                                 Female│  136│
2387 │                                     ╶─────────────────────────────────┼─────┤
2388 │                                      Spanish              QNS3A Male  │   20│
2389 │                                                                 Female│   28│
2390 │                                     ╶─────────────────────────────────┼─────┤
2391 │                                      South American       QNS3A Male  │   21│
2392 │                                                                 Female│   13│
2393 │                                     ╶─────────────────────────────────┼─────┤
2394 │                                      Central American     QNS3A Male  │   27│
2395 │                                                                 Female│   25│
2396 │                                     ╶─────────────────────────────────┼─────┤
2397 │                                      Puerto Rican, OR     QNS3A Male  │   37│
2398 │                                                                 Female│   41│
2399 │                                     ╶─────────────────────────────────┼─────┤
2400 │                                      Something else       QNS3A Male  │   35│
2401 │                                                                 Female│   33│
2402 │                                     ╶─────────────────────────────────┼─────┤
2403 │                                      Multiple - cannot    QNS3A Male  │    2│
2404 │                                      choose one                 Female│    5│
2405 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2406
2407                          Custom Tables
2408 ╭──────────────────────────────────────────────────────┬─────╮
2409 │                                                      │Count│
2410 ├──────────────────────────────────────────────────────┼─────┤
2411 │QND5A Cuban                        S3a. GENDER: Male  │   13│
2412 │                                                Female│    7│
2413 │     ╶────────────────────────────────────────────────┼─────┤
2414 │      Mexican                      S3a. GENDER: Male  │  175│
2415 │                                                Female│  136│
2416 │     ╶────────────────────────────────────────────────┼─────┤
2417 │      Spanish                      S3a. GENDER: Male  │   20│
2418 │                                                Female│   28│
2419 │     ╶────────────────────────────────────────────────┼─────┤
2420 │      South American               S3a. GENDER: Male  │   21│
2421 │                                                Female│   13│
2422 │     ╶────────────────────────────────────────────────┼─────┤
2423 │      Central American             S3a. GENDER: Male  │   27│
2424 │                                                Female│   25│
2425 │     ╶────────────────────────────────────────────────┼─────┤
2426 │      Puerto Rican, OR             S3a. GENDER: Male  │   37│
2427 │                                                Female│   41│
2428 │     ╶────────────────────────────────────────────────┼─────┤
2429 │      Something else               S3a. GENDER: Male  │   35│
2430 │                                                Female│   33│
2431 │     ╶────────────────────────────────────────────────┼─────┤
2432 │      Multiple - cannot choose one S3a. GENDER: Male  │    2│
2433 │                                                Female│    5│
2434 ╰──────────────────────────────────────────────────────┴─────╯
2435
2436                                  Custom Tables
2437 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2438 │                                                                       │Count│
2439 ├───────────────────────────────────────────────────────────────────────┼─────┤
2440 │D5a. What would you say is your primary    Cuban                 Male  │   13│
2441 │ethnic background?                                               Female│    7│
2442 │                                          ╶────────────────────────────┼─────┤
2443 │                                           Mexican               Male  │  175│
2444 │                                                                 Female│  136│
2445 │                                          ╶────────────────────────────┼─────┤
2446 │                                           Spanish               Male  │   20│
2447 │                                                                 Female│   28│
2448 │                                          ╶────────────────────────────┼─────┤
2449 │                                           South American        Male  │   21│
2450 │                                                                 Female│   13│
2451 │                                          ╶────────────────────────────┼─────┤
2452 │                                           Central American      Male  │   27│
2453 │                                                                 Female│   25│
2454 │                                          ╶────────────────────────────┼─────┤
2455 │                                           Puerto Rican, OR      Male  │   37│
2456 │                                                                 Female│   41│
2457 │                                          ╶────────────────────────────┼─────┤
2458 │                                           Something else        Male  │   35│
2459 │                                                                 Female│   33│
2460 │                                          ╶────────────────────────────┼─────┤
2461 │                                           Multiple - cannot     Male  │    2│
2462 │                                           choose one            Female│    5│
2463 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2464
2465                       Custom Tables
2466 ╭────────────────────────────────────────────────┬─────╮
2467 │                                                │Count│
2468 ├────────────────────────────────────────────────┼─────┤
2469 │Cuban                        S3a. GENDER: Male  │   13│
2470 │                                          Female│    7│
2471 ├────────────────────────────────────────────────┼─────┤
2472 │Mexican                      S3a. GENDER: Male  │  175│
2473 │                                          Female│  136│
2474 ├────────────────────────────────────────────────┼─────┤
2475 │Spanish                      S3a. GENDER: Male  │   20│
2476 │                                          Female│   28│
2477 ├────────────────────────────────────────────────┼─────┤
2478 │South American               S3a. GENDER: Male  │   21│
2479 │                                          Female│   13│
2480 ├────────────────────────────────────────────────┼─────┤
2481 │Central American             S3a. GENDER: Male  │   27│
2482 │                                          Female│   25│
2483 ├────────────────────────────────────────────────┼─────┤
2484 │Puerto Rican, OR             S3a. GENDER: Male  │   37│
2485 │                                          Female│   41│
2486 ├────────────────────────────────────────────────┼─────┤
2487 │Something else               S3a. GENDER: Male  │   35│
2488 │                                          Female│   33│
2489 ├────────────────────────────────────────────────┼─────┤
2490 │Multiple - cannot choose one S3a. GENDER: Male  │    2│
2491 │                                          Female│    5│
2492 ╰────────────────────────────────────────────────┴─────╯
2493
2494                Custom Tables
2495 ╭───────────────────────────────────┬─────╮
2496 │                                   │Count│
2497 ├───────────────────────────────────┼─────┤
2498 │Cuban                        Male  │   13│
2499 │                             Female│    7│
2500 ├───────────────────────────────────┼─────┤
2501 │Mexican                      Male  │  175│
2502 │                             Female│  136│
2503 ├───────────────────────────────────┼─────┤
2504 │Spanish                      Male  │   20│
2505 │                             Female│   28│
2506 ├───────────────────────────────────┼─────┤
2507 │South American               Male  │   21│
2508 │                             Female│   13│
2509 ├───────────────────────────────────┼─────┤
2510 │Central American             Male  │   27│
2511 │                             Female│   25│
2512 ├───────────────────────────────────┼─────┤
2513 │Puerto Rican, OR             Male  │   37│
2514 │                             Female│   41│
2515 ├───────────────────────────────────┼─────┤
2516 │Something else               Male  │   35│
2517 │                             Female│   33│
2518 ├───────────────────────────────────┼─────┤
2519 │Multiple - cannot choose one Male  │    2│
2520 │                             Female│    5│
2521 ╰───────────────────────────────────┴─────╯
2522 ])
2523 AT_CLEANUP
2524
2525 AT_SETUP([CTABLES FORMAT EMPTY])
2526 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2527 AT_DATA([ctables.sps],
2528 [[GET 'nhtsa.sav'.
2529 CTABLES /FORMAT EMPTY=ZERO /TABLE qnd5a BY qnd5.
2530 CTABLES /FORMAT EMPTY=BLANK /TABLE qnd5a BY qnd5.
2531 CTABLES /FORMAT EMPTY='n/a' /TABLE qnd5a BY qnd5.
2532 ]])
2533 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2534                                  Custom Tables
2535 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2536 │                                             │   D5. ETHNICITY: Are you of   │
2537 │                                             │  Hispanic or Latino origin or │
2538 │                                             │            descent?           │
2539 │                                             ├───────────────┬───────────────┤
2540 │                                             │      Yes      │       No      │
2541 │                                             ├───────────────┼───────────────┤
2542 │                                             │     Count     │     Count     │
2543 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2544 │D5a. What would you say is   Cuban           │             20│              0│
2545 │your primary ethnic          Mexican         │            311│              0│
2546 │background?                  Spanish         │             48│              0│
2547 │                             South American  │             34│              0│
2548 │                             Central American│             52│              0│
2549 │                             Puerto Rican, OR│             78│              0│
2550 │                             Something else  │             68│              0│
2551 │                             Multiple -      │              7│              0│
2552 │                             cannot choose   │               │               │
2553 │                             one             │               │               │
2554 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2555
2556                                  Custom Tables
2557 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2558 │                                             │   D5. ETHNICITY: Are you of   │
2559 │                                             │  Hispanic or Latino origin or │
2560 │                                             │            descent?           │
2561 │                                             ├───────────────┬───────────────┤
2562 │                                             │      Yes      │       No      │
2563 │                                             ├───────────────┼───────────────┤
2564 │                                             │     Count     │     Count     │
2565 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2566 │D5a. What would you say is   Cuban           │             20│               │
2567 │your primary ethnic          Mexican         │            311│               │
2568 │background?                  Spanish         │             48│               │
2569 │                             South American  │             34│               │
2570 │                             Central American│             52│               │
2571 │                             Puerto Rican, OR│             78│               │
2572 │                             Something else  │             68│               │
2573 │                             Multiple -      │              7│               │
2574 │                             cannot choose   │               │               │
2575 │                             one             │               │               │
2576 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2577
2578                                  Custom Tables
2579 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2580 │                                             │   D5. ETHNICITY: Are you of   │
2581 │                                             │  Hispanic or Latino origin or │
2582 │                                             │            descent?           │
2583 │                                             ├───────────────┬───────────────┤
2584 │                                             │      Yes      │       No      │
2585 │                                             ├───────────────┼───────────────┤
2586 │                                             │     Count     │     Count     │
2587 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2588 │D5a. What would you say is   Cuban           │             20│n/a            │
2589 │your primary ethnic          Mexican         │            311│n/a            │
2590 │background?                  Spanish         │             48│n/a            │
2591 │                             South American  │             34│n/a            │
2592 │                             Central American│             52│n/a            │
2593 │                             Puerto Rican, OR│             78│n/a            │
2594 │                             Something else  │             68│n/a            │
2595 │                             Multiple -      │              7│n/a            │
2596 │                             cannot choose   │               │               │
2597 │                             one             │               │               │
2598 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2599 ])
2600 AT_CLEANUP
2601
2602 AT_SETUP([CTABLES FORMAT MISSING])
2603 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2604 AT_DATA([ctables.sps],
2605 [[GET 'nhtsa.sav'.
2606 CTABLES /FORMAT MISSING='(no data)' /TABLE qnd5a[COLPCT] BY qnd5.
2607 ]])
2608 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2609                                  Custom Tables
2610 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2611 │                                             │   D5. ETHNICITY: Are you of   │
2612 │                                             │  Hispanic or Latino origin or │
2613 │                                             │            descent?           │
2614 │                                             ├───────────────┬───────────────┤
2615 │                                             │      Yes      │       No      │
2616 │                                             ├───────────────┼───────────────┤
2617 │                                             │    Column %   │    Column %   │
2618 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2619 │D5a. What would you say is   Cuban           │           3.2%│(no data)      │
2620 │your primary ethnic          Mexican         │          50.3%│(no data)      │
2621 │background?                  Spanish         │           7.8%│(no data)      │
2622 │                             South American  │           5.5%│(no data)      │
2623 │                             Central American│           8.4%│(no data)      │
2624 │                             Puerto Rican, OR│          12.6%│(no data)      │
2625 │                             Something else  │          11.0%│(no data)      │
2626 │                             Multiple -      │           1.1%│(no data)      │
2627 │                             cannot choose   │               │               │
2628 │                             one             │               │               │
2629 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2630 ])
2631 AT_CLEANUP
2632
2633 AT_SETUP([CTABLES HIDESMALLCOUNTS])
2634 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2635 AT_DATA([ctables.sps],
2636 [[GET 'nhtsa.sav'.
2637 CTABLES /TABLE qn38[c][COUNT, COLPCT].
2638 CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
2639 CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
2640 ]])
2641 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2642                                  Custom Tables
2643 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2644 │                                                              │Count│Column %│
2645 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2646 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2647 │occasion?                                        1            │  491│   34.9%│
2648 │                                                 2            │  462│   32.9%│
2649 │                                                 3            │  229│   16.3%│
2650 │                                                 4            │   82│    5.8%│
2651 │                                                 5            │   56│    4.0%│
2652 │                                                 6            │   32│    2.3%│
2653 │                                                 7            │    9│     .6%│
2654 │                                                 8            │    8│     .6%│
2655 │                                                 9            │    4│     .3%│
2656 │                                                 10           │    6│     .4%│
2657 │                                                 11           │    2│     .1%│
2658 │                                                 12           │    5│     .4%│
2659 │                                                 14           │    1│     .1%│
2660 │                                                 15           │    1│     .1%│
2661 │                                                 18           │    1│     .1%│
2662 │                                                 20           │    4│     .3%│
2663 │                                                 25           │    1│     .1%│
2664 │                                                 30           │    3│     .2%│
2665 │                                                 60           │    1│     .1%│
2666 │                                                 99+          │    0│     .0%│
2667 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2668
2669                                  Custom Tables
2670 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2671 │                                                              │Count│Column %│
2672 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2673 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2674 │occasion?                                        1            │  491│   34.9%│
2675 │                                                 2            │  462│   32.9%│
2676 │                                                 3            │  229│   16.3%│
2677 │                                                 4            │   82│    5.8%│
2678 │                                                 5            │   56│    4.0%│
2679 │                                                 6            │   32│    2.3%│
2680 │                                                 7            │    9│     .6%│
2681 │                                                 8            │    8│     .6%│
2682 │                                                 9            │<5   │     .3%│
2683 │                                                 10           │    6│     .4%│
2684 │                                                 11           │<5   │     .1%│
2685 │                                                 12           │    5│     .4%│
2686 │                                                 14           │<5   │     .1%│
2687 │                                                 15           │<5   │     .1%│
2688 │                                                 18           │<5   │     .1%│
2689 │                                                 20           │<5   │     .3%│
2690 │                                                 25           │<5   │     .1%│
2691 │                                                 30           │<5   │     .2%│
2692 │                                                 60           │<5   │     .1%│
2693 │                                                 99+          │<5   │     .0%│
2694 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2695
2696                                  Custom Tables
2697 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2698 │                                                              │Count│Column %│
2699 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2700 │38. How many drinks did you have on that         Less than one│<10  │     .5%│
2701 │occasion?                                        1            │  491│   34.9%│
2702 │                                                 2            │  462│   32.9%│
2703 │                                                 3            │  229│   16.3%│
2704 │                                                 4            │   82│    5.8%│
2705 │                                                 5            │   56│    4.0%│
2706 │                                                 6            │   32│    2.3%│
2707 │                                                 7            │<10  │     .6%│
2708 │                                                 8            │<10  │     .6%│
2709 │                                                 9            │<10  │     .3%│
2710 │                                                 10           │<10  │     .4%│
2711 │                                                 11           │<10  │     .1%│
2712 │                                                 12           │<10  │     .4%│
2713 │                                                 14           │<10  │     .1%│
2714 │                                                 15           │<10  │     .1%│
2715 │                                                 18           │<10  │     .1%│
2716 │                                                 20           │<10  │     .3%│
2717 │                                                 25           │<10  │     .1%│
2718 │                                                 30           │<10  │     .2%│
2719 │                                                 60           │<10  │     .1%│
2720 │                                                 99+          │<10  │     .0%│
2721 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2722 ])
2723 AT_CLEANUP
2724
2725 AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
2726 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2727 AT_DATA([ctables.sps],
2728 [[GET 'nhtsa.sav'.
2729 CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
2730 ]])
2731 AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
2732  Custom Tables
2733 ╭────────────╮
2734 │S3a. GENDER:│
2735 ├─────┬──────┤
2736 │ Male│Female│
2737 ├─────┼──────┤
2738 │Count│ Count│
2739 ├─────┼──────┤
2740 │ 3132│  3867│
2741 ╰─────┴──────╯
2742 ])
2743 AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
2744 AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
2745 maximumColumnWidth="192"
2746 minimumColumnWidth="96"
2747 ])
2748 AT_CLEANUP
2749
2750 AT_SETUP([CTABLES special formats])
2751 AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
2752 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2753 AT_DATA([ctables.sps],
2754 [[GET 'nhtsa.sav'.
2755 COMPUTE x = qnd3 - 4.
2756 CTABLES /TABLE x[MINIMUM NEGPAREN8.1, MINIMUM NEQUAL8.1, MINIMUM PAREN8.1, MINIMUM PCTPAREN8.1, MAXIMUM NEGPAREN8.1, MAXIMUM NEQUAL8.1, MAXIMUM PAREN8.1, MAXIMUM PCTPAREN8.1].
2757 ]])
2758 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2759                            Custom Tables
2760 ╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
2761 │ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
2762 ├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
2763 │x│(3.0)  │N=-3.0 │(-3.0) │(-3.0%)│8.0    │N=8.0  │(8.0)  │(8.0%) │
2764 ╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
2765 ])
2766 AT_CLEANUP
2767
2768 AT_SETUP([CTABLES TITLES])
2769 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2770 AT_DATA([ctables.sps],
2771 [[GET 'nhtsa.sav'.
2772 CTABLES
2773     /VLABELS VARIABLES=qn1 DISPLAY=NONE
2774     /TABLE ((qn1[c][COUNT])) BY qns3a[c] > qnd5
2775     /TITLES TITLE='How often do you drive?'
2776             CAPTION='Generated )TIME on )DATE'
2777             CORNER=')TABLE'.
2778 ]])
2779 AT_CHECK([pspp ctables.sps -O box=unicode | sed 's/..:..:../HH:MM:SS/
2780 s&../../..&MM/DD/YY&'], [0], [dnl
2781                             How often do you drive?
2782 ╭───────────────────────────────────┬─────────────────────────────────────────╮
2783 │                                   │               S3a. GENDER:              │
2784 │                                   ├────────────────────┬────────────────────┤
2785 │                                   │        Male        │       Female       │
2786 │                                   ├────────────────────┼────────────────────┤
2787 │                                   │ D5. ETHNICITY: Are │ D5. ETHNICITY: Are │
2788 │                                   │ you of Hispanic or │ you of Hispanic or │
2789 │                                   │  Latino origin or  │  Latino origin or  │
2790 │( ( 1. How often do you usually    │      descent?      │      descent?      │
2791 │drive a car or other motor         ├─────────┬──────────┼─────────┬──────────┤
2792 │vehicle?) ) BY S3a. GENDER: > D5.  │   Yes   │    No    │   Yes   │    No    │
2793 │ETHNICITY: Are you of Hispanic or  ├─────────┼──────────┼─────────┼──────────┤
2794 │Latino origin or descent?          │  Count  │   Count  │  Count  │   Count  │
2795 ├───────────────────────────────────┼─────────┼──────────┼─────────┼──────────┤
2796 │Every day                          │      218│      2066│      166│      2175│
2797 │Several days a week                │       44│       391│       45│       782│
2798 │Once a week or less                │       16│       109│       12│       223│
2799 │Only certain times a year          │       15│        41│       11│        61│
2800 │Never                              │       39│       150│       56│       278│
2801 ╰───────────────────────────────────┴─────────┴──────────┴─────────┴──────────╯
2802 Generated HH:MM:SS on MM/DD/YY
2803 ])
2804 AT_CLEANUP
2805
2806 AT_SETUP([CTABLES area definitions])
2807 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2808 AT_DATA([ctables.sps],
2809 [[GET 'nhtsa.sav'.
2810 CTABLES
2811     /VLABELS VARIABLES=ALL DISPLAY=NAME
2812     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[TABLE.ID, LAYER.ID, SUBTABLE.ID]
2813     /SLABELS POSITION=ROW
2814     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[ROW.ID, LAYERROW.ID]
2815     /SLABELS POSITION=ROW
2816     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[COL.ID, LAYERCOL.ID]
2817     /SLABELS POSITION=ROW.
2818 ]])
2819 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=80], [0], [dnl
2820                     Custom Tables
2821 Male
2822 ╭─────────────────────────────┬─────────────┬──────╮
2823 │                             │    QND7A    │ QN64B│
2824 │                             ├──────┬──────┼───┬──┤
2825 │                             │  Yes │  No  │   │  │
2826 │                             ├──────┼──────┤   │  │
2827 │                             │ QN86 │ QN86 │   │  │
2828 │                             ├───┬──┼───┬──┤   │  │
2829 │                             │Yes│No│Yes│No│Yes│No│
2830 ├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
2831 │QN61 Yes QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
2832 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
2833 │                  Subtable ID│  1│ 1│  2│ 2│  3│ 3│
2834 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
2835 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
2836 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
2837 │                  Subtable ID│  1│ 1│  2│ 2│  3│ 3│
2838 │    ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
2839 │     No  QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
2840 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
2841 │                  Subtable ID│  4│ 4│  5│ 5│  6│ 6│
2842 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
2843 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
2844 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
2845 │                  Subtable ID│  4│ 4│  5│ 5│  6│ 6│
2846 ╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
2847
2848                     Custom Tables
2849 Female
2850 ╭─────────────────────────────┬─────────────┬──────╮
2851 │                             │    QND7A    │ QN64B│
2852 │                             ├──────┬──────┼───┬──┤
2853 │                             │  Yes │  No  │   │  │
2854 │                             ├──────┼──────┤   │  │
2855 │                             │ QN86 │ QN86 │   │  │
2856 │                             ├───┬──┼───┬──┤   │  │
2857 │                             │Yes│No│Yes│No│Yes│No│
2858 ├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
2859 │QN61 Yes QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
2860 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
2861 │                  Subtable ID│  7│ 7│  8│ 8│  9│ 9│
2862 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
2863 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
2864 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
2865 │                  Subtable ID│  7│ 7│  8│ 8│  9│ 9│
2866 │    ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
2867 │     No  QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
2868 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
2869 │                  Subtable ID│ 10│10│ 11│11│ 12│12│
2870 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
2871 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
2872 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
2873 │                  Subtable ID│ 10│10│ 11│11│ 12│12│
2874 ╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
2875
2876                     Custom Tables
2877 Male
2878 ╭──────────────────────────────┬─────────────┬──────╮
2879 │                              │    QND7A    │ QN64B│
2880 │                              ├──────┬──────┼───┬──┤
2881 │                              │  Yes │  No  │   │  │
2882 │                              ├──────┼──────┤   │  │
2883 │                              │ QN86 │ QN86 │   │  │
2884 │                              ├───┬──┼───┬──┤   │  │
2885 │                              │Yes│No│Yes│No│Yes│No│
2886 ├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
2887 │QN61 Yes QN57 Yes Row ID      │  1│ 1│  2│ 2│  3│ 3│
2888 │                  Layer Row ID│  1│ 1│  1│ 1│  2│ 2│
2889 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
2890 │              No  Row ID      │  4│ 4│  5│ 5│  6│ 6│
2891 │                  Layer Row ID│  3│ 3│  3│ 3│  4│ 4│
2892 │    ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
2893 │     No  QN57 Yes Row ID      │  7│ 7│  8│ 8│  9│ 9│
2894 │                  Layer Row ID│  5│ 5│  5│ 5│  6│ 6│
2895 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
2896 │              No  Row ID      │ 10│10│ 11│11│ 12│12│
2897 │                  Layer Row ID│  7│ 7│  7│ 7│  8│ 8│
2898 ╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
2899
2900                     Custom Tables
2901 Female
2902 ╭──────────────────────────────┬─────────────┬──────╮
2903 │                              │    QND7A    │ QN64B│
2904 │                              ├──────┬──────┼───┬──┤
2905 │                              │  Yes │  No  │   │  │
2906 │                              ├──────┼──────┤   │  │
2907 │                              │ QN86 │ QN86 │   │  │
2908 │                              ├───┬──┼───┬──┤   │  │
2909 │                              │Yes│No│Yes│No│Yes│No│
2910 ├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
2911 │QN61 Yes QN57 Yes Row ID      │ 13│13│ 14│14│ 15│15│
2912 │                  Layer Row ID│  9│ 9│  9│ 9│ 10│10│
2913 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
2914 │              No  Row ID      │ 16│16│ 17│17│ 18│18│
2915 │                  Layer Row ID│ 11│11│ 11│11│ 12│12│
2916 │    ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
2917 │     No  QN57 Yes Row ID      │ 19│19│ 20│20│ 21│21│
2918 │                  Layer Row ID│ 13│13│ 13│13│ 14│14│
2919 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
2920 │              No  Row ID      │ 22│22│ 23│23│ 24│24│
2921 │                  Layer Row ID│ 15│15│ 15│15│ 16│16│
2922 ╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
2923
2924                       Custom Tables
2925 Male
2926 ╭─────────────────────────────────┬─────────────┬──────╮
2927 │                                 │    QND7A    │ QN64B│
2928 │                                 ├──────┬──────┼───┬──┤
2929 │                                 │  Yes │  No  │   │  │
2930 │                                 ├──────┼──────┤   │  │
2931 │                                 │ QN86 │ QN86 │   │  │
2932 │                                 ├───┬──┼───┬──┤   │  │
2933 │                                 │Yes│No│Yes│No│Yes│No│
2934 ├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
2935 │QN61 Yes QN57 Yes Column ID      │  1│ 2│  3│ 4│  5│ 6│
2936 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
2937 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
2938 │              No  Column ID      │  1│ 2│  3│ 4│  5│ 6│
2939 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
2940 │    ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
2941 │     No  QN57 Yes Column ID      │  7│ 8│  9│10│ 11│12│
2942 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
2943 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
2944 │              No  Column ID      │  7│ 8│  9│10│ 11│12│
2945 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
2946 ╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
2947
2948                       Custom Tables
2949 Female
2950 ╭─────────────────────────────────┬─────────────┬──────╮
2951 │                                 │    QND7A    │ QN64B│
2952 │                                 ├──────┬──────┼───┬──┤
2953 │                                 │  Yes │  No  │   │  │
2954 │                                 ├──────┼──────┤   │  │
2955 │                                 │ QN86 │ QN86 │   │  │
2956 │                                 ├───┬──┼───┬──┤   │  │
2957 │                                 │Yes│No│Yes│No│Yes│No│
2958 ├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
2959 │QN61 Yes QN57 Yes Column ID      │ 13│14│ 15│16│ 17│18│
2960 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
2961 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
2962 │              No  Column ID      │ 13│14│ 15│16│ 17│18│
2963 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
2964 │    ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
2965 │     No  QN57 Yes Column ID      │ 19│20│ 21│22│ 23│24│
2966 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
2967 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
2968 │              No  Column ID      │ 19│20│ 21│22│ 23│24│
2969 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
2970 ╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
2971 ])
2972 AT_CLEANUP
2973
2974 AT_SETUP([CTABLES categorical summary functions])
2975 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2976 AT_DATA([ctables.sps],
2977 [[GET 'nhtsa.sav'.
2978 CTABLES
2979     /TABLE region BY qnd5a[COUNT, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTAL[COUNT, VALIDN, TOTALN]]
2980     /CATEGORIES VARIABLES=qnd5a TOTAL=YES MISSING=INCLUDE
2981     /SLABELS POSITION=ROW.
2982 ]])
2983 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2984                                                       Custom Tables
2985 ╭─────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────╮
2986 │                 │                     D5a. What would you say is your primary ethnic background?                     │
2987 │                 ├─────┬───────┬───────┬──────────┬──────────┬─────────┬──────────┬──────────────┬──────┬───────┬─────┤
2988 │                 │     │       │       │          │          │         │          │  Multiple -  │      │       │     │
2989 │                 │     │       │       │   South  │  Central │  Puerto │ Something│ cannot choose│ Don't│       │     │
2990 │                 │Cuban│Mexican│Spanish│ American │ American │Rican, OR│   else   │      one     │ know │Refused│Total│
2991 ├─────────────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
2992 │Region NE Count  │    6│      8│      8│        11│         7│       39│        23│             2│     0│      1│  105│
2993 │          Row %  │ 5.7%│   7.6%│   7.6%│     10.5%│      6.7%│    37.1%│     21.9%│          1.9%│   .0%│   1.0%│     │
2994 │          Row    │ 5.8%│   7.7%│   7.7%│     10.6%│      6.7%│    37.5%│     22.1%│          1.9%│   .0%│    .0%│     │
2995 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
2996 │          %      │     │       │       │          │          │         │          │              │      │       │     │
2997 │          Row    │  .4%│    .6%│    .6%│       .8%│       .5%│     2.8%│      1.6%│           .1%│   .0%│    .1%│     │
2998 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
2999 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3000 │          Valid N│     │       │       │          │          │         │          │              │      │       │  104│
3001 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1409│
3002 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3003 │       MW Count  │    3│     24│      1│         4│         5│        9│         6│             0│     0│      1│   53│
3004 │          Row %  │ 5.7%│  45.3%│   1.9%│      7.5%│      9.4%│    17.0%│     11.3%│           .0%│   .0%│   1.9%│     │
3005 │          Row    │ 5.8%│  46.2%│   1.9%│      7.7%│      9.6%│    17.3%│     11.5%│           .0%│   .0%│    .0%│     │
3006 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3007 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3008 │          Row    │  .2%│   1.5%│    .1%│       .2%│       .3%│      .5%│       .4%│           .0%│   .0%│    .1%│     │
3009 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3010 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3011 │          Valid N│     │       │       │          │          │         │          │              │      │       │   52│
3012 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1654│
3013 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3014 │       S  Count  │   10│    113│     11│        14│        25│       23│        20│             2│     3│      2│  223│
3015 │          Row %  │ 4.5%│  50.7%│   4.9%│      6.3%│     11.2%│    10.3%│      9.0%│           .9%│  1.3%│    .9%│     │
3016 │          Row    │ 4.6%│  51.8%│   5.0%│      6.4%│     11.5%│    10.6%│      9.2%│           .9%│   .0%│    .0%│     │
3017 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3018 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3019 │          Row    │  .4%│   4.7%│    .5%│       .6%│      1.0%│     1.0%│       .8%│           .1%│   .1%│    .1%│     │
3020 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3021 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3022 │          Valid N│     │       │       │          │          │         │          │              │      │       │  218│
3023 │          Total N│     │       │       │          │          │         │          │              │      │       │ 2390│
3024 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3025 │       W  Count  │    1│    166│     28│         5│        15│        7│        19│             3│     0│      1│  245│
3026 │          Row %  │  .4%│  67.8%│  11.4%│      2.0%│      6.1%│     2.9%│      7.8%│          1.2%│   .0%│    .4%│     │
3027 │          Row    │  .4%│  68.0%│  11.5%│      2.0%│      6.1%│     2.9%│      7.8%│          1.2%│   .0%│    .0%│     │
3028 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3029 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3030 │          Row    │  .1%│  10.7%│   1.8%│       .3%│      1.0%│      .5%│      1.2%│           .2%│   .0%│    .1%│     │
3031 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3032 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3033 │          Valid N│     │       │       │          │          │         │          │              │      │       │  244│
3034 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1546│
3035 ╰─────────────────┴─────┴───────┴───────┴──────────┴──────────┴─────────┴──────────┴──────────────┴──────┴───────┴─────╯
3036 ])
3037 AT_CLEANUP
3038
3039
3040 AT_SETUP([CTABLES scale summary functions])
3041 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3042 AT_DATA([ctables.sps],
3043 [[GET 'nhtsa.sav'.
3044 SET TVAR=NAME.
3045
3046 * Use SPLIT FILE with FREQUENCIES to generate output equivalent to
3047   CTABLES later, to make the results easier to verify.
3048 SPLIT FILE BY REGION.
3049 FREQUENCIES
3050     qn19a
3051     /STATISTICS=MEAN SEMEAN MEDIAN MODE STDDEV VARIANCE RANGE MINIMUM MAXIMUM SUM
3052     /FORMAT NOTABLE /MISSING=INCLUDE.
3053 SPLIT FILE OFF.
3054
3055 CTABLES
3056     /VLABELS VARIABLE=qn19a DISPLAY=NAME /*XXX NONE yields an assertion failure
3057     /TABLE region BY qn19a[VALIDN, MISSING, MEAN, SEMEAN, MEDIAN, MODE, STDDEV, VARIANCE, RANGE, MINIMUM, MAXIMUM, SUM, COUNT, TOTALN, COLPCT.SUM]
3058     /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
3059     /SLABELS POSITION=ROW.
3060 ]])
3061 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
3062          Statistics
3063 ╭────────────────┬────────╮
3064 │REGION          │  QN19A │
3065 ├────────────────┼────────┤
3066 │NE     N Valid  │     936│
3067 │         Missing│     473│
3068 │      ╶─────────┼────────┤
3069 │       Mean     │   19.33│
3070 │      ╶─────────┼────────┤
3071 │       S.E. Mean│     .14│
3072 │      ╶─────────┼────────┤
3073 │       Median   │   18.00│
3074 │      ╶─────────┼────────┤
3075 │       Mode     │   18.00│
3076 │      ╶─────────┼────────┤
3077 │       Std Dev  │    4.41│
3078 │      ╶─────────┼────────┤
3079 │       Variance │   19.41│
3080 │      ╶─────────┼────────┤
3081 │       Range    │   59.00│
3082 │      ╶─────────┼────────┤
3083 │       Minimum  │     .00│
3084 │      ╶─────────┼────────┤
3085 │       Maximum  │   59.00│
3086 │      ╶─────────┼────────┤
3087 │       Sum      │18092.00│
3088 ├────────────────┼────────┤
3089 │MW     N Valid  │    1019│
3090 │         Missing│     635│
3091 │      ╶─────────┼────────┤
3092 │       Mean     │   19.83│
3093 │      ╶─────────┼────────┤
3094 │       S.E. Mean│     .16│
3095 │      ╶─────────┼────────┤
3096 │       Median   │   19.00│
3097 │      ╶─────────┼────────┤
3098 │       Mode     │   18.00│
3099 │      ╶─────────┼────────┤
3100 │       Std Dev  │    5.15│
3101 │      ╶─────────┼────────┤
3102 │       Variance │   26.47│
3103 │      ╶─────────┼────────┤
3104 │       Range    │   71.00│
3105 │      ╶─────────┼────────┤
3106 │       Minimum  │    4.00│
3107 │      ╶─────────┼────────┤
3108 │       Maximum  │   75.00│
3109 │      ╶─────────┼────────┤
3110 │       Sum      │20206.00│
3111 ├────────────────┼────────┤
3112 │S      N Valid  │    1276│
3113 │         Missing│    1114│
3114 │      ╶─────────┼────────┤
3115 │       Mean     │   20.29│
3116 │      ╶─────────┼────────┤
3117 │       S.E. Mean│     .18│
3118 │      ╶─────────┼────────┤
3119 │       Median   │   19.00│
3120 │      ╶─────────┼────────┤
3121 │       Mode     │   18.00│
3122 │      ╶─────────┼────────┤
3123 │       Std Dev  │    6.44│
3124 │      ╶─────────┼────────┤
3125 │       Variance │   41.43│
3126 │      ╶─────────┼────────┤
3127 │       Range    │   75.00│
3128 │      ╶─────────┼────────┤
3129 │       Minimum  │    4.00│
3130 │      ╶─────────┼────────┤
3131 │       Maximum  │   79.00│
3132 │      ╶─────────┼────────┤
3133 │       Sum      │25886.00│
3134 ├────────────────┼────────┤
3135 │W      N Valid  │     950│
3136 │         Missing│     596│
3137 │      ╶─────────┼────────┤
3138 │       Mean     │   19.87│
3139 │      ╶─────────┼────────┤
3140 │       S.E. Mean│     .17│
3141 │      ╶─────────┼────────┤
3142 │       Median   │   19.00│
3143 │      ╶─────────┼────────┤
3144 │       Mode     │   18.00│
3145 │      ╶─────────┼────────┤
3146 │       Std Dev  │    5.25│
3147 │      ╶─────────┼────────┤
3148 │       Variance │   27.59│
3149 │      ╶─────────┼────────┤
3150 │       Range    │   61.00│
3151 │      ╶─────────┼────────┤
3152 │       Minimum  │    4.00│
3153 │      ╶─────────┼────────┤
3154 │       Maximum  │   65.00│
3155 │      ╶─────────┼────────┤
3156 │       Sum      │18877.00│
3157 ╰────────────────┴────────╯
3158
3159              Custom Tables
3160 ╭───────────────────────────┬────────╮
3161 │                           │  QN19A │
3162 ├───────────────────────────┼────────┤
3163 │REGION NE Valid N          │     936│
3164 │          Missing          │  473.00│
3165 │          Mean             │   19.33│
3166 │          Std Error of Mean│     .14│
3167 │          Median           │   18.00│
3168 │          Mode             │   18.00│
3169 │          Std Deviation    │    4.41│
3170 │          Variance         │   19.41│
3171 │          Range            │   59.00│
3172 │          Minimum          │     .00│
3173 │          Maximum          │   59.00│
3174 │          Sum              │18092.00│
3175 │          Count            │    1409│
3176 │          Total N          │    1409│
3177 │          Column Sum %     │   21.8%│
3178 │      ╶────────────────────┼────────┤
3179 │       MW Valid N          │    1019│
3180 │          Missing          │  635.00│
3181 │          Mean             │   19.83│
3182 │          Std Error of Mean│     .16│
3183 │          Median           │   19.00│
3184 │          Mode             │   18.00│
3185 │          Std Deviation    │    5.15│
3186 │          Variance         │   26.47│
3187 │          Range            │   71.00│
3188 │          Minimum          │    4.00│
3189 │          Maximum          │   75.00│
3190 │          Sum              │20206.00│
3191 │          Count            │    1654│
3192 │          Total N          │    1654│
3193 │          Column Sum %     │   24.3%│
3194 │      ╶────────────────────┼────────┤
3195 │       S  Valid N          │    1276│
3196 │          Missing          │ 1114.00│
3197 │          Mean             │   20.29│
3198 │          Std Error of Mean│     .18│
3199 │          Median           │   19.00│
3200 │          Mode             │   18.00│
3201 │          Std Deviation    │    6.44│
3202 │          Variance         │   41.43│
3203 │          Range            │   75.00│
3204 │          Minimum          │    4.00│
3205 │          Maximum          │   79.00│
3206 │          Sum              │25886.00│
3207 │          Count            │    2390│
3208 │          Total N          │    2390│
3209 │          Column Sum %     │   31.2%│
3210 │      ╶────────────────────┼────────┤
3211 │       W  Valid N          │     950│
3212 │          Missing          │  596.00│
3213 │          Mean             │   19.87│
3214 │          Std Error of Mean│     .17│
3215 │          Median           │   19.00│
3216 │          Mode             │   18.00│
3217 │          Std Deviation    │    5.25│
3218 │          Variance         │   27.59│
3219 │          Range            │   61.00│
3220 │          Minimum          │    4.00│
3221 │          Maximum          │   65.00│
3222 │          Sum              │18877.00│
3223 │          Count            │    1546│
3224 │          Total N          │    1546│
3225 │          Column Sum %     │   22.7%│
3226 ╰───────────────────────────┴────────╯
3227 ])
3228 AT_CLEANUP
3229
3230
3231 AT_SETUP([CTABLES hidden scale VLABELS])
3232 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3233 AT_DATA([ctables.sps],
3234 [[GET 'nhtsa.sav'.
3235 CTABLES
3236     /TABLE region BY qn19a + qn35
3237     /SLABELS POSITION=ROW.
3238 CTABLES
3239     /VLABELS VARIABLE=qn19a DISPLAY=NONE
3240     /TABLE region BY qn19a + qn35
3241     /SLABELS POSITION=ROW.
3242 CTABLES
3243     /VLABELS VARIABLE=qn35 DISPLAY=NONE
3244     /TABLE region BY qn19a + qn35
3245     /SLABELS POSITION=ROW.
3246
3247 * This one in particular caused a crash because no categories were
3248   created on the column axis, so passing in 0 for the index was still
3249   too big for that number of categories.  It was fixed by creating a
3250   name-only category for each variable despite the "NONE" request,
3251   then hiding the entire dimension's labels if all its labels were
3252   set to "NONE".
3253 CTABLES
3254     /VLABELS VARIABLE=qn19a qn35 DISPLAY=NONE
3255     /TABLE region BY qn19a + qn35
3256     /SLABELS POSITION=ROW.
3257 ]])
3258 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
3259                                  Custom Tables
3260 ╭──────────────┬────────────────────────────┬─────────────────────────────────╮
3261 │              │ 19a. About how old were you│ 35. In the past thirty days, how│
3262 │              │   when you first starting  │   many times have you driven a  │
3263 │              │    drinking alcohol, not   │  motor vehicle WITHIN TWO HOURS │
3264 │              │  counting small tastes or  │     AFTER drinking alcoholic    │
3265 │              │      sips of alcohol.      │            beverages?           │
3266 ├──────────────┼────────────────────────────┼─────────────────────────────────┤
3267 │Region NE Mean│                       19.33│                                2│
3268 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3269 │       MW Mean│                       19.83│                                2│
3270 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3271 │       S  Mean│                       20.29│                                2│
3272 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3273 │       W  Mean│                       19.87│                                2│
3274 ╰──────────────┴────────────────────────────┴─────────────────────────────────╯
3275
3276                                  Custom Tables
3277 ╭──────────────┬─────┬────────────────────────────────────────────────────────╮
3278 │              │     │  35. In the past thirty days, how many times have you  │
3279 │              │     │ driven a motor vehicle WITHIN TWO HOURS AFTER drinking │
3280 │              │QN19A│                  alcoholic beverages?                  │
3281 ├──────────────┼─────┼────────────────────────────────────────────────────────┤
3282 │Region NE Mean│19.33│                                                       2│
3283 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3284 │       MW Mean│19.83│                                                       2│
3285 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3286 │       S  Mean│20.29│                                                       2│
3287 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3288 │       W  Mean│19.87│                                                       2│
3289 ╰──────────────┴─────┴────────────────────────────────────────────────────────╯
3290
3291                                  Custom Tables
3292 ╭──────────────┬─────────────────────────────────────────────────────────┬────╮
3293 │              │   19a. About how old were you when you first starting   │    │
3294 │              │  drinking alcohol, not counting small tastes or sips of │    │
3295 │              │                         alcohol.                        │qn35│
3296 ├──────────────┼─────────────────────────────────────────────────────────┼────┤
3297 │Region NE Mean│                                                    19.33│   2│
3298 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3299 │       MW Mean│                                                    19.83│   2│
3300 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3301 │       S  Mean│                                                    20.29│   2│
3302 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3303 │       W  Mean│                                                    19.87│   2│
3304 ╰──────────────┴─────────────────────────────────────────────────────────┴────╯
3305
3306       Custom Tables
3307 ╭──────────────┬───────╮
3308 │Region NE Mean│19.33 2│
3309 │      ╶───────┼───────┤
3310 │       MW Mean│19.83 2│
3311 │      ╶───────┼───────┤
3312 │       S  Mean│20.29 2│
3313 │      ╶───────┼───────┤
3314 │       W  Mean│19.87 2│
3315 ╰──────────────┴───────╯
3316 ])
3317 AT_CLEANUP
3318