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