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