82e0f9bea8bfc703cc6cdc99331461437a8a12a7
[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 - String variables and values
6 dnl - Testing details of missing value handling in summaries.
7 dnl - test CLABELS ROWLABELS=LAYER.
8 dnl - Test VLABELS.
9 dnl - Test WEIGHT and adjustment weights.
10 dnl - EMPTY=INCLUDE For string ranges.
11 dnl - Summary functions:
12 dnl   * Separate summary functions for totals and subtotals.
13 dnl   * )CILEVEL in summary label specification
14 dnl Category sorting:
15 dnl   * VALUE
16 dnl   * LABEL
17 dnl   * ascending/descending
18 dnl - CATEGORIES:
19 dnl   * String values
20 dnl   * Date values
21 dnl   * THRU (numeric ranges)
22 dnl   * THRU (string ranges)
23 dnl   * OTHERNM
24 dnl - FORMAT:
25 dnl   * MINCOLWIDTH, MAXCOLWIDTH, UNITS.
26 dnl   * EMPTY.
27 dnl   * MISSING.
28 dnl - HIDESMALLCOUNTS.
29 dnl - Date/time variables and values
30 dnl - Special formats for summary functions: NEGPAREN, NEQUAL, PAREN, PCTPAREN.
31 dnl - TITLES: )DATE, )TIME, )TABLE.
32 dnl - Test PCOMPUTE:
33 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
34 dnl   * MISSING, OTHERNM
35 dnl   * strings and string ranges
36 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
37 dnl   * dates
38 dnl - PPROPERTIES:
39 dnl   * )LABEL[N].
40 dnl - Summary functions:
41 dnl   * U-prefix for unweighted summaries.
42 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
43 dnl - SPLIT FILE with SEPARATE splits
44 dnl - Definition of columns/rows when labels are rotated from one axis to another.
45 dnl
46 dnl Not for v1:
47 dnl - Multiple response sets
48 dnl - MRSETS subcommand.
49 dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
50 dnl - SIGTEST
51 dnl - COMPARETEST
52 dnl - Summary functions:
53 dnl   * .LCL and .UCL suffixes.
54 dnl   * .SE suffixes.
55 dnl - CATEGORIES:
56 dnl   * Data-dependent sorting.
57 dnl
58 dnl
59 dnl Bug:
60 dnl     CTABLES /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a.
61 dnl produces a bad median:
62 dnl                     Custom Tables
63 dnl +--------------------------+-----------------------+
64 dnl |                          |      S3a. GENDER:     |
65 dnl |                          +-----------+-----------+
66 dnl |                          |    Male   |   Female  |
67 dnl |                          +----+------+----+------+
68 dnl |                          |Mean|Median|Mean|Median|
69 dnl +--------------------------+----+------+----+------+
70 dnl |D1. AGE: What is your age?|  46|   999|  50|   999|
71 dnl +--------------------------+----+------+----+------+
72
73
74
75 AT_SETUP([CTABLES parsing])
76 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
77 AT_DATA([ctables.sps],
78 [[GET 'nhtsa.sav'.
79 CTABLES
80     /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
81     /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
82     /FORMAT UNITS=CM EMPTY="(-)"
83     /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
84     /VLABELS VARIABLES=qn17 DISPLAY=NAME
85     /VLABELS VARIABLES=qns3a DISPLAY=LABEL
86     /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
87     /VLABELS VARIABLES=qn20 DISPLAY=NONE
88     /MRSETS COUNTDUPLICATES=NO
89     /MRSETS COUNTDUPLICATES=YES
90     /SMISSING VARIABLE
91     /SMISSING LISTWISE
92     /WEIGHT VARIABLE=qns3a
93     /HIDESMALLCOUNTS
94     /HIDESMALLCOUNTS COUNT=10
95     /TABLE qnsa1
96     /SLABELS POSITION=COLUMN VISIBLE=YES
97     /SLABELS VISIBLE=NO POSITION=ROW
98     /SLABELS POSITION=LAYER
99     /CLABELS AUTO
100     /CLABELS ROWLABELS=OPPOSITE
101     /CRITERIA CILEVEL=50
102     /CATEGORIES VARIABLES=qn1 qn17
103                 ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
104                 POSITION=BEFORE EMPTY=INCLUDE.
105 CTABLES /TABLE qnsa1 /CLABELS ROWLABELS=LAYER.
106 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=OPPOSITE.
107 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=LAYER.
108 ]])
109 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
110          Custom Tables
111 Count
112 ╭───────────────────┬────┬────╮
113 │                   │ RDD│CELL│
114 ├───────────────────┼────┼────┤
115 │Sa1. SAMPLE SOURCE:│5392│1607│
116 ╰───────────────────┴────┴────╯
117
118        Custom Tables
119 RDD
120 ╭───────────────────┬─────╮
121 │                   │Count│
122 ├───────────────────┼─────┤
123 │Sa1. SAMPLE SOURCE:│ 5392│
124 ╰───────────────────┴─────╯
125
126           Custom Tables
127 ╭────────────────────────┬─────╮
128 │                        │Count│
129 ├────────────────────────┼─────┤
130 │Sa1. SAMPLE SOURCE: RDD │ 5392│
131 │                    CELL│ 1607│
132 ╰────────────────────────┴─────╯
133
134           Custom Tables
135 ╭────────────────────────┬─────╮
136 │                        │Count│
137 ├────────────────────────┼─────┤
138 │Sa1. SAMPLE SOURCE: RDD │ 5392│
139 │                    CELL│ 1607│
140 ╰────────────────────────┴─────╯
141 ])
142 AT_CLEANUP
143
144 AT_SETUP([CTABLES parsing - negative])
145 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
146 AT_DATA([ctables.sps],
147 [[GET 'nhtsa.sav'.
148 CTABLES.
149 CTABLES /FORMAT MINCOLWIDTH='foo'.
150 CTABLES /TABLE qn1 [**].
151 CTABLES /TABLE qn1 [NOTAFUNCTION].
152 CTABLES /TABLE (qn1.
153 CTABLES /TABLE **.
154 CTABLES /TABLE NOTAVAR.
155 STRING string(A8).
156 CTABLES /TABLE string[S].
157 CTABLES /TABLE qn1 [PTILE 101].
158 CTABLES /TABLE qn1 [MEAN F0.1].
159 CTABLES /TABLE qn1 [MEAN NEGPAREN1.2].
160 CTABLES /TABLE qn1 [MEAN NEGPAREN3.4].
161 CTABLES /TABLE qn1 [MEAN TOTALS].
162 CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
163 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [SUBTOTAL=x].
164 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO **].
165 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO THRU x].
166 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1 THRU **].
167 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['x' THRU **].
168 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&**].
169 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
170 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 101).
171 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1.
172 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN.
173 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 MISSING=**.
174 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 TOTAL=**.
175 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 LABEL=**.
176 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 POSITION=**.
177 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 EMPTY=**.
178 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 **.
179 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1,2,3] **.
180 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[0]).
181 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[1**]).
182 CTABLES /PCOMPUTE &k=EXPR([LO **]).
183 CTABLES /PCOMPUTE &k=EXPR([LO THRU **]).
184 CTABLES /PCOMPUTE &k=EXPR([1 THRU **]).
185 CTABLES /PCOMPUTE &k=EXPR([1**]).
186 CTABLES /PCOMPUTE &k=EXPR((1x)).
187 CTABLES /PCOMPUTE **k.
188 CTABLES /PCOMPUTE &1.
189 CTABLES /PCOMPUTE &k**.
190 CTABLES /PCOMPUTE &k=**.
191 CTABLES /PCOMPUTE &k=EXPR**.
192 CTABLES /PCOMPUTE &k=EXPR(1x).
193 CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
194 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=NOTAFUNCTION.
195 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=PTILE **.
196 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k LABEL=**.
197 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k HIDESOURCECATS=**.
198 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k **.
199 CTABLES /FORMAT EMPTY=**.
200 CTABLES /FORMAT MISSING=**.
201 CTABLES /FORMAT **.
202 CTABLES /FORMAT MINCOLWIDTH=20 MAXCOLWIDTH=10/.
203 CTABLES /VLABELS **.
204 CTABLES /VLABELS VARIABLES=NOTAVAR.
205 CTABLES /VLABELS VARIABLES=qn1 **.
206 CTABLES /VLABELS VARIABLES=qn1 DISPLAY=**.
207 CTABLES /MRSETS **.
208 CTABLES /MRSETS COUNTDUPLICATES=**.
209 CTABLES /SMISSING **.
210 CTABLES /WEIGHT **.
211 CTABLES /WEIGHT VARIABLE=NOTAVAR.
212 CTABLES /HIDESMALLCOUNTS COUNT=1.
213 CTABLES /QUUX.
214 CTABLES /HIDESMALLCOUNTS COUNT=2.
215 CTABLES /TABLE qn1**.
216 CTABLES /TABLE qn1 /SLABELS POSITION=**.
217 CTABLES /TABLE qn1 /SLABELS VISIBLE=**.
218 CTABLES /TABLE qn1 /SLABELS **.
219 CTABLES /TABLE qn1 /CLABELS ROWLABELS=**.
220 CTABLES /TABLE qn1 /CLABELS COLLABELS=**.
221 CTABLES /TABLE qn1 /CLABELS **.
222 CTABLES /TABLE qn1 /CRITERIA **.
223 CTABLES /TABLE qn1 /CRITERIA CILEVEL=101.
224 CTABLES /TABLE qn1 /TITLES **.
225 CTABLES /TABLE qn1 /SIGTEST TYPE=**.
226 CTABLES /TABLE qn1 /SIGTEST ALPHA=**.
227 CTABLES /TABLE qn1 /SIGTEST INCLUDEMRSETS=**.
228 CTABLES /TABLE qn1 /SIGTEST CATEGORIES=**.
229 CTABLES /TABLE qn1 /SIGTEST **.
230 CTABLES /TABLE qn1 /COMPARETEST TYPE=**.
231 CTABLES /TABLE qn1 /COMPARETEST ALPHA=**.
232 CTABLES /TABLE qn1 /COMPARETEST ALPHA=0,5.
233 CTABLES /TABLE qn1 /COMPARETEST ADJUST=**.
234 CTABLES /TABLE qn1 /COMPARETEST INCLUDEMRSETS=**.
235 CTABLES /TABLE qn1 /COMPARETEST MEANSVARIANCE=**.
236 CTABLES /TABLE qn1 /COMPARETEST CATEGORIES=**.
237 CTABLES /TABLE qn1 /COMPARETEST MERGE=**.
238 CTABLES /TABLE qn1 /COMPARETEST STYLE=**.
239 CTABLES /TABLE qn1 /COMPARETEST SHOWSIG=**.
240 CTABLES /TABLE qn1 /COMPARETEST **.
241 CTABLES /TABLE qn1 / **.
242 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CLABELS COLLABELS=OPPOSITE.
243 CTABLES /TABLE qn20 > qnd1.
244 CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
245 NUMERIC datetime (DATETIME17.0).
246 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
247 ]])
248 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
249 [[ctables.sps:2.8: error: CTABLES: Syntax error at end of command: expecting `/'.
250
251 ctables.sps:3.29-3.33: error: CTABLES: Syntax error at `'foo'': Expected non-
252 negative number for MINCOLWIDTH.
253
254 ctables.sps:4.21-4.22: error: CTABLES: Syntax error at `**': expecting
255 identifier.
256
257 ctables.sps:5.21-5.32: error: CTABLES: Syntax error at `NOTAFUNCTION': Expecting
258 summary function name.
259
260 ctables.sps:6.20: error: CTABLES: Syntax error at end of command: expecting `@:}@'.
261
262 ctables.sps:7.16-7.17: error: CTABLES: Syntax error at `**': expecting
263 identifier.
264
265 ctables.sps:8: error: CTABLES: NOTAVAR is not a variable name.
266
267 ctables.sps:10.16-10.24: error: CTABLES: Cannot use string variable string as a
268 scale variable.
269    10 | CTABLES /TABLE string[S].
270       |                ^~~~~~~~~
271
272 ctables.sps:11.27-11.29: error: CTABLES: Syntax error at `101': Expected number
273 between 0 and 100 for PTILE.
274
275 ctables.sps:12: error: CTABLES: Output format F0.1 specifies width 0, but F
276 requires a width between 1 and 40.
277
278 ctables.sps:13.26-13.36: error: CTABLES: Syntax error at `NEGPAREN1.2': Output
279 format NEGPAREN requires width 2 or greater.
280
281 ctables.sps:14.26-14.36: error: CTABLES: Syntax error at `NEGPAREN3.4': Output
282 format NEGPAREN requires width greater than decimals.
283
284 ctables.sps:15.21-15.24: error: CTABLES: Summary function MEAN applies only to
285 scale variables.
286    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
287       |                     ^~~~
288
289 ctables.sps:15.16-15.18: note: CTABLES: 'QN1' is not a scale variable.
290    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
291       |                ^~~
292
293 ctables.sps:15.32: error: CTABLES: Syntax error at `@:>@': expecting `@<:@'.
294
295 ctables.sps:16.21-16.24: error: CTABLES: Summary function MEAN applies only to
296 scale variables.
297    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
298       |                     ^~~~
299
300 ctables.sps:16.16-16.18: note: CTABLES: 'QN1' is not a scale variable.
301    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
302       |                ^~~
303
304 ctables.sps:16.40: error: CTABLES: Syntax error at `%': expecting `@:>@'.
305
306 ctables.sps:17.56: error: CTABLES: Syntax error at `x': expecting string.
307
308 ctables.sps:18.50-18.51: error: CTABLES: Syntax error at `**': expecting THRU.
309
310 ctables.sps:19.55: error: CTABLES: Syntax error at `x': expecting number.
311
312 ctables.sps:20.54-20.55: error: CTABLES: Syntax error at `**': expecting number.
313
314 ctables.sps:21.56-21.57: error: CTABLES: Syntax error at `**': expecting string.
315
316 ctables.sps:22.48-22.49: error: CTABLES: Syntax error at `**': expecting
317 identifier.
318
319 ctables.sps:23.47-23.48: error: CTABLES: Unknown postcompute &x.
320    23 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
321       |                                               ^~
322
323 ctables.sps:24.61-24.63: error: CTABLES: Syntax error at `101': Expected number
324 between 0 and 100 for PTILE.
325
326 ctables.sps:25.58: error: CTABLES: Syntax error at end of command: expecting
327 `@:}@'.
328
329 ctables.sps:26.54: error: CTABLES: Syntax error at end of command: expecting
330 `@{:@'.
331
332 ctables.sps:27.54-27.55: error: CTABLES: Syntax error at `**': expecting INCLUDE
333 or EXCLUDE.
334
335 ctables.sps:28.52-28.53: error: CTABLES: Syntax error at `**': expecting YES or
336 NO.
337
338 ctables.sps:29.52-29.53: error: CTABLES: Syntax error at `**': expecting string.
339
340 ctables.sps:30.55-30.56: error: CTABLES: Syntax error at `**': expecting BEFORE
341 or AFTER.
342
343 ctables.sps:31.52-31.53: error: CTABLES: Syntax error at `**': expecting INCLUDE
344 or EXCLUDE.
345
346 ctables.sps:32.46-32.47: error: CTABLES: Syntax error at `**': expecting ORDER,
347 KEY, MISSING, TOTAL, LABEL, POSITION, or EMPTY.
348
349 ctables.sps:33.54-33.55: error: CTABLES: Syntax error at `**': expecting TOTAL,
350 LABEL, POSITION, or EMPTY.
351
352 ctables.sps:34.36: error: CTABLES: Syntax error at `0': Expected positive
353 integer for SUBTOTAL.
354
355 ctables.sps:35.37-35.38: error: CTABLES: Syntax error at `**': expecting `@:>@'.
356
357 ctables.sps:36.31-36.32: error: CTABLES: Syntax error at `**': expecting THRU.
358
359 ctables.sps:37.36-37.37: error: CTABLES: Syntax error at `**': expecting number.
360
361 ctables.sps:38.35-38.36: error: CTABLES: Syntax error at `**': expecting number.
362
363 ctables.sps:39.29-39.30: error: CTABLES: Syntax error at `**': expecting `@:>@'.
364
365 ctables.sps:40.29: error: CTABLES: Syntax error at `x': expecting `@:}@'.
366
367 ctables.sps:41.19-41.20: error: CTABLES: Syntax error at `**': expecting &.
368
369 ctables.sps:42.20: error: CTABLES: Syntax error at `1': expecting identifier.
370
371 ctables.sps:43.21-43.22: error: CTABLES: Syntax error at `**': expecting `='.
372
373 ctables.sps:44.22-44.23: error: CTABLES: Syntax error at `**': expecting EXPR.
374
375 ctables.sps:45.26-45.27: error: CTABLES: Syntax error at `**': expecting `('.
376
377 ctables.sps:46.28: error: CTABLES: Syntax error at `x': expecting `)'.
378
379 ctables.sps:47.31-47.49: warning: CTABLES: New definition of &k will override
380 the previous definition.
381    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
382       |                               ^~~~~~~~~~~~~~~~~~~
383
384 ctables.sps:47.10-47.28: note: CTABLES: This is the previous definition.
385    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
386       |          ^~~~~~~~~~~~~~~~~~~
387
388 ctables.sps:47.50: error: CTABLES: Syntax error at end of command: expecting
389 `/'.
390
391 ctables.sps:48.53-48.64: error: CTABLES: Syntax error at `NOTAFUNCTION':
392 Expecting summary function name.
393
394 ctables.sps:49.59-49.60: error: CTABLES: Syntax error at `**': Expected number
395 between 0 and 100 for PTILE.
396
397 ctables.sps:50.52-50.53: error: CTABLES: Syntax error at `**': expecting string.
398
399 ctables.sps:51.61-51.62: error: CTABLES: Syntax error at `**': expecting YES or
400 NO.
401
402 ctables.sps:52.46-52.47: error: CTABLES: Syntax error at `**': expecting LABEL,
403 FORMAT, or HIDESOURCECATS.
404
405 ctables.sps:53.23-53.24: error: CTABLES: Syntax error at `**': expecting string.
406
407 ctables.sps:54.25-54.26: error: CTABLES: Syntax error at `**': expecting string.
408
409 ctables.sps:55.17-55.18: error: CTABLES: Syntax error at `**': expecting
410 MINCOLWIDTH, MAXCOLWIDTH, UNITS, EMPTY, or MISSING.
411
412 ctables.sps:56: error: CTABLES: MINCOLWIDTH must not be greater than
413 MAXCOLWIDTH.
414
415 ctables.sps:57.18-57.19: error: CTABLES: Syntax error at `**': expecting
416 VARIABLES.
417
418 ctables.sps:58: error: CTABLES: NOTAVAR is not a variable name.
419
420 ctables.sps:59.32-59.33: error: CTABLES: Syntax error at `**': expecting
421 DISPLAY.
422
423 ctables.sps:60.40-60.41: error: CTABLES: Syntax error at `**': expecting
424 DEFAULT, NAME, LABEL, BOTH, or NONE.
425
426 ctables.sps:61.17-61.18: error: CTABLES: Syntax error at `**': expecting
427 COUNTDUPLICATES.
428
429 ctables.sps:62.33-62.34: error: CTABLES: Syntax error at `**': expecting YES or
430 NO.
431
432 ctables.sps:63.19-63.20: error: CTABLES: Syntax error at `**': expecting
433 VARIABLE or LISTWISE.
434
435 ctables.sps:64.17-64.18: error: CTABLES: Syntax error at `**': expecting
436 VARIABLE.
437
438 ctables.sps:65: error: CTABLES: NOTAVAR is not a variable name.
439
440 ctables.sps:66.32: error: CTABLES: Syntax error at `1': Expected integer 2 or
441 greater for HIDESMALLCOUNTS COUNT.
442
443 ctables.sps:67.10-67.13: error: CTABLES: Syntax error at `QUUX': expecting
444 FORMAT, VLABELS, MRSETS, SMISSING, PCOMPUTE, PPROPERTIES, WEIGHT,
445 HIDESMALLCOUNTS, or TABLE.
446
447 ctables.sps:68.33: error: CTABLES: Syntax error at end of command: expecting
448 `/'.
449
450 ctables.sps:69.19-69.20: error: CTABLES: Syntax error at `**': expecting `/'.
451
452 ctables.sps:70.38-70.39: error: CTABLES: Syntax error at `**': expecting COLUMN,
453 ROW, or LAYER.
454
455 ctables.sps:71.37-71.38: error: CTABLES: Syntax error at `**': expecting YES or
456 NO.
457
458 ctables.sps:72.29-72.30: error: CTABLES: Syntax error at `**': expecting
459 POSITION or VISIBLE.
460
461 ctables.sps:73.39-73.40: error: CTABLES: Syntax error at `**': expecting
462 OPPOSITE or LAYER.
463
464 ctables.sps:74.39-74.40: error: CTABLES: Syntax error at `**': expecting
465 OPPOSITE or LAYER.
466
467 ctables.sps:75.29-75.30: error: CTABLES: Syntax error at `**': expecting AUTO,
468 ROWLABELS, or COLLABELS.
469
470 ctables.sps:76.30-76.31: error: CTABLES: Syntax error at `**': expecting
471 CILEVEL.
472
473 ctables.sps:77.38-77.40: error: CTABLES: Syntax error at `101': Expected number
474 in @<:@0,100@:}@ for CILEVEL.
475
476 ctables.sps:78.28-78.29: error: CTABLES: Syntax error at `**': expecting
477 CAPTION, CORNER, or TITLE.
478
479 ctables.sps:79.34-79.35: error: CTABLES: Syntax error at `**': expecting
480 CHISQUARE.
481
482 ctables.sps:80.35-80.36: error: CTABLES: Syntax error at `**': Expected number
483 in @<:@0,1@:}@ for ALPHA.
484
485 ctables.sps:81.43-81.44: error: CTABLES: Syntax error at `**': expecting YES or
486 NO.
487
488 ctables.sps:82.40-82.41: error: CTABLES: Syntax error at `**': expecting
489 ALLVISIBLE or SUBTOTALS.
490
491 ctables.sps:83.29-83.30: error: CTABLES: Syntax error at `**': expecting TYPE,
492 ALPHA, INCLUDEMRSETS, or CATEGORIES.
493
494 ctables.sps:84.38-84.39: error: CTABLES: Syntax error at `**': expecting PROP or
495 MEAN.
496
497 ctables.sps:85.39-85.40: error: CTABLES: Syntax error at `**': Expected number
498 in (0,1) for ALPHA.
499
500 ctables.sps:86.39: error: CTABLES: Syntax error at `0': Expected number in (0,1)
501 for ALPHA.
502
503 ctables.sps:87.40-87.41: error: CTABLES: Syntax error at `**': expecting
504 BONFERRONI, BH, or NONE.
505
506 ctables.sps:88.47-88.48: error: CTABLES: Syntax error at `**': expecting YES or
507 NO.
508
509 ctables.sps:89.47-89.48: error: CTABLES: Syntax error at `**': expecting ALLCATS
510 or TESTEDCATS.
511
512 ctables.sps:90.44-90.45: error: CTABLES: Syntax error at `**': expecting
513 ALLVISIBLE or SUBTOTALS.
514
515 ctables.sps:91.39-91.40: error: CTABLES: Syntax error at `**': expecting YES or
516 NO.
517
518 ctables.sps:92.39-92.40: error: CTABLES: Syntax error at `**': expecting APA or
519 SIMPLE.
520
521 ctables.sps:93.41-93.42: error: CTABLES: Syntax error at `**': expecting YES or
522 NO.
523
524 ctables.sps:94.33-94.34: error: CTABLES: Syntax error at `**': expecting TYPE,
525 ALPHA, ADJUST, INCLUDEMRSETS, MEANSVARIANCE, CATEGORIES, MERGE, STYLE, or
526 SHOWSIG.
527
528 ctables.sps:95.22-95.23: error: CTABLES: Syntax error at `**': expecting TABLE,
529 SLABELS, CLABELS, CRITERIA, CATEGORIES, TITLES, SIGTEST, or COMPARETEST.
530
531 ctables.sps:96: error: CTABLES: ROWLABELS and COLLABELS may not both be
532 specified.
533
534 ctables.sps:97.16-97.26: error: CTABLES: Cannot nest scale variables.
535    97 | CTABLES /TABLE qn20 > qnd1.
536       |                ^~~~~~~~~~~
537
538 ctables.sps:97.16-97.19: note: CTABLES: This is an outer scale variable.
539    97 | CTABLES /TABLE qn20 > qnd1.
540       |                ^~~~
541
542 ctables.sps:97.23-97.26: note: CTABLES: This is an inner scale variable.
543    97 | CTABLES /TABLE qn20 > qnd1.
544       |                       ^~~~
545
546 ctables.sps:98.16-98.35: error: CTABLES: Summaries may only be requested for
547 categorical variables at the innermost nesting level.
548    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
549       |                ^~~~~~~~~~~~~~~~~~~~
550
551 ctables.sps:98.16-98.18: note: CTABLES: This outer categorical variable has a
552 summary.
553    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
554       |                ^~~
555
556 ctables.sps:100.52-100.56: error: CTABLES: Failed to parse category
557 specification as format DATETIME: Day (123) must be between 1 and 31..
558   100 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
559       |                                                    ^~~~~
560
561 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
562
563 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
564 summary.
565    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
566       |                ^~~~~
567
568 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
569 summary.
570    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
571       |                                 ^~~~~
572
573 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
574 summary.
575    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
576       |                                                  ^~~~~
577 ]])
578 AT_CLEANUP
579
580 AT_SETUP([CTABLES parsing - more negative])
581 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
582 AT_DATA([ctables.sps],
583 [[GET 'nhtsa.sav'.
584 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
585 CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
586 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
587
588 STRING string(A8).
589 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
590 CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
591
592 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1).
593
594 CTABLES /TABLE qnd1 /CLABELS ROWLABELS=OPPOSITE.
595 CTABLES /TABLE qn1 + string /CLABELS ROWLABELS=OPPOSITE.
596 CTABLES /TABLE qn1 + qnsa1 /CLABELS ROWLABELS=OPPOSITE.
597 CTABLES /TABLE qn105ba + qn105bb /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn105ba [1,2,3].
598
599 CTABLES /PCOMPUTE &x=EXPR(1**2**3).
600 CTABLES /PCOMPUTE &x=EXPR([**]).
601 CTABLES /PCOMPUTE &x=EXPR(**).
602
603 CTABLES /TABLE.
604
605 CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. 
606 ]])
607 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
608 [[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a
609 category not included in the category list.
610     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
611 VARIABLES=qn1 [&pc].
612       |
613 ^~~
614
615 ctables.sps:2.28-2.35: note: CTABLES: This is the missing category.
616     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
617 VARIABLES=qn1 [&pc].
618       |                            ^~~~~~~~
619
620 ctables.sps:2.76-2.79: note: CTABLES: To fix the problem, add subtotals to the
621 list of categories here.
622     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
623 VARIABLES=qn1 [&pc].
624       |
625 ^~~~
626
627 ctables.sps:3.73-3.75: error: CTABLES: Computed category &pc references a
628 category not included in the category list.
629     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
630 [&pc].
631       |
632 ^~~
633
634 ctables.sps:3.28-3.32: note: CTABLES: This is the missing category.
635     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
636 [&pc].
637       |                            ^~~~~
638
639 ctables.sps:3: note: CTABLES: To fix the problem, add TOTAL=YES to the
640 variable's CATEGORIES specification.
641
642 ctables.sps:4.76-4.99: error: CTABLES: These categories include 2 instances of
643 SUBTOTAL or HSUBTOTAL, so references from computed categories must refer to
644 subtotals by position, e.g. SUBTOTAL[1].
645     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
646 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
647       |
648 ^~~~~~~~~~~~~~~~~~~~~~~~
649
650 ctables.sps:4.28-4.35: note: CTABLES: This is the reference that lacks a
651 position.
652     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
653 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
654       |                            ^~~~~~~~
655
656 ctables.sps:7.47-7.54: error: CTABLES: This category specification may be
657 applied only to string variables, but this subcommand tries to apply it to
658 numeric variable QN1.
659     7 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
660       |                                               ^~~~~~~~
661
662 ctables.sps:8.53: error: CTABLES: This category specification may be applied
663 only to numeric variables, but this subcommand tries to apply it to string
664 variable string.
665     8 | CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
666       |                                                     ^
667
668 ctables.sps:10: error: CTABLES: ROWLABELS=OPPOSITE is not allowed with sorting
669 based on a summary function.
670
671 ctables.sps:12: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
672 moved to be categorical, but qnd1 is a scale variable.
673
674 ctables.sps:13: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
675 moved to have the same width, but QN1 has width 0 and string has width 8.
676
677 ctables.sps:14: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
678 moved to have the same value labels, but QN1 and QNSA1 have different value
679 labels.
680
681 ctables.sps:15: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
682 moved to have the same category specifications, but QN105BA and QN105BB have
683 different category specifications.
684
685 ctables.sps:17.27-17.33: warning: CTABLES: The exponentiation operator (`**') is
686 left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'.  To disable
687 this warning, insert parentheses.
688    17 | CTABLES /PCOMPUTE &x=EXPR(1**2**3).
689       |                           ^~~~~~~
690
691 ctables.sps:17.35: error: CTABLES: Syntax error at end of command: expecting
692 `/'.
693
694 ctables.sps:18.28-18.29: error: CTABLES: Syntax error at `**'.
695
696 ctables.sps:19.27-19.28: error: CTABLES: Syntax error at `**'.
697
698 ctables.sps:21.15: error: CTABLES: Syntax error at end of command: At least one
699 variable must be specified.
700
701 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
702
703 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
704 summary.
705    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
706       |                ^~~~~
707
708 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
709 summary.
710    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
711       |                                 ^~~~~
712
713 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
714 summary.
715    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
716       |                                                  ^~~~~
717 ]])
718 AT_CLEANUP
719
720 AT_SETUP([CTABLES one categorical variable])
721 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
722 AT_DATA([ctables.sps],
723 [[GET 'nhtsa.sav'.
724 CTABLES /TABLE qn1.
725 CTABLES /TABLE BY qn1.
726 CTABLES /TABLE BY BY qn1.
727 ]])
728 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
729                                   Custom Tables
730 ╭────────────────────────────────────────────────────────────────────────┬─────╮
731 │                                                                        │Count│
732 ├────────────────────────────────────────────────────────────────────────┼─────┤
733 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
734 │motor vehicle?                                     Several days a week  │ 1274│
735 │                                                   Once a week or less  │  361│
736 │                                                   Only certain times a │  130│
737 │                                                   year                 │     │
738 │                                                   Never                │  540│
739 ╰────────────────────────────────────────────────────────────────────────┴─────╯
740
741                                   Custom Tables
742 ╭──────────────────────────────────────────────────────────────────────────────╮
743 │        1. How often do you usually drive a car or other motor vehicle?       │
744 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
745 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
746 │Every day│       week       │       less       │          year          │Never│
747 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
748 │  Count  │       Count      │       Count      │          Count         │Count│
749 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
750 │     4667│              1274│               361│                     130│  540│
751 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
752
753 Custom Tables
754 Every day
755 ╭─────╮
756 │Count│
757 ├─────┤
758 │ 4667│
759 ╰─────╯
760 ])
761 AT_CLEANUP
762
763 AT_SETUP([CTABLES one scale variable])
764 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
765 AT_DATA([ctables.sps],
766 [[GET 'nhtsa.sav'.
767 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
768 CTABLES /TABLE BY qnd1.
769 CTABLES /TABLE BY BY qnd1.
770 ]])
771 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
772                                   Custom Tables
773 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
774 │                      │     │       │       │    │     Std    │       │       │
775 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
776 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
777 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
778 │age?                  │     │       │       │    │            │       │       │
779 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
780
781         Custom Tables
782 ╭──────────────────────────╮
783 │D1. AGE: What is your age?│
784 ├──────────────────────────┤
785 │           Mean           │
786 ├──────────────────────────┤
787 │                        48│
788 ╰──────────────────────────╯
789
790 Custom Tables
791 D1. AGE: What is your age?
792 ╭────╮
793 │Mean│
794 ├────┤
795 │  48│
796 ╰────╯
797 ])
798 AT_CLEANUP
799
800 AT_SETUP([CTABLES simple stacking])
801 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
802 AT_DATA([ctables.sps],
803 [[GET 'nhtsa.sav'.
804 CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
805 ]])
806 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
807                                   Custom Tables
808 ╭───────────────────────────────────────────────────────────────┬──────────────╮
809 │                                                               │ S3a. GENDER: │
810 │                                                               ├──────┬───────┤
811 │                                                               │ Male │ Female│
812 │                                                               ├──────┼───────┤
813 │                                                               │Column│ Column│
814 │                                                               │   %  │   %   │
815 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
816 │105b. How likely is it that drivers who have had   Almost      │   10%│    11%│
817 │too much to drink to drive safely will A. Get      certain     │      │       │
818 │stopped by the police?                             Very likely │   21%│    22%│
819 │                                                   Somewhat    │   38%│    42%│
820 │                                                   likely      │      │       │
821 │                                                   Somewhat    │   21%│    18%│
822 │                                                   unlikely    │      │       │
823 │                                                   Very        │   10%│     8%│
824 │                                                   unlikely    │      │       │
825 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
826 │105b. How likely is it that drivers who have had   Almost      │   14%│    18%│
827 │too much to drink to drive safely will B. Have an  certain     │      │       │
828 │accident?                                          Very likely │   36%│    45%│
829 │                                                   Somewhat    │   39%│    32%│
830 │                                                   likely      │      │       │
831 │                                                   Somewhat    │    9%│     4%│
832 │                                                   unlikely    │      │       │
833 │                                                   Very        │    3%│     2%│
834 │                                                   unlikely    │      │       │
835 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
836 │105b. How likely is it that drivers who have had   Almost      │   18%│    16%│
837 │too much to drink to drive safely will C. Be       certain     │      │       │
838 │convicted for drunk driving?                       Very likely │   32%│    28%│
839 │                                                   Somewhat    │   27%│    32%│
840 │                                                   likely      │      │       │
841 │                                                   Somewhat    │   15%│    15%│
842 │                                                   unlikely    │      │       │
843 │                                                   Very        │    9%│     9%│
844 │                                                   unlikely    │      │       │
845 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
846 │105b. How likely is it that drivers who have had   Almost      │   16%│    16%│
847 │too much to drink to drive safely will D. Be       certain     │      │       │
848 │arrested for drunk driving?                        Very likely │   26%│    27%│
849 │                                                   Somewhat    │   32%│    35%│
850 │                                                   likely      │      │       │
851 │                                                   Somewhat    │   17%│    15%│
852 │                                                   unlikely    │      │       │
853 │                                                   Very        │    9%│     7%│
854 │                                                   unlikely    │      │       │
855 ╰───────────────────────────────────────────────────────────────┴──────┴───────╯
856 ])
857 AT_CLEANUP
858
859 AT_SETUP([CTABLES show or hide empty categories])
860 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
861 AT_DATA([ctables.sps],
862 [[GET 'nhtsa.sav'.
863 IF (qn105ba = 2) qn105ba = 1.
864 IF (qns3a = 1) qns3a = 2.
865 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
866 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
867     /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
868 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
869     /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
870 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
871     /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
872 ]])
873 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
874                                   Custom Tables
875 ╭──────────────────────────────────────────────────────────────┬───────────────╮
876 │                                                              │  S3a. GENDER: │
877 │                                                              ├───────┬───────┤
878 │                                                              │  Male │ Female│
879 │                                                              ├───────┼───────┤
880 │                                                              │ Column│ Column│
881 │                                                              │   %   │   %   │
882 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
883 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
884 │too much to drink to drive safely will A. Get      certain    │       │       │
885 │stopped by the police?                             Very likely│      .│     0%│
886 │                                                   Somewhat   │      .│    40%│
887 │                                                   likely     │       │       │
888 │                                                   Somewhat   │      .│    19%│
889 │                                                   unlikely   │       │       │
890 │                                                   Very       │      .│     9%│
891 │                                                   unlikely   │       │       │
892 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
893
894                                   Custom Tables
895 ╭──────────────────────────────────────────────────────────────┬───────────────╮
896 │                                                              │  S3a. GENDER: │
897 │                                                              ├───────┬───────┤
898 │                                                              │  Male │ Female│
899 │                                                              ├───────┼───────┤
900 │                                                              │ Column│ Column│
901 │                                                              │   %   │   %   │
902 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
903 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
904 │too much to drink to drive safely will A. Get      certain    │       │       │
905 │stopped by the police?                             Somewhat   │      .│    40%│
906 │                                                   likely     │       │       │
907 │                                                   Somewhat   │      .│    19%│
908 │                                                   unlikely   │       │       │
909 │                                                   Very       │      .│     9%│
910 │                                                   unlikely   │       │       │
911 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
912
913                                   Custom Tables
914 ╭────────────────────────────────────────────────────────────────────┬─────────╮
915 │                                                                    │   S3a.  │
916 │                                                                    │ GENDER: │
917 │                                                                    ├─────────┤
918 │                                                                    │  Female │
919 │                                                                    ├─────────┤
920 │                                                                    │ Column %│
921 ├────────────────────────────────────────────────────────────────────┼─────────┤
922 │105b. How likely is it that drivers who have had too    Almost      │      32%│
923 │much to drink to drive safely will A. Get stopped by    certain     │         │
924 │the police?                                             Very likely │       0%│
925 │                                                        Somewhat    │      40%│
926 │                                                        likely      │         │
927 │                                                        Somewhat    │      19%│
928 │                                                        unlikely    │         │
929 │                                                        Very        │       9%│
930 │                                                        unlikely    │         │
931 ╰────────────────────────────────────────────────────────────────────┴─────────╯
932
933                                   Custom Tables
934 ╭────────────────────────────────────────────────────────────────────┬─────────╮
935 │                                                                    │   S3a.  │
936 │                                                                    │ GENDER: │
937 │                                                                    ├─────────┤
938 │                                                                    │  Female │
939 │                                                                    ├─────────┤
940 │                                                                    │ Column %│
941 ├────────────────────────────────────────────────────────────────────┼─────────┤
942 │105b. How likely is it that drivers who have had too    Almost      │      32%│
943 │much to drink to drive safely will A. Get stopped by    certain     │         │
944 │the police?                                             Somewhat    │      40%│
945 │                                                        likely      │         │
946 │                                                        Somewhat    │      19%│
947 │                                                        unlikely    │         │
948 │                                                        Very        │       9%│
949 │                                                        unlikely    │         │
950 ╰────────────────────────────────────────────────────────────────────┴─────────╯
951 ])
952 AT_CLEANUP
953
954 AT_SETUP([CTABLES simple nesting])
955 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
956 AT_DATA([ctables.sps],
957 [[GET 'nhtsa.sav'.
958 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
959   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
960 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
961   /CATEGORIES VARIABLES=qns3a TOTAL=YES
962   /CLABELS ROW=OPPOSITE.
963 ]])
964 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
965                                   Custom Tables
966 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
967 │                                                                 │     │ Table│
968 │                                                                 │Count│   %  │
969 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
970 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
971 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
972 │drive safely will A. Get stopped by                        Total │  700│   10%│
973 │the police?                           ╶──────────────────────────┼─────┼──────┤
974 │                                       Very       S3a.     Male  │  660│   10%│
975 │                                       likely     GENDER:  Female│  842│   12%│
976 │                                                           Total │ 1502│   22%│
977 │                                      ╶──────────────────────────┼─────┼──────┤
978 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
979 │                                       likely     GENDER:  Female│ 1589│   23%│
980 │                                                           Total │ 2763│   40%│
981 │                                      ╶──────────────────────────┼─────┼──────┤
982 │                                       Somewhat   S3a.     Male  │  640│    9%│
983 │                                       unlikely   GENDER:  Female│  667│   10%│
984 │                                                           Total │ 1307│   19%│
985 │                                      ╶──────────────────────────┼─────┼──────┤
986 │                                       Very       S3a.     Male  │  311│    5%│
987 │                                       unlikely   GENDER:  Female│  298│    4%│
988 │                                                           Total │  609│    9%│
989 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
990 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
991 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
992 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
993 │                                      ╶──────────────────────────┼─────┼──────┤
994 │                                       Very       S3a.     Male  │ 1104│   16%│
995 │                                       likely     GENDER:  Female│ 1715│   25%│
996 │                                                           Total │ 2819│   41%│
997 │                                      ╶──────────────────────────┼─────┼──────┤
998 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
999 │                                       likely     GENDER:  Female│ 1214│   18%│
1000 │                                                           Total │ 2417│   35%│
1001 │                                      ╶──────────────────────────┼─────┼──────┤
1002 │                                       Somewhat   S3a.     Male  │  262│    4%│
1003 │                                       unlikely   GENDER:  Female│  168│    2%│
1004 │                                                           Total │  430│    6%│
1005 │                                      ╶──────────────────────────┼─────┼──────┤
1006 │                                       Very       S3a.     Male  │   81│    1%│
1007 │                                       unlikely   GENDER:  Female│   59│    1%│
1008 │                                                           Total │  140│    2%│
1009 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1010 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
1011 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
1012 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
1013 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1014 │                                       Very       S3a.     Male  │  988│   14%│
1015 │                                       likely     GENDER:  Female│ 1049│   15%│
1016 │                                                           Total │ 2037│   30%│
1017 │                                      ╶──────────────────────────┼─────┼──────┤
1018 │                                       Somewhat   S3a.     Male  │  822│   12%│
1019 │                                       likely     GENDER:  Female│ 1210│   18%│
1020 │                                                           Total │ 2032│   30%│
1021 │                                      ╶──────────────────────────┼─────┼──────┤
1022 │                                       Somewhat   S3a.     Male  │  446│    7%│
1023 │                                       unlikely   GENDER:  Female│  548│    8%│
1024 │                                                           Total │  994│   15%│
1025 │                                      ╶──────────────────────────┼─────┼──────┤
1026 │                                       Very       S3a.     Male  │  268│    4%│
1027 │                                       unlikely   GENDER:  Female│  354│    5%│
1028 │                                                           Total │  622│    9%│
1029 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1030 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
1031 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
1032 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
1033 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1034 │                                       Very       S3a.     Male  │  805│   12%│
1035 │                                       likely     GENDER:  Female│ 1029│   15%│
1036 │                                                           Total │ 1834│   27%│
1037 │                                      ╶──────────────────────────┼─────┼──────┤
1038 │                                       Somewhat   S3a.     Male  │  975│   14%│
1039 │                                       likely     GENDER:  Female│ 1332│   19%│
1040 │                                                           Total │ 2307│   34%│
1041 │                                      ╶──────────────────────────┼─────┼──────┤
1042 │                                       Somewhat   S3a.     Male  │  535│    8%│
1043 │                                       unlikely   GENDER:  Female│  560│    8%│
1044 │                                                           Total │ 1095│   16%│
1045 │                                      ╶──────────────────────────┼─────┼──────┤
1046 │                                       Very       S3a.     Male  │  270│    4%│
1047 │                                       unlikely   GENDER:  Female│  279│    4%│
1048 │                                                           Total │  549│    8%│
1049 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1050
1051                                   Custom Tables
1052 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
1053 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
1054 │                                 │ certain│likely│  likely │ unlikely│unlikely│
1055 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
1056 │                                 │        │ Table│         │         │        │
1057 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
1058 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1059 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
1060 │GENDER:        is it that drivers│        │      │         │         │        │
1061 │               who have had too  │        │      │         │         │        │
1062 │               much to drink to  │        │      │         │         │        │
1063 │               drive safely will │        │      │         │         │        │
1064 │               A. Get stopped by │        │      │         │         │        │
1065 │               the police?       │        │      │         │         │        │
1066 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1067 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
1068 │               is it that drivers│        │      │         │         │        │
1069 │               who have had too  │        │      │         │         │        │
1070 │               much to drink to  │        │      │         │         │        │
1071 │               drive safely will │        │      │         │         │        │
1072 │               A. Get stopped by │        │      │         │         │        │
1073 │               the police?       │        │      │         │         │        │
1074 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1075 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
1076 │               is it that drivers│        │      │         │         │        │
1077 │               who have had too  │        │      │         │         │        │
1078 │               much to drink to  │        │      │         │         │        │
1079 │               drive safely will │        │      │         │         │        │
1080 │               A. Get stopped by │        │      │         │         │        │
1081 │               the police?       │        │      │         │         │        │
1082 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1083 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
1084 │GENDER:        is it that drivers│        │      │         │         │        │
1085 │               who have had too  │        │      │         │         │        │
1086 │               much to drink to  │        │      │         │         │        │
1087 │               drive safely will │        │      │         │         │        │
1088 │               B. Have an        │        │      │         │         │        │
1089 │               accident?         │        │      │         │         │        │
1090 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1091 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
1092 │               is it that drivers│        │      │         │         │        │
1093 │               who have had too  │        │      │         │         │        │
1094 │               much to drink to  │        │      │         │         │        │
1095 │               drive safely will │        │      │         │         │        │
1096 │               B. Have an        │        │      │         │         │        │
1097 │               accident?         │        │      │         │         │        │
1098 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1099 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
1100 │               is it that drivers│        │      │         │         │        │
1101 │               who have had too  │        │      │         │         │        │
1102 │               much to drink to  │        │      │         │         │        │
1103 │               drive safely will │        │      │         │         │        │
1104 │               B. Have an        │        │      │         │         │        │
1105 │               accident?         │        │      │         │         │        │
1106 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1107 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
1108 │GENDER:        is it that drivers│        │      │         │         │        │
1109 │               who have had too  │        │      │         │         │        │
1110 │               much to drink to  │        │      │         │         │        │
1111 │               drive safely will │        │      │         │         │        │
1112 │               C. Be convicted   │        │      │         │         │        │
1113 │               for drunk driving?│        │      │         │         │        │
1114 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1115 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
1116 │               is it that drivers│        │      │         │         │        │
1117 │               who have had too  │        │      │         │         │        │
1118 │               much to drink to  │        │      │         │         │        │
1119 │               drive safely will │        │      │         │         │        │
1120 │               C. Be convicted   │        │      │         │         │        │
1121 │               for drunk driving?│        │      │         │         │        │
1122 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1123 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
1124 │               is it that drivers│        │      │         │         │        │
1125 │               who have had too  │        │      │         │         │        │
1126 │               much to drink to  │        │      │         │         │        │
1127 │               drive safely will │        │      │         │         │        │
1128 │               C. Be convicted   │        │      │         │         │        │
1129 │               for drunk driving?│        │      │         │         │        │
1130 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1131 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
1132 │GENDER:        is it that drivers│        │      │         │         │        │
1133 │               who have had too  │        │      │         │         │        │
1134 │               much to drink to  │        │      │         │         │        │
1135 │               drive safely will │        │      │         │         │        │
1136 │               D. Be arrested for│        │      │         │         │        │
1137 │               drunk driving?    │        │      │         │         │        │
1138 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1139 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
1140 │               is it that drivers│        │      │         │         │        │
1141 │               who have had too  │        │      │         │         │        │
1142 │               much to drink to  │        │      │         │         │        │
1143 │               drive safely will │        │      │         │         │        │
1144 │               D. Be arrested for│        │      │         │         │        │
1145 │               drunk driving?    │        │      │         │         │        │
1146 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1147 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
1148 │               is it that drivers│        │      │         │         │        │
1149 │               who have had too  │        │      │         │         │        │
1150 │               much to drink to  │        │      │         │         │        │
1151 │               drive safely will │        │      │         │         │        │
1152 │               D. Be arrested for│        │      │         │         │        │
1153 │               drunk driving?    │        │      │         │         │        │
1154 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
1155 ])
1156 AT_CLEANUP
1157
1158 AT_SETUP([CTABLES nesting and scale variables])
1159 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1160 AT_DATA([ctables.sps],
1161 [[GET 'nhtsa.sav'.
1162 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
1163 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
1164 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
1165   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
1166 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
1167 ]])
1168 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1169                                   Custom Tables
1170 ╭─────────────────────────────────────────────────────────────────┬────────────╮
1171 │                                                                 │S3a. GENDER:│
1172 │                                                                 ├─────┬──────┤
1173 │                                                                 │ Male│Female│
1174 │                                                                 ├─────┼──────┤
1175 │                                                                 │ Mean│ Mean │
1176 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1177 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
1178 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
1179 │                                                  week           │     │      │
1180 │                                                  Once a week or │   44│    54│
1181 │                                                  less           │     │      │
1182 │                                                  Only certain   │   34│    41│
1183 │                                                  times a year   │     │      │
1184 │                                                  Never          │   39│    55│
1185 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1186
1187                                   Custom Tables
1188 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
1189 │                                                         │Minimum│Maximum│Mean│
1190 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1191 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
1192 │What is  GENDER:         months, has there been a        │       │       │    │
1193 │your                     time when you felt you          │       │       │    │
1194 │age?                     should cut down on your      No │     16│     86│  46│
1195 │                         drinking?                       │       │       │    │
1196 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1197 │                  Female 26. During the last 12       Yes│     16│     86│  43│
1198 │                         months, has there been a        │       │       │    │
1199 │                         time when you felt you          │       │       │    │
1200 │                         should cut down on your      No │     16│     86│  48│
1201 │                         drinking?                       │       │       │    │
1202 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1203 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
1204 │What is  GENDER:         months, has there been a        │       │       │    │
1205 │your                     time when people criticized  No │     16│     86│  46│
1206 │age?                     your drinking?                  │       │       │    │
1207 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1208 │                  Female 27. During the last 12       Yes│     17│     69│  37│
1209 │                         months, has there been a        │       │       │    │
1210 │                         time when people criticized  No │     16│     86│  48│
1211 │                         your drinking?                  │       │       │    │
1212 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
1213
1214                                   Custom Tables
1215 ╭─────────────────────────────┬────────────────────────────────────────────────╮
1216 │                             │S1. Including yourself, how many members of this│
1217 │                             │         household are age 16 or older?         │
1218 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
1219 │                             │      │      │      │      │      │      │ 6 or │
1220 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
1221 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1222 │                             │Column│Column│Column│Column│Column│Column│Column│
1223 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
1224 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1225 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
1226 │SAMPLE      How      certain │      │      │      │      │      │      │      │
1227 │SOURCE:     likely           │      │      │      │      │      │      │      │
1228 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
1229 │            that     likely  │      │      │      │      │      │      │      │
1230 │            drivers          │      │      │      │      │      │      │      │
1231 │            who have         │      │      │      │      │      │      │      │
1232 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
1233 │            much to  likely  │      │      │      │      │      │      │      │
1234 │            drink to         │      │      │      │      │      │      │      │
1235 │            drive            │      │      │      │      │      │      │      │
1236 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
1237 │            will A.  unlikely│      │      │      │      │      │      │      │
1238 │            Get              │      │      │      │      │      │      │      │
1239 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
1240 │            by the   unlikely│      │      │      │      │      │      │      │
1241 │            police?          │      │      │      │      │      │      │      │
1242 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
1243
1244                                   Custom Tables
1245 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
1246 │                                                              │    │    Std   │
1247 │                                                              │Mean│ Deviation│
1248 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
1249 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
1250 │group           typical month did you have one or more        │    │          │
1251 │                alcoholic beverages to drink?                 │    │          │
1252 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1253 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
1254 │                typical month did you have one or more        │    │          │
1255 │                alcoholic beverages to drink?                 │    │          │
1256 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1257 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
1258 │                typical month did you have one or more        │    │          │
1259 │                alcoholic beverages to drink?                 │    │          │
1260 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1261 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
1262 │                typical month did you have one or more        │    │          │
1263 │                alcoholic beverages to drink?                 │    │          │
1264 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1265 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
1266 │                typical month did you have one or more        │    │          │
1267 │                alcoholic beverages to drink?                 │    │          │
1268 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1269 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
1270 │       older    typical month did you have one or more        │    │          │
1271 │                alcoholic beverages to drink?                 │    │          │
1272 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
1273 ])
1274 AT_CLEANUP
1275
1276
1277 AT_SETUP([CTABLES SLABELS])
1278 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1279 AT_DATA([ctables.sps],
1280 [[GET 'nhtsa.sav'.
1281 CTABLES /TABLE qn1 [COUNT COLPCT].
1282 CTABLES /TABLE qn1 [COUNT COLPCT]
1283     /SLABELS POSITION=ROW.
1284 CTABLES /TABLE qn1 [COUNT COLPCT]
1285     /SLABELS POSITION=ROW VISIBLE=NO.
1286 ]])
1287 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1288                                   Custom Tables
1289 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
1290 │                                                                │     │ Column│
1291 │                                                                │Count│   %   │
1292 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
1293 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
1294 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
1295 │                                             Once a week or less│  361│   5.2%│
1296 │                                             Only certain times │  130│   1.9%│
1297 │                                             a year             │     │       │
1298 │                                             Never              │  540│   7.7%│
1299 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
1300
1301                                   Custom Tables
1302 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1303 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
1304 │other motor vehicle?                                             Column │66.9%│
1305 │                                                                 %      │     │
1306 │                                            ╶───────────────────────────┼─────┤
1307 │                                             Several days a week Count  │ 1274│
1308 │                                                                 Column │18.3%│
1309 │                                                                 %      │     │
1310 │                                            ╶───────────────────────────┼─────┤
1311 │                                             Once a week or less Count  │  361│
1312 │                                                                 Column │ 5.2%│
1313 │                                                                 %      │     │
1314 │                                            ╶───────────────────────────┼─────┤
1315 │                                             Only certain times  Count  │  130│
1316 │                                             a year              Column │ 1.9%│
1317 │                                                                 %      │     │
1318 │                                            ╶───────────────────────────┼─────┤
1319 │                                             Never               Count  │  540│
1320 │                                                                 Column │ 7.7%│
1321 │                                                                 %      │     │
1322 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1323
1324                                   Custom Tables
1325 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1326 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
1327 │motor vehicle?                                                          │66.9%│
1328 │                                                   Several days a week  │ 1274│
1329 │                                                                        │18.3%│
1330 │                                                   Once a week or less  │  361│
1331 │                                                                        │ 5.2%│
1332 │                                                   Only certain times a │  130│
1333 │                                                   year                 │ 1.9%│
1334 │                                                   Never                │  540│
1335 │                                                                        │ 7.7%│
1336 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1337 ])
1338 AT_CLEANUP
1339
1340 AT_SETUP([CTABLES simple totals])
1341 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1342 AT_DATA([ctables.sps],
1343 [[GET 'nhtsa.sav'.
1344 CTABLES /TABLE=qn17
1345     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
1346 DESCRIPTIVES qn18/STATISTICS=MEAN.
1347 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
1348     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
1349 ]])
1350 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1351                                   Custom Tables
1352 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1353 │                                                                        │Count│
1354 ├────────────────────────────────────────────────────────────────────────┼─────┤
1355 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
1356 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
1357 │                                                      Light beer        │  620│
1358 │                                                      Wine              │ 1418│
1359 │                                                      Wine coolers      │  137│
1360 │                                                      Hard liquor or    │  888│
1361 │                                                      mixed drinks      │     │
1362 │                                                      Flavored malt     │   83│
1363 │                                                      drinks            │     │
1364 │                                                      Number responding │ 4221│
1365 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1366
1367                              Descriptive Statistics
1368 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
1369 │                                                                    │  N │Mean│
1370 ├────────────────────────────────────────────────────────────────────┼────┼────┤
1371 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
1372 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
1373 │Valid N (listwise)                                                  │6999│    │
1374 │Missing N (listwise)                                                │2781│    │
1375 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
1376
1377                                   Custom Tables
1378 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
1379 │                                                      │    │     │ Valid│Total│
1380 │                                                      │Mean│Count│   N  │  N  │
1381 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1382 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
1383 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1384 │                you usually drink per sitting?        │    │     │      │     │
1385 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1386 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
1387 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1388 │                you usually drink per sitting?        │    │     │      │     │
1389 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1390 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
1391 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1392 │                you usually drink per sitting?        │    │     │      │     │
1393 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1394 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
1395 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1396 │                you usually drink per sitting?        │    │     │      │     │
1397 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1398 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
1399 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1400 │                you usually drink per sitting?        │    │     │      │     │
1401 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
1402 ])
1403 AT_CLEANUP
1404
1405 AT_SETUP([CTABLES subtotals])
1406 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1407 AT_DATA([ctables.sps],
1408 [[GET 'nhtsa.sav'.
1409 CTABLES /TABLE=qn105ba BY qns1
1410     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1411 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
1412     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
1413 CTABLES /TABLE=qn105ba BY qns1
1414     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
1415     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1416 ]])
1417 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1418                                                       Custom Tables
1419 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1420 │                                                         │ S1. Including yourself, how many members of this household │
1421 │                                                         │                    are age 16 or older?                    │
1422 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1423 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1424 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1425 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1426 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1427 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1428 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1429 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1430 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1431 │                                              likely     │       │       │         │       │        │      │          │
1432 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1433 │                                              unlikely   │       │       │         │       │        │      │          │
1434 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1435 │                                              unlikely   │       │       │         │       │        │      │          │
1436 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1437
1438                                                       Custom Tables
1439 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1440 │                                                        │  S1. Including yourself, how many members of this household │
1441 │                                                        │                     are age 16 or older?                    │
1442 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
1443 │                                                        │        │        │        │        │       │        │  6 or  │
1444 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
1445 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1446 │                                                        │        │        │        │        │ Column│        │        │
1447 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
1448 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1449 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
1450 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
1451 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
1452 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
1453 │                                             likely     │        │        │        │        │       │        │        │
1454 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
1455 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
1456 │                                             unlikely   │        │        │        │        │       │        │        │
1457 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
1458 │                                             unlikely   │        │        │        │        │       │        │        │
1459 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
1460 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
1461
1462                                                       Custom Tables
1463 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1464 │                                                         │ S1. Including yourself, how many members of this household │
1465 │                                                         │                    are age 16 or older?                    │
1466 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1467 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1468 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1469 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1470 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1471 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1472 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1473 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1474 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1475 │                                              likely     │       │       │         │       │        │      │          │
1476 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
1477 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1478 │                                              unlikely   │       │       │         │       │        │      │          │
1479 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1480 │                                              unlikely   │       │       │         │       │        │      │          │
1481 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
1482 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1483 ])
1484 AT_CLEANUP
1485
1486 AT_SETUP([CTABLES PCOMPUTE])
1487 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1488 AT_DATA([ctables.sps],
1489 [[GET 'nhtsa.sav'.
1490 CTABLES
1491     /PCOMPUTE &x=EXPR([3] + [4])
1492     /PCOMPUTE &y=EXPR([4] + [5])
1493     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
1494     /PPROPERTIES &y LABEL='4+5'
1495     /TABLE=qn105ba BY qns1
1496     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
1497 ]])
1498 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1499                                                       Custom Tables
1500 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1501 │                                                        │  S1. Including yourself, how many members of this household │
1502 │                                                        │                     are age 16 or older?                    │
1503 │                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
1504 │                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
1505 │                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1506 │                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
1507 ├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1508 │105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
1509 │had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
1510 │A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
1511 │                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
1512 │                                             likely     │       │       │          │       │        │      │          │
1513 │                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
1514 │                                             unlikely   │       │       │          │       │        │      │          │
1515 │                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
1516 │                                             unlikely   │       │       │          │       │        │      │          │
1517 ╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
1518 ])
1519 AT_CLEANUP
1520
1521 AT_SETUP([CTABLES CLABELS])
1522 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1523 AT_DATA([ctables.sps],
1524 [[GET 'nhtsa.sav'.
1525 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1526 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1527 ]])
1528 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1529                                                       Custom Tables
1530 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1531 │       │                                                 S3a. GENDER:                                                 │
1532 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
1533 │       │                         Male                         │                         Female                        │
1534 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
1535 │       │  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 │
1536 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
1537 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1538 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
1539 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1540 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
1541 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
1542 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
1543
1544                 Custom Tables
1545 ╭──────────────────────────────┬────────────╮
1546 │                              │S3a. GENDER:│
1547 │                              ├────────────┤
1548 │                              │    Count   │
1549 ├──────────────────────────────┼────────────┤
1550 │Age group 15 or younger Male  │           0│
1551 │                        Female│           0│
1552 │         ╶────────────────────┼────────────┤
1553 │          16 to 25      Male  │         594│
1554 │                        Female│         505│
1555 │         ╶────────────────────┼────────────┤
1556 │          26 to 35      Male  │         476│
1557 │                        Female│         491│
1558 │         ╶────────────────────┼────────────┤
1559 │          36 to 45      Male  │         489│
1560 │                        Female│         548│
1561 │         ╶────────────────────┼────────────┤
1562 │          46 to 55      Male  │         526│
1563 │                        Female│         649│
1564 │         ╶────────────────────┼────────────┤
1565 │          56 to 65      Male  │         516│
1566 │                        Female│         731│
1567 │         ╶────────────────────┼────────────┤
1568 │          66 or older   Male  │         531│
1569 │                        Female│         943│
1570 ╰──────────────────────────────┴────────────╯
1571 ])
1572 AT_CLEANUP
1573
1574 AT_SETUP([CTABLES missing values])
1575 AT_DATA([ctables.sps],
1576 [[DATA LIST LIST NOTABLE/x y.
1577 BEGIN DATA.
1578 1 1
1579 1 2
1580 1 3
1581 1 4
1582 1 5
1583 1 .
1584 2 1
1585 2 2
1586 2 3
1587 2 4
1588 2 5
1589 2 .
1590 3 1
1591 3 2
1592 3 3
1593 3 4
1594 3 5
1595 3 .
1596 4 1
1597 4 2
1598 4 3
1599 4 4
1600 4 5
1601 4 .
1602 5 1
1603 5 2
1604 5 3
1605 5 4
1606 5 5
1607 5 .
1608 . 1
1609 . 2
1610 . 3
1611 . 4
1612 . 5
1613 . .
1614 END DATA.
1615 MISSING VALUES x (1, 2) y (2, 3).
1616 VARIABLE LEVEL ALL (NOMINAL).
1617
1618 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1619                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1620     /CATEGORIES VARIABLES=ALL TOTAL=YES.
1621 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1622                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1623     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
1624 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1625                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1626     /CATEGORIES VARIABLES=ALL TOTAL=YES
1627     /SLABELS POSITION=ROW.
1628 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1629                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1630     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
1631     /SLABELS POSITION=ROW.
1632 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1633                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1634     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
1635     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
1636     /SLABELS POSITION=ROW.
1637 ]])
1638 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1639                                Custom Tables
1640 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1641 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1642 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1643 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1644 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1645 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1646 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
1647 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1648 dnl Note that Column Total N % doesn't add up to 100 because missing
1649 dnl values are included in the total but not shown as a category and this
1650 dnl is expected behavior.
1651
1652                                Custom Tables
1653 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1654 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1655 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1656 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1657 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1658 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1659 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1660 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1661 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
1662 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1663 dnl Note that Column Total N % doesn't add up to 100 because system-missing
1664 dnl values are included in the total but not shown as a category and this
1665 dnl is expected behavior.
1666
1667                      Custom Tables
1668 ╭────────────────────────┬───────────────────────────╮
1669 │                        │             y             │
1670 │                        ├──────┬──────┬──────┬──────┤
1671 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
1672 ├────────────────────────┼──────┼──────┼──────┼──────┤
1673 │x 3.00  Count           │     1│     1│     1│     3│
1674 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1675 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1676 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1677 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1678 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1679 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1680 │        Valid N         │      │      │      │     3│
1681 │        Total N         │      │      │      │     6│
1682 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1683 │  4.00  Count           │     1│     1│     1│     3│
1684 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1685 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1686 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1687 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1688 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1689 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1690 │        Valid N         │      │      │      │     3│
1691 │        Total N         │      │      │      │     6│
1692 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1693 │  5.00  Count           │     1│     1│     1│     3│
1694 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1695 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1696 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1697 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1698 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1699 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1700 │        Valid N         │      │      │      │     3│
1701 │        Total N         │      │      │      │     6│
1702 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1703 │  Total Count           │     3│     3│     3│     9│
1704 │        Column %        │100.0%│100.0%│100.0%│     .│
1705 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
1706 │        Column Total N %│100.0%│100.0%│100.0%│     .│
1707 │        Row %           │     .│     .│     .│     .│
1708 │        Row Valid N %   │     .│     .│     .│     .│
1709 │        Row Total N %   │     .│     .│     .│     .│
1710 │        Valid N         │     3│     3│     3│     9│
1711 │        Total N         │     6│     6│     6│    36│
1712 ╰────────────────────────┴──────┴──────┴──────┴──────╯
1713
1714                             Custom Tables
1715 ╭────────────────────────┬─────────────────────────────────────────╮
1716 │                        │                    y                    │
1717 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
1718 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1719 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1720 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
1721 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1722 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1723 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1724 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1725 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1726 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1727 │        Valid N         │      │      │      │      │      │     0│
1728 │        Total N         │      │      │      │      │      │     6│
1729 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1730 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
1731 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1732 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1733 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1734 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1735 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1736 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1737 │        Valid N         │      │      │      │      │      │     0│
1738 │        Total N         │      │      │      │      │      │     6│
1739 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1740 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
1741 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1742 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1743 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1744 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1745 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1746 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1747 │        Valid N         │      │      │      │      │      │     3│
1748 │        Total N         │      │      │      │      │      │     6│
1749 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1750 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
1751 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1752 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1753 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1754 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1755 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1756 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1757 │        Valid N         │      │      │      │      │      │     3│
1758 │        Total N         │      │      │      │      │      │     6│
1759 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1760 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
1761 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1762 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1763 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1764 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1765 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1766 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1767 │        Valid N         │      │      │      │      │      │     3│
1768 │        Total N         │      │      │      │      │      │     6│
1769 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1770 │  Total Count           │     5│     5│     5│     5│     5│    25│
1771 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
1772 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
1773 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
1774 │        Row %           │     .│     .│     .│     .│     .│     .│
1775 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1776 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
1777 │        Valid N         │     3│     0│     0│     3│     3│     9│
1778 │        Total N         │     6│     6│     6│     6│     6│    36│
1779 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
1780
1781                         Custom Tables
1782 ╭────────────────────────┬──────────────────────────────────╮
1783 │                        │                 y                │
1784 │                        ├──────┬──────┬──────┬──────┬──────┤
1785 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1786 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
1787 │x 1.00  Count           │     1│     1│     1│     1│     4│
1788 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1789 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
1790 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1791 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1792 │        Row Valid N %   │     .│     .│     .│     .│     .│
1793 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1794 │        Valid N         │      │      │      │      │     0│
1795 │        Total N         │      │      │      │      │     6│
1796 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1797 │  2.00  Count           │     1│     1│     1│     1│     4│
1798 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1799 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
1800 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1801 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1802 │        Row Valid N %   │     .│     .│     .│     .│     .│
1803 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1804 │        Valid N         │      │      │      │      │     0│
1805 │        Total N         │      │      │      │      │     6│
1806 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1807 │  3.00  Count           │     1│     1│     1│     1│     4│
1808 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1809 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
1810 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1811 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1812 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
1813 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1814 │        Valid N         │      │      │      │      │     3│
1815 │        Total N         │      │      │      │      │     6│
1816 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1817 │  4.00  Count           │     1│     1│     1│     1│     4│
1818 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1819 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
1820 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1821 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1822 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
1823 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1824 │        Valid N         │      │      │      │      │     3│
1825 │        Total N         │      │      │      │      │     6│
1826 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1827 │  Total Count           │     4│     4│     4│     4│    16│
1828 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
1829 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
1830 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
1831 │        Row %           │     .│     .│     .│     .│     .│
1832 │        Row Valid N %   │     .│     .│     .│     .│     .│
1833 │        Row Total N %   │     .│     .│     .│     .│     .│
1834 │        Valid N         │     2│     0│     2│     2│     6│
1835 │        Total N         │     5│     5│     5│     5│    30│
1836 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
1837 ])
1838 AT_CLEANUP
1839
1840 AT_SETUP([CTABLES SMISSING=LISTWISE])
1841 AT_KEYWORDS([SMISSING LISTWISE])
1842 AT_DATA([ctables.sps],
1843 [[DATA LIST LIST NOTABLE/x y z.
1844 BEGIN DATA.
1845 1  . 40
1846 1 10 50
1847 1 20 60
1848 1  .  .
1849 1 30  .
1850 END DATA.
1851 VARIABLE LEVEL x (NOMINAL).
1852
1853 CTABLES /TABLE (y + z) > x.
1854 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
1855
1856 * The following doesn't come out as listwise because the tables are
1857 separate, not linked by an > operator.
1858 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
1859 ]])
1860 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1861   Custom Tables
1862 ╭────────┬─────╮
1863 │        │ Mean│
1864 ├────────┼─────┤
1865 │y x 1.00│20.00│
1866 ├────────┼─────┤
1867 │z x 1.00│50.00│
1868 ╰────────┴─────╯
1869
1870   Custom Tables
1871 ╭────────┬─────╮
1872 │        │ Mean│
1873 ├────────┼─────┤
1874 │y x 1.00│15.00│
1875 ├────────┼─────┤
1876 │z x 1.00│55.00│
1877 ╰────────┴─────╯
1878
1879   Custom Tables
1880 ╭────────┬─────╮
1881 │        │ Mean│
1882 ├────────┼─────┤
1883 │y x 1.00│20.00│
1884 ├────────┼─────┤
1885 │z x 1.00│50.00│
1886 ╰────────┴─────╯
1887 ])
1888 AT_CLEANUP