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