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