4b520cc0cddd540a19ebeb8bfbb4660970772469
[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 - TITLES: )DATE, )TIME, )TABLE.
16 dnl - Test PCOMPUTE:
17 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
18 dnl   * MISSING, OTHERNM
19 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
20 dnl   * dates
21 dnl - PPROPERTIES:
22 dnl   * )LABEL[N].
23 dnl - Summary functions:
24 dnl   * U-prefix for unweighted summaries.
25 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
26 dnl - SPLIT FILE with SEPARATE splits
27 dnl - Definition of columns/rows when labels are rotated from one axis to another.
28 dnl
29 dnl Not for v1:
30 dnl - Multiple response sets
31 dnl - MRSETS subcommand.
32 dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
33 dnl - SIGTEST
34 dnl - COMPARETEST
35 dnl - Summary functions:
36 dnl   * .LCL and .UCL suffixes.
37 dnl   * .SE suffixes.
38 dnl - CATEGORIES:
39 dnl   * Data-dependent sorting.
40
41 AT_SETUP([CTABLES parsing])
42 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
43 AT_DATA([ctables.sps],
44 [[GET 'nhtsa.sav'.
45 CTABLES
46     /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
47     /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
48     /FORMAT UNITS=CM EMPTY="(-)"
49     /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
50     /VLABELS VARIABLES=qn17 DISPLAY=NAME
51     /VLABELS VARIABLES=qns3a DISPLAY=LABEL
52     /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
53     /VLABELS VARIABLES=qn20 DISPLAY=NONE
54     /MRSETS COUNTDUPLICATES=NO
55     /MRSETS COUNTDUPLICATES=YES
56     /SMISSING VARIABLE
57     /SMISSING LISTWISE
58     /WEIGHT VARIABLE=qns3a
59     /HIDESMALLCOUNTS
60     /HIDESMALLCOUNTS COUNT=10
61     /TABLE qnsa1
62     /SLABELS POSITION=COLUMN VISIBLE=YES
63     /SLABELS VISIBLE=NO POSITION=ROW
64     /SLABELS POSITION=LAYER
65     /CLABELS AUTO
66     /CLABELS ROWLABELS=OPPOSITE
67     /CRITERIA CILEVEL=50
68     /CATEGORIES VARIABLES=qn1 qn17
69                 ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
70                 POSITION=BEFORE EMPTY=INCLUDE.
71 CTABLES /TABLE qnsa1 /CLABELS ROWLABELS=LAYER.
72 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=OPPOSITE.
73 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=LAYER.
74 ]])
75 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
76          Custom Tables
77 Count
78 ╭───────────────────┬────┬────╮
79 │                   │ RDD│CELL│
80 ├───────────────────┼────┼────┤
81 │Sa1. SAMPLE SOURCE:│5392│1607│
82 ╰───────────────────┴────┴────╯
83
84        Custom Tables
85 RDD
86 ╭───────────────────┬─────╮
87 │                   │Count│
88 ├───────────────────┼─────┤
89 │Sa1. SAMPLE SOURCE:│ 5392│
90 ╰───────────────────┴─────╯
91
92           Custom Tables
93 ╭────────────────────────┬─────╮
94 │                        │Count│
95 ├────────────────────────┼─────┤
96 │Sa1. SAMPLE SOURCE: RDD │ 5392│
97 │                    CELL│ 1607│
98 ╰────────────────────────┴─────╯
99
100           Custom Tables
101 ╭────────────────────────┬─────╮
102 │                        │Count│
103 ├────────────────────────┼─────┤
104 │Sa1. SAMPLE SOURCE: RDD │ 5392│
105 │                    CELL│ 1607│
106 ╰────────────────────────┴─────╯
107 ])
108 AT_CLEANUP
109
110 AT_SETUP([CTABLES parsing - negative])
111 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
112 AT_DATA([ctables.sps],
113 [[GET 'nhtsa.sav'.
114 CTABLES.
115 CTABLES /FORMAT MINCOLWIDTH='foo'.
116 CTABLES /TABLE qn1 [**].
117 CTABLES /TABLE qn1 [NOTAFUNCTION].
118 CTABLES /TABLE (qn1.
119 CTABLES /TABLE **.
120 CTABLES /TABLE NOTAVAR.
121 STRING string(A8).
122 CTABLES /TABLE string[S].
123 CTABLES /TABLE qn1 [PTILE 101].
124 CTABLES /TABLE qn1 [MEAN F0.1].
125 CTABLES /TABLE qn1 [MEAN NEGPAREN1.2].
126 CTABLES /TABLE qn1 [MEAN NEGPAREN3.4].
127 CTABLES /TABLE qn1 [MEAN TOTALS].
128 CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
129 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [SUBTOTAL=x].
130 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO **].
131 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO THRU x].
132 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1 THRU **].
133 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['x' THRU **].
134 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&**].
135 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
136 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 101).
137 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1.
138 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN.
139 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 MISSING=**.
140 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 TOTAL=**.
141 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 LABEL=**.
142 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 POSITION=**.
143 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 EMPTY=**.
144 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 **.
145 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1,2,3] **.
146 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[0]).
147 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[1**]).
148 CTABLES /PCOMPUTE &k=EXPR([LO **]).
149 CTABLES /PCOMPUTE &k=EXPR([LO THRU **]).
150 CTABLES /PCOMPUTE &k=EXPR([1 THRU **]).
151 CTABLES /PCOMPUTE &k=EXPR([1**]).
152 CTABLES /PCOMPUTE &k=EXPR((1x)).
153 CTABLES /PCOMPUTE **k.
154 CTABLES /PCOMPUTE &1.
155 CTABLES /PCOMPUTE &k**.
156 CTABLES /PCOMPUTE &k=**.
157 CTABLES /PCOMPUTE &k=EXPR**.
158 CTABLES /PCOMPUTE &k=EXPR(1x).
159 CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
160 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=NOTAFUNCTION.
161 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=PTILE **.
162 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k LABEL=**.
163 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k HIDESOURCECATS=**.
164 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k **.
165 CTABLES /FORMAT EMPTY=**.
166 CTABLES /FORMAT MISSING=**.
167 CTABLES /FORMAT **.
168 CTABLES /FORMAT MINCOLWIDTH=20 MAXCOLWIDTH=10/.
169 CTABLES /VLABELS **.
170 CTABLES /VLABELS VARIABLES=NOTAVAR.
171 CTABLES /VLABELS VARIABLES=qn1 **.
172 CTABLES /VLABELS VARIABLES=qn1 DISPLAY=**.
173 CTABLES /MRSETS **.
174 CTABLES /MRSETS COUNTDUPLICATES=**.
175 CTABLES /SMISSING **.
176 CTABLES /WEIGHT **.
177 CTABLES /WEIGHT VARIABLE=NOTAVAR.
178 CTABLES /HIDESMALLCOUNTS COUNT=1.
179 CTABLES /QUUX.
180 CTABLES /HIDESMALLCOUNTS COUNT=2.
181 CTABLES /TABLE qn1**.
182 CTABLES /TABLE qn1 /SLABELS POSITION=**.
183 CTABLES /TABLE qn1 /SLABELS VISIBLE=**.
184 CTABLES /TABLE qn1 /SLABELS **.
185 CTABLES /TABLE qn1 /CLABELS ROWLABELS=**.
186 CTABLES /TABLE qn1 /CLABELS COLLABELS=**.
187 CTABLES /TABLE qn1 /CLABELS **.
188 CTABLES /TABLE qn1 /CRITERIA **.
189 CTABLES /TABLE qn1 /CRITERIA CILEVEL=101.
190 CTABLES /TABLE qn1 /TITLES **.
191 CTABLES /TABLE qn1 /SIGTEST TYPE=**.
192 CTABLES /TABLE qn1 /SIGTEST ALPHA=**.
193 CTABLES /TABLE qn1 /SIGTEST INCLUDEMRSETS=**.
194 CTABLES /TABLE qn1 /SIGTEST CATEGORIES=**.
195 CTABLES /TABLE qn1 /SIGTEST **.
196 CTABLES /TABLE qn1 /COMPARETEST TYPE=**.
197 CTABLES /TABLE qn1 /COMPARETEST ALPHA=**.
198 CTABLES /TABLE qn1 /COMPARETEST ALPHA=0,5.
199 CTABLES /TABLE qn1 /COMPARETEST ADJUST=**.
200 CTABLES /TABLE qn1 /COMPARETEST INCLUDEMRSETS=**.
201 CTABLES /TABLE qn1 /COMPARETEST MEANSVARIANCE=**.
202 CTABLES /TABLE qn1 /COMPARETEST CATEGORIES=**.
203 CTABLES /TABLE qn1 /COMPARETEST MERGE=**.
204 CTABLES /TABLE qn1 /COMPARETEST STYLE=**.
205 CTABLES /TABLE qn1 /COMPARETEST SHOWSIG=**.
206 CTABLES /TABLE qn1 /COMPARETEST **.
207 CTABLES /TABLE qn1 / **.
208 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CLABELS COLLABELS=OPPOSITE.
209 CTABLES /TABLE qn20 > qnd1.
210 CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
211 NUMERIC datetime (DATETIME17.0).
212 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
213 ]])
214 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
215 [[ctables.sps:2.8: error: CTABLES: Syntax error at end of command: expecting `/'.
216
217 ctables.sps:3.29-3.33: error: CTABLES: Syntax error at `'foo'': Expected non-
218 negative number for MINCOLWIDTH.
219
220 ctables.sps:4.21-4.22: error: CTABLES: Syntax error at `**': expecting
221 identifier.
222
223 ctables.sps:5.21-5.32: error: CTABLES: Syntax error at `NOTAFUNCTION': Expecting
224 summary function name.
225
226 ctables.sps:6.20: error: CTABLES: Syntax error at end of command: expecting `@:}@'.
227
228 ctables.sps:7.16-7.17: error: CTABLES: Syntax error at `**': expecting
229 identifier.
230
231 ctables.sps:8: error: CTABLES: NOTAVAR is not a variable name.
232
233 ctables.sps:10.16-10.24: error: CTABLES: Cannot use string variable string as a
234 scale variable.
235    10 | CTABLES /TABLE string[S].
236       |                ^~~~~~~~~
237
238 ctables.sps:11.27-11.29: error: CTABLES: Syntax error at `101': Expected number
239 between 0 and 100 for PTILE.
240
241 ctables.sps:12: error: CTABLES: Output format F0.1 specifies width 0, but F
242 requires a width between 1 and 40.
243
244 ctables.sps:13.26-13.36: error: CTABLES: Syntax error at `NEGPAREN1.2': Output
245 format NEGPAREN requires width 2 or greater.
246
247 ctables.sps:14.26-14.36: error: CTABLES: Syntax error at `NEGPAREN3.4': Output
248 format NEGPAREN requires width greater than decimals.
249
250 ctables.sps:15.21-15.24: error: CTABLES: Summary function MEAN applies only to
251 scale variables.
252    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
253       |                     ^~~~
254
255 ctables.sps:15.16-15.18: note: CTABLES: 'QN1' is not a scale variable.
256    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
257       |                ^~~
258
259 ctables.sps:15.32: error: CTABLES: Syntax error at `@:>@': expecting `@<:@'.
260
261 ctables.sps:16.21-16.24: error: CTABLES: Summary function MEAN applies only to
262 scale variables.
263    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
264       |                     ^~~~
265
266 ctables.sps:16.16-16.18: note: CTABLES: 'QN1' is not a scale variable.
267    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
268       |                ^~~
269
270 ctables.sps:16.40: error: CTABLES: Syntax error at `%': expecting `@:>@'.
271
272 ctables.sps:17.56: error: CTABLES: Syntax error at `x': expecting string.
273
274 ctables.sps:18.50-18.51: error: CTABLES: Syntax error at `**': expecting THRU.
275
276 ctables.sps:19.55: error: CTABLES: Syntax error at `x': expecting number.
277
278 ctables.sps:20.54-20.55: error: CTABLES: Syntax error at `**': expecting number.
279
280 ctables.sps:21.56-21.57: error: CTABLES: Syntax error at `**': expecting string.
281
282 ctables.sps:22.48-22.49: error: CTABLES: Syntax error at `**': expecting
283 identifier.
284
285 ctables.sps:23.47-23.48: error: CTABLES: Unknown postcompute &x.
286    23 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
287       |                                               ^~
288
289 ctables.sps:24.61-24.63: error: CTABLES: Syntax error at `101': Expected number
290 between 0 and 100 for PTILE.
291
292 ctables.sps:25.58: error: CTABLES: Syntax error at end of command: expecting
293 `@:}@'.
294
295 ctables.sps:26.54: error: CTABLES: Syntax error at end of command: expecting
296 `@{:@'.
297
298 ctables.sps:27.54-27.55: error: CTABLES: Syntax error at `**': expecting INCLUDE
299 or EXCLUDE.
300
301 ctables.sps:28.52-28.53: error: CTABLES: Syntax error at `**': expecting YES or
302 NO.
303
304 ctables.sps:29.52-29.53: error: CTABLES: Syntax error at `**': expecting string.
305
306 ctables.sps:30.55-30.56: error: CTABLES: Syntax error at `**': expecting BEFORE
307 or AFTER.
308
309 ctables.sps:31.52-31.53: error: CTABLES: Syntax error at `**': expecting INCLUDE
310 or EXCLUDE.
311
312 ctables.sps:32.46-32.47: error: CTABLES: Syntax error at `**': expecting ORDER,
313 KEY, MISSING, TOTAL, LABEL, POSITION, or EMPTY.
314
315 ctables.sps:33.54-33.55: error: CTABLES: Syntax error at `**': expecting TOTAL,
316 LABEL, POSITION, or EMPTY.
317
318 ctables.sps:34.36: error: CTABLES: Syntax error at `0': Expected positive
319 integer for SUBTOTAL.
320
321 ctables.sps:35.37-35.38: error: CTABLES: Syntax error at `**': expecting `@:>@'.
322
323 ctables.sps:36.31-36.32: error: CTABLES: Syntax error at `**': expecting THRU.
324
325 ctables.sps:37.36-37.37: error: CTABLES: Syntax error at `**': expecting number.
326
327 ctables.sps:38.35-38.36: error: CTABLES: Syntax error at `**': expecting number.
328
329 ctables.sps:39.29-39.30: error: CTABLES: Syntax error at `**': expecting `@:>@'.
330
331 ctables.sps:40.29: error: CTABLES: Syntax error at `x': expecting `@:}@'.
332
333 ctables.sps:41.19-41.20: error: CTABLES: Syntax error at `**': expecting &.
334
335 ctables.sps:42.20: error: CTABLES: Syntax error at `1': expecting identifier.
336
337 ctables.sps:43.21-43.22: error: CTABLES: Syntax error at `**': expecting `='.
338
339 ctables.sps:44.22-44.23: error: CTABLES: Syntax error at `**': expecting EXPR.
340
341 ctables.sps:45.26-45.27: error: CTABLES: Syntax error at `**': expecting `('.
342
343 ctables.sps:46.28: error: CTABLES: Syntax error at `x': expecting `)'.
344
345 ctables.sps:47.31-47.49: warning: CTABLES: New definition of &k will override
346 the previous definition.
347    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
348       |                               ^~~~~~~~~~~~~~~~~~~
349
350 ctables.sps:47.10-47.28: note: CTABLES: This is the previous definition.
351    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
352       |          ^~~~~~~~~~~~~~~~~~~
353
354 ctables.sps:47.50: error: CTABLES: Syntax error at end of command: expecting
355 `/'.
356
357 ctables.sps:48.53-48.64: error: CTABLES: Syntax error at `NOTAFUNCTION':
358 Expecting summary function name.
359
360 ctables.sps:49.59-49.60: error: CTABLES: Syntax error at `**': Expected number
361 between 0 and 100 for PTILE.
362
363 ctables.sps:50.52-50.53: error: CTABLES: Syntax error at `**': expecting string.
364
365 ctables.sps:51.61-51.62: error: CTABLES: Syntax error at `**': expecting YES or
366 NO.
367
368 ctables.sps:52.46-52.47: error: CTABLES: Syntax error at `**': expecting LABEL,
369 FORMAT, or HIDESOURCECATS.
370
371 ctables.sps:53.23-53.24: error: CTABLES: Syntax error at `**': expecting string.
372
373 ctables.sps:54.25-54.26: error: CTABLES: Syntax error at `**': expecting string.
374
375 ctables.sps:55.17-55.18: error: CTABLES: Syntax error at `**': expecting
376 MINCOLWIDTH, MAXCOLWIDTH, UNITS, EMPTY, or MISSING.
377
378 ctables.sps:56: error: CTABLES: MINCOLWIDTH must not be greater than
379 MAXCOLWIDTH.
380
381 ctables.sps:57.18-57.19: error: CTABLES: Syntax error at `**': expecting
382 VARIABLES.
383
384 ctables.sps:58: error: CTABLES: NOTAVAR is not a variable name.
385
386 ctables.sps:59.32-59.33: error: CTABLES: Syntax error at `**': expecting
387 DISPLAY.
388
389 ctables.sps:60.40-60.41: error: CTABLES: Syntax error at `**': expecting
390 DEFAULT, NAME, LABEL, BOTH, or NONE.
391
392 ctables.sps:61.17-61.18: error: CTABLES: Syntax error at `**': expecting
393 COUNTDUPLICATES.
394
395 ctables.sps:62.33-62.34: error: CTABLES: Syntax error at `**': expecting YES or
396 NO.
397
398 ctables.sps:63.19-63.20: error: CTABLES: Syntax error at `**': expecting
399 VARIABLE or LISTWISE.
400
401 ctables.sps:64.17-64.18: error: CTABLES: Syntax error at `**': expecting
402 VARIABLE.
403
404 ctables.sps:65: error: CTABLES: NOTAVAR is not a variable name.
405
406 ctables.sps:66.32: error: CTABLES: Syntax error at `1': Expected integer 2 or
407 greater for HIDESMALLCOUNTS COUNT.
408
409 ctables.sps:67.10-67.13: error: CTABLES: Syntax error at `QUUX': expecting
410 FORMAT, VLABELS, MRSETS, SMISSING, PCOMPUTE, PPROPERTIES, WEIGHT,
411 HIDESMALLCOUNTS, or TABLE.
412
413 ctables.sps:68.33: error: CTABLES: Syntax error at end of command: expecting
414 `/'.
415
416 ctables.sps:69.19-69.20: error: CTABLES: Syntax error at `**': expecting `/'.
417
418 ctables.sps:70.38-70.39: error: CTABLES: Syntax error at `**': expecting COLUMN,
419 ROW, or LAYER.
420
421 ctables.sps:71.37-71.38: error: CTABLES: Syntax error at `**': expecting YES or
422 NO.
423
424 ctables.sps:72.29-72.30: error: CTABLES: Syntax error at `**': expecting
425 POSITION or VISIBLE.
426
427 ctables.sps:73.39-73.40: error: CTABLES: Syntax error at `**': expecting
428 OPPOSITE or LAYER.
429
430 ctables.sps:74.39-74.40: error: CTABLES: Syntax error at `**': expecting
431 OPPOSITE or LAYER.
432
433 ctables.sps:75.29-75.30: error: CTABLES: Syntax error at `**': expecting AUTO,
434 ROWLABELS, or COLLABELS.
435
436 ctables.sps:76.30-76.31: error: CTABLES: Syntax error at `**': expecting
437 CILEVEL.
438
439 ctables.sps:77.38-77.40: error: CTABLES: Syntax error at `101': Expected number
440 in @<:@0,100@:}@ for CILEVEL.
441
442 ctables.sps:78.28-78.29: error: CTABLES: Syntax error at `**': expecting
443 CAPTION, CORNER, or TITLE.
444
445 ctables.sps:79.34-79.35: error: CTABLES: Syntax error at `**': expecting
446 CHISQUARE.
447
448 ctables.sps:80.35-80.36: error: CTABLES: Syntax error at `**': Expected number
449 in @<:@0,1@:}@ for ALPHA.
450
451 ctables.sps:81.43-81.44: error: CTABLES: Syntax error at `**': expecting YES or
452 NO.
453
454 ctables.sps:82.40-82.41: error: CTABLES: Syntax error at `**': expecting
455 ALLVISIBLE or SUBTOTALS.
456
457 ctables.sps:83.29-83.30: error: CTABLES: Syntax error at `**': expecting TYPE,
458 ALPHA, INCLUDEMRSETS, or CATEGORIES.
459
460 ctables.sps:84.38-84.39: error: CTABLES: Syntax error at `**': expecting PROP or
461 MEAN.
462
463 ctables.sps:85.39-85.40: error: CTABLES: Syntax error at `**': Expected number
464 in (0,1) for ALPHA.
465
466 ctables.sps:86.39: error: CTABLES: Syntax error at `0': Expected number in (0,1)
467 for ALPHA.
468
469 ctables.sps:87.40-87.41: error: CTABLES: Syntax error at `**': expecting
470 BONFERRONI, BH, or NONE.
471
472 ctables.sps:88.47-88.48: error: CTABLES: Syntax error at `**': expecting YES or
473 NO.
474
475 ctables.sps:89.47-89.48: error: CTABLES: Syntax error at `**': expecting ALLCATS
476 or TESTEDCATS.
477
478 ctables.sps:90.44-90.45: error: CTABLES: Syntax error at `**': expecting
479 ALLVISIBLE or SUBTOTALS.
480
481 ctables.sps:91.39-91.40: error: CTABLES: Syntax error at `**': expecting YES or
482 NO.
483
484 ctables.sps:92.39-92.40: error: CTABLES: Syntax error at `**': expecting APA or
485 SIMPLE.
486
487 ctables.sps:93.41-93.42: error: CTABLES: Syntax error at `**': expecting YES or
488 NO.
489
490 ctables.sps:94.33-94.34: error: CTABLES: Syntax error at `**': expecting TYPE,
491 ALPHA, ADJUST, INCLUDEMRSETS, MEANSVARIANCE, CATEGORIES, MERGE, STYLE, or
492 SHOWSIG.
493
494 ctables.sps:95.22-95.23: error: CTABLES: Syntax error at `**': expecting TABLE,
495 SLABELS, CLABELS, CRITERIA, CATEGORIES, TITLES, SIGTEST, or COMPARETEST.
496
497 ctables.sps:96: error: CTABLES: ROWLABELS and COLLABELS may not both be
498 specified.
499
500 ctables.sps:97.16-97.26: error: CTABLES: Cannot nest scale variables.
501    97 | CTABLES /TABLE qn20 > qnd1.
502       |                ^~~~~~~~~~~
503
504 ctables.sps:97.16-97.19: note: CTABLES: This is an outer scale variable.
505    97 | CTABLES /TABLE qn20 > qnd1.
506       |                ^~~~
507
508 ctables.sps:97.23-97.26: note: CTABLES: This is an inner scale variable.
509    97 | CTABLES /TABLE qn20 > qnd1.
510       |                       ^~~~
511
512 ctables.sps:98.16-98.35: error: CTABLES: Summaries may only be requested for
513 categorical variables at the innermost nesting level.
514    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
515       |                ^~~~~~~~~~~~~~~~~~~~
516
517 ctables.sps:98.16-98.18: note: CTABLES: This outer categorical variable has a
518 summary.
519    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
520       |                ^~~
521
522 ctables.sps:100.52-100.56: error: CTABLES: Failed to parse category
523 specification as format DATETIME: Day (123) must be between 1 and 31..
524   100 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
525       |                                                    ^~~~~
526 ]])
527 AT_CLEANUP
528
529 AT_SETUP([CTABLES parsing - more negative])
530 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
531 AT_DATA([ctables.sps],
532 [[GET 'nhtsa.sav'.
533 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
534 CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
535 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
536
537 STRING string(A8).
538 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
539 CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
540
541 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1).
542
543 CTABLES /TABLE qnd1 /CLABELS ROWLABELS=OPPOSITE.
544 CTABLES /TABLE qn1 + string /CLABELS ROWLABELS=OPPOSITE.
545 CTABLES /TABLE qn1 + qnsa1 /CLABELS ROWLABELS=OPPOSITE.
546 CTABLES /TABLE qn105ba + qn105bb /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn105ba [1,2,3].
547
548 CTABLES /PCOMPUTE &x=EXPR(1**2**3).
549 CTABLES /PCOMPUTE &x=EXPR([**]).
550 CTABLES /PCOMPUTE &x=EXPR(**).
551
552 CTABLES /TABLE.
553
554 CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. 
555 ]])
556 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
557 [[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a
558 category not included in the category list.
559     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
560 VARIABLES=qn1 [&pc].
561       |
562 ^~~
563
564 ctables.sps:2.28-2.35: note: CTABLES: This is the missing category.
565     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
566 VARIABLES=qn1 [&pc].
567       |                            ^~~~~~~~
568
569 ctables.sps:2.76-2.79: note: CTABLES: To fix the problem, add subtotals to the
570 list of categories here.
571     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
572 VARIABLES=qn1 [&pc].
573       |
574 ^~~~
575
576 ctables.sps:3.73-3.75: error: CTABLES: Computed category &pc references a
577 category not included in the category list.
578     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
579 [&pc].
580       |
581 ^~~
582
583 ctables.sps:3.28-3.32: note: CTABLES: This is the missing category.
584     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
585 [&pc].
586       |                            ^~~~~
587
588 ctables.sps:3: note: CTABLES: To fix the problem, add TOTAL=YES to the
589 variable's CATEGORIES specification.
590
591 ctables.sps:4.76-4.99: error: CTABLES: These categories include 2 instances of
592 SUBTOTAL or HSUBTOTAL, so references from computed categories must refer to
593 subtotals by position, e.g. SUBTOTAL[1].
594     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
595 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
596       |
597 ^~~~~~~~~~~~~~~~~~~~~~~~
598
599 ctables.sps:4.28-4.35: note: CTABLES: This is the reference that lacks a
600 position.
601     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
602 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
603       |                            ^~~~~~~~
604
605 ctables.sps:7.47-7.54: error: CTABLES: This category specification may be
606 applied only to string variables, but this subcommand tries to apply it to
607 numeric variable QN1.
608     7 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
609       |                                               ^~~~~~~~
610
611 ctables.sps:8.53: error: CTABLES: This category specification may be applied
612 only to numeric variables, but this subcommand tries to apply it to string
613 variable string.
614     8 | CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
615       |                                                     ^
616
617 ctables.sps:10: error: CTABLES: ROWLABELS=OPPOSITE is not allowed with sorting
618 based on a summary function.
619
620 ctables.sps:12: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
621 moved to be categorical, but qnd1 is a scale variable.
622
623 ctables.sps:13: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
624 moved to have the same width, but QN1 has width 0 and string has width 8.
625
626 ctables.sps:14: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
627 moved to have the same value labels, but QN1 and QNSA1 have different value
628 labels.
629
630 ctables.sps:15: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
631 moved to have the same category specifications, but QN105BA and QN105BB have
632 different category specifications.
633
634 ctables.sps:17.27-17.33: warning: CTABLES: The exponentiation operator (`**') is
635 left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'.  To disable
636 this warning, insert parentheses.
637    17 | CTABLES /PCOMPUTE &x=EXPR(1**2**3).
638       |                           ^~~~~~~
639
640 ctables.sps:17.35: error: CTABLES: Syntax error at end of command: expecting
641 `/'.
642
643 ctables.sps:18.28-18.29: error: CTABLES: Syntax error at `**'.
644
645 ctables.sps:19.27-19.28: error: CTABLES: Syntax error at `**'.
646
647 ctables.sps:21.15: error: CTABLES: Syntax error at end of command: At least one
648 variable must be specified.
649
650 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
651
652 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
653 summary.
654    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
655       |                ^~~~~
656
657 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
658 summary.
659    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
660       |                                 ^~~~~
661
662 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
663 summary.
664    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
665       |                                                  ^~~~~
666 ]])
667 AT_CLEANUP
668
669 AT_SETUP([CTABLES one categorical variable])
670 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
671 AT_DATA([ctables.sps],
672 [[GET 'nhtsa.sav'.
673 CTABLES /TABLE qn1.
674 CTABLES /TABLE BY qn1.
675 CTABLES /TABLE BY BY qn1.
676 ]])
677 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
678                                   Custom Tables
679 ╭────────────────────────────────────────────────────────────────────────┬─────╮
680 │                                                                        │Count│
681 ├────────────────────────────────────────────────────────────────────────┼─────┤
682 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
683 │motor vehicle?                                     Several days a week  │ 1274│
684 │                                                   Once a week or less  │  361│
685 │                                                   Only certain times a │  130│
686 │                                                   year                 │     │
687 │                                                   Never                │  540│
688 ╰────────────────────────────────────────────────────────────────────────┴─────╯
689
690                                   Custom Tables
691 ╭──────────────────────────────────────────────────────────────────────────────╮
692 │        1. How often do you usually drive a car or other motor vehicle?       │
693 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
694 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
695 │Every day│       week       │       less       │          year          │Never│
696 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
697 │  Count  │       Count      │       Count      │          Count         │Count│
698 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
699 │     4667│              1274│               361│                     130│  540│
700 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
701
702 Custom Tables
703 Every day
704 ╭─────╮
705 │Count│
706 ├─────┤
707 │ 4667│
708 ╰─────╯
709 ])
710 AT_CLEANUP
711
712 AT_SETUP([CTABLES one string variable])
713 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
714 AT_DATA([ctables.sps],
715 [[GET 'nhtsa.sav'.
716 STRING licensed(A8).
717 MISSING VALUES licensed('DontKnow', 'Refused').
718 RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
719 CTABLES /TABLE licensed.
720 CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
721 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
722 * Notice that the string matching is case-sensitive.
723 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
724 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
725 CTABLES
726     /PCOMPUTE &notyes=EXPR(['No']+['DontKnow']+['Refused'])
727     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
728     /TABLE licensed
729     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'No', 'DontKnow', 'Refused'].
730 CTABLES
731     /PCOMPUTE &notyes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
732     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
733     /TABLE licensed
734     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'DontKnow' THRU 'No', 'Refused'].
735 ]])
736 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
737     Custom Tables
738 ╭────────────┬─────╮
739 │            │Count│
740 ├────────────┼─────┤
741 │licensed No │  572│
742 │         Yes│ 6379│
743 ╰────────────┴─────╯
744
745           Custom Tables
746 ╭─────────────────┬─────┬───────╮
747 │                 │Count│Valid N│
748 ├─────────────────┼─────┼───────┤
749 │licensed DontKnow│    4│       │
750 │         No      │  572│       │
751 │         Refused │   44│       │
752 │         Yes     │ 6379│       │
753 │         Total   │ 6999│   6951│
754 ╰─────────────────┴─────┴───────╯
755
756      Custom Tables
757 ╭──────────────┬─────╮
758 │              │Count│
759 ├──────────────┼─────┤
760 │licensed Yes  │ 6379│
761 │         No   │  572│
762 │         Total│ 6951│
763 ╰──────────────┴─────╯
764
765      Custom Tables
766 ╭──────────────┬─────╮
767 │              │Count│
768 ├──────────────┼─────┤
769 │licensed Yes  │ 6379│
770 │         no   │    0│
771 │         Total│ 6379│
772 ╰──────────────┴─────╯
773
774       Custom Tables
775 ╭────────────────┬─────╮
776 │                │Count│
777 ├────────────────┼─────┤
778 │licensed No     │  572│
779 │         Refused│   44│
780 │         Yes    │ 6379│
781 │         Total  │ 6995│
782 ╰────────────────┴─────╯
783
784       Custom Tables
785 ╭────────────────┬─────╮
786 │                │Count│
787 ├────────────────┼─────┤
788 │licensed Yes    │ 6379│
789 │         Not Yes│  620│
790 ╰────────────────┴─────╯
791
792       Custom Tables
793 ╭────────────────┬─────╮
794 │                │Count│
795 ├────────────────┼─────┤
796 │licensed Yes    │ 6379│
797 │         Not Yes│  620│
798 ╰────────────────┴─────╯
799 ])
800 AT_CLEANUP
801
802 AT_SETUP([CTABLES one scale variable])
803 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
804 AT_DATA([ctables.sps],
805 [[GET 'nhtsa.sav'.
806 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
807 CTABLES /TABLE BY qnd1.
808 CTABLES /TABLE BY BY qnd1.
809 ]])
810 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
811                                   Custom Tables
812 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
813 │                      │     │       │       │    │     Std    │       │       │
814 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
815 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
816 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
817 │age?                  │     │       │       │    │            │       │       │
818 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
819
820         Custom Tables
821 ╭──────────────────────────╮
822 │D1. AGE: What is your age?│
823 ├──────────────────────────┤
824 │           Mean           │
825 ├──────────────────────────┤
826 │                        48│
827 ╰──────────────────────────╯
828
829 Custom Tables
830 D1. AGE: What is your age?
831 ╭────╮
832 │Mean│
833 ├────┤
834 │  48│
835 ╰────╯
836 ])
837 AT_CLEANUP
838
839 AT_SETUP([CTABLES simple stacking])
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_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1077 AT_DATA([ctables.sps],
1078 [[GET 'nhtsa.sav'.
1079 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
1080   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
1081 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
1082   /CATEGORIES VARIABLES=qns3a TOTAL=YES
1083   /CLABELS ROW=OPPOSITE.
1084 ]])
1085 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1086                                   Custom Tables
1087 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
1088 │                                                                 │     │ Table│
1089 │                                                                 │Count│   %  │
1090 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1091 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
1092 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
1093 │drive safely will A. Get stopped by                        Total │  700│   10%│
1094 │the police?                           ╶──────────────────────────┼─────┼──────┤
1095 │                                       Very       S3a.     Male  │  660│   10%│
1096 │                                       likely     GENDER:  Female│  842│   12%│
1097 │                                                           Total │ 1502│   22%│
1098 │                                      ╶──────────────────────────┼─────┼──────┤
1099 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
1100 │                                       likely     GENDER:  Female│ 1589│   23%│
1101 │                                                           Total │ 2763│   40%│
1102 │                                      ╶──────────────────────────┼─────┼──────┤
1103 │                                       Somewhat   S3a.     Male  │  640│    9%│
1104 │                                       unlikely   GENDER:  Female│  667│   10%│
1105 │                                                           Total │ 1307│   19%│
1106 │                                      ╶──────────────────────────┼─────┼──────┤
1107 │                                       Very       S3a.     Male  │  311│    5%│
1108 │                                       unlikely   GENDER:  Female│  298│    4%│
1109 │                                                           Total │  609│    9%│
1110 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1111 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
1112 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
1113 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
1114 │                                      ╶──────────────────────────┼─────┼──────┤
1115 │                                       Very       S3a.     Male  │ 1104│   16%│
1116 │                                       likely     GENDER:  Female│ 1715│   25%│
1117 │                                                           Total │ 2819│   41%│
1118 │                                      ╶──────────────────────────┼─────┼──────┤
1119 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
1120 │                                       likely     GENDER:  Female│ 1214│   18%│
1121 │                                                           Total │ 2417│   35%│
1122 │                                      ╶──────────────────────────┼─────┼──────┤
1123 │                                       Somewhat   S3a.     Male  │  262│    4%│
1124 │                                       unlikely   GENDER:  Female│  168│    2%│
1125 │                                                           Total │  430│    6%│
1126 │                                      ╶──────────────────────────┼─────┼──────┤
1127 │                                       Very       S3a.     Male  │   81│    1%│
1128 │                                       unlikely   GENDER:  Female│   59│    1%│
1129 │                                                           Total │  140│    2%│
1130 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1131 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
1132 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
1133 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
1134 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1135 │                                       Very       S3a.     Male  │  988│   14%│
1136 │                                       likely     GENDER:  Female│ 1049│   15%│
1137 │                                                           Total │ 2037│   30%│
1138 │                                      ╶──────────────────────────┼─────┼──────┤
1139 │                                       Somewhat   S3a.     Male  │  822│   12%│
1140 │                                       likely     GENDER:  Female│ 1210│   18%│
1141 │                                                           Total │ 2032│   30%│
1142 │                                      ╶──────────────────────────┼─────┼──────┤
1143 │                                       Somewhat   S3a.     Male  │  446│    7%│
1144 │                                       unlikely   GENDER:  Female│  548│    8%│
1145 │                                                           Total │  994│   15%│
1146 │                                      ╶──────────────────────────┼─────┼──────┤
1147 │                                       Very       S3a.     Male  │  268│    4%│
1148 │                                       unlikely   GENDER:  Female│  354│    5%│
1149 │                                                           Total │  622│    9%│
1150 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1151 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
1152 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
1153 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
1154 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1155 │                                       Very       S3a.     Male  │  805│   12%│
1156 │                                       likely     GENDER:  Female│ 1029│   15%│
1157 │                                                           Total │ 1834│   27%│
1158 │                                      ╶──────────────────────────┼─────┼──────┤
1159 │                                       Somewhat   S3a.     Male  │  975│   14%│
1160 │                                       likely     GENDER:  Female│ 1332│   19%│
1161 │                                                           Total │ 2307│   34%│
1162 │                                      ╶──────────────────────────┼─────┼──────┤
1163 │                                       Somewhat   S3a.     Male  │  535│    8%│
1164 │                                       unlikely   GENDER:  Female│  560│    8%│
1165 │                                                           Total │ 1095│   16%│
1166 │                                      ╶──────────────────────────┼─────┼──────┤
1167 │                                       Very       S3a.     Male  │  270│    4%│
1168 │                                       unlikely   GENDER:  Female│  279│    4%│
1169 │                                                           Total │  549│    8%│
1170 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1171
1172                                   Custom Tables
1173 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
1174 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
1175 │                                 │ certain│likely│  likely │ unlikely│unlikely│
1176 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
1177 │                                 │        │ Table│         │         │        │
1178 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
1179 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1180 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
1181 │GENDER:        is it that drivers│        │      │         │         │        │
1182 │               who have had too  │        │      │         │         │        │
1183 │               much to drink to  │        │      │         │         │        │
1184 │               drive safely will │        │      │         │         │        │
1185 │               A. Get stopped by │        │      │         │         │        │
1186 │               the police?       │        │      │         │         │        │
1187 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1188 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
1189 │               is it that drivers│        │      │         │         │        │
1190 │               who have had too  │        │      │         │         │        │
1191 │               much to drink to  │        │      │         │         │        │
1192 │               drive safely will │        │      │         │         │        │
1193 │               A. Get stopped by │        │      │         │         │        │
1194 │               the police?       │        │      │         │         │        │
1195 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1196 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
1197 │               is it that drivers│        │      │         │         │        │
1198 │               who have had too  │        │      │         │         │        │
1199 │               much to drink to  │        │      │         │         │        │
1200 │               drive safely will │        │      │         │         │        │
1201 │               A. Get stopped by │        │      │         │         │        │
1202 │               the police?       │        │      │         │         │        │
1203 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1204 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
1205 │GENDER:        is it that drivers│        │      │         │         │        │
1206 │               who have had too  │        │      │         │         │        │
1207 │               much to drink to  │        │      │         │         │        │
1208 │               drive safely will │        │      │         │         │        │
1209 │               B. Have an        │        │      │         │         │        │
1210 │               accident?         │        │      │         │         │        │
1211 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1212 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
1213 │               is it that drivers│        │      │         │         │        │
1214 │               who have had too  │        │      │         │         │        │
1215 │               much to drink to  │        │      │         │         │        │
1216 │               drive safely will │        │      │         │         │        │
1217 │               B. Have an        │        │      │         │         │        │
1218 │               accident?         │        │      │         │         │        │
1219 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1220 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
1221 │               is it that drivers│        │      │         │         │        │
1222 │               who have had too  │        │      │         │         │        │
1223 │               much to drink to  │        │      │         │         │        │
1224 │               drive safely will │        │      │         │         │        │
1225 │               B. Have an        │        │      │         │         │        │
1226 │               accident?         │        │      │         │         │        │
1227 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1228 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
1229 │GENDER:        is it that drivers│        │      │         │         │        │
1230 │               who have had too  │        │      │         │         │        │
1231 │               much to drink to  │        │      │         │         │        │
1232 │               drive safely will │        │      │         │         │        │
1233 │               C. Be convicted   │        │      │         │         │        │
1234 │               for drunk driving?│        │      │         │         │        │
1235 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1236 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
1237 │               is it that drivers│        │      │         │         │        │
1238 │               who have had too  │        │      │         │         │        │
1239 │               much to drink to  │        │      │         │         │        │
1240 │               drive safely will │        │      │         │         │        │
1241 │               C. Be convicted   │        │      │         │         │        │
1242 │               for drunk driving?│        │      │         │         │        │
1243 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1244 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
1245 │               is it that drivers│        │      │         │         │        │
1246 │               who have had too  │        │      │         │         │        │
1247 │               much to drink to  │        │      │         │         │        │
1248 │               drive safely will │        │      │         │         │        │
1249 │               C. Be convicted   │        │      │         │         │        │
1250 │               for drunk driving?│        │      │         │         │        │
1251 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1252 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
1253 │GENDER:        is it that drivers│        │      │         │         │        │
1254 │               who have had too  │        │      │         │         │        │
1255 │               much to drink to  │        │      │         │         │        │
1256 │               drive safely will │        │      │         │         │        │
1257 │               D. Be arrested for│        │      │         │         │        │
1258 │               drunk driving?    │        │      │         │         │        │
1259 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1260 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
1261 │               is it that drivers│        │      │         │         │        │
1262 │               who have had too  │        │      │         │         │        │
1263 │               much to drink to  │        │      │         │         │        │
1264 │               drive safely will │        │      │         │         │        │
1265 │               D. Be arrested for│        │      │         │         │        │
1266 │               drunk driving?    │        │      │         │         │        │
1267 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1268 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
1269 │               is it that drivers│        │      │         │         │        │
1270 │               who have had too  │        │      │         │         │        │
1271 │               much to drink to  │        │      │         │         │        │
1272 │               drive safely will │        │      │         │         │        │
1273 │               D. Be arrested for│        │      │         │         │        │
1274 │               drunk driving?    │        │      │         │         │        │
1275 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
1276 ])
1277 AT_CLEANUP
1278
1279 AT_SETUP([CTABLES nesting and scale variables])
1280 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1281 AT_DATA([ctables.sps],
1282 [[GET 'nhtsa.sav'.
1283 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
1284 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
1285 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
1286   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
1287 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
1288 ]])
1289 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1290                                   Custom Tables
1291 ╭─────────────────────────────────────────────────────────────────┬────────────╮
1292 │                                                                 │S3a. GENDER:│
1293 │                                                                 ├─────┬──────┤
1294 │                                                                 │ Male│Female│
1295 │                                                                 ├─────┼──────┤
1296 │                                                                 │ Mean│ Mean │
1297 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1298 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
1299 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
1300 │                                                  week           │     │      │
1301 │                                                  Once a week or │   44│    54│
1302 │                                                  less           │     │      │
1303 │                                                  Only certain   │   34│    41│
1304 │                                                  times a year   │     │      │
1305 │                                                  Never          │   39│    55│
1306 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1307
1308                                   Custom Tables
1309 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
1310 │                                                         │Minimum│Maximum│Mean│
1311 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1312 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
1313 │What is  GENDER:         months, has there been a        │       │       │    │
1314 │your                     time when you felt you          │       │       │    │
1315 │age?                     should cut down on your      No │     16│     86│  46│
1316 │                         drinking?                       │       │       │    │
1317 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1318 │                  Female 26. During the last 12       Yes│     16│     86│  43│
1319 │                         months, has there been a        │       │       │    │
1320 │                         time when you felt you          │       │       │    │
1321 │                         should cut down on your      No │     16│     86│  48│
1322 │                         drinking?                       │       │       │    │
1323 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1324 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
1325 │What is  GENDER:         months, has there been a        │       │       │    │
1326 │your                     time when people criticized  No │     16│     86│  46│
1327 │age?                     your drinking?                  │       │       │    │
1328 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1329 │                  Female 27. During the last 12       Yes│     17│     69│  37│
1330 │                         months, has there been a        │       │       │    │
1331 │                         time when people criticized  No │     16│     86│  48│
1332 │                         your drinking?                  │       │       │    │
1333 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
1334
1335                                   Custom Tables
1336 ╭─────────────────────────────┬────────────────────────────────────────────────╮
1337 │                             │S1. Including yourself, how many members of this│
1338 │                             │         household are age 16 or older?         │
1339 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
1340 │                             │      │      │      │      │      │      │ 6 or │
1341 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
1342 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1343 │                             │Column│Column│Column│Column│Column│Column│Column│
1344 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
1345 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1346 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
1347 │SAMPLE      How      certain │      │      │      │      │      │      │      │
1348 │SOURCE:     likely           │      │      │      │      │      │      │      │
1349 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
1350 │            that     likely  │      │      │      │      │      │      │      │
1351 │            drivers          │      │      │      │      │      │      │      │
1352 │            who have         │      │      │      │      │      │      │      │
1353 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
1354 │            much to  likely  │      │      │      │      │      │      │      │
1355 │            drink to         │      │      │      │      │      │      │      │
1356 │            drive            │      │      │      │      │      │      │      │
1357 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
1358 │            will A.  unlikely│      │      │      │      │      │      │      │
1359 │            Get              │      │      │      │      │      │      │      │
1360 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
1361 │            by the   unlikely│      │      │      │      │      │      │      │
1362 │            police?          │      │      │      │      │      │      │      │
1363 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
1364
1365                                   Custom Tables
1366 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
1367 │                                                              │    │    Std   │
1368 │                                                              │Mean│ Deviation│
1369 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
1370 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
1371 │group           typical month did you have one or more        │    │          │
1372 │                alcoholic beverages to drink?                 │    │          │
1373 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1374 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
1375 │                typical month did you have one or more        │    │          │
1376 │                alcoholic beverages to drink?                 │    │          │
1377 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1378 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
1379 │                typical month did you have one or more        │    │          │
1380 │                alcoholic beverages to drink?                 │    │          │
1381 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1382 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
1383 │                typical month did you have one or more        │    │          │
1384 │                alcoholic beverages to drink?                 │    │          │
1385 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1386 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
1387 │                typical month did you have one or more        │    │          │
1388 │                alcoholic beverages to drink?                 │    │          │
1389 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1390 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
1391 │       older    typical month did you have one or more        │    │          │
1392 │                alcoholic beverages to drink?                 │    │          │
1393 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
1394 ])
1395 AT_CLEANUP
1396
1397
1398 AT_SETUP([CTABLES SLABELS])
1399 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1400 AT_DATA([ctables.sps],
1401 [[GET 'nhtsa.sav'.
1402 CTABLES /TABLE qn1 [COUNT COLPCT].
1403 CTABLES /TABLE qn1 [COUNT COLPCT]
1404     /SLABELS POSITION=ROW.
1405 CTABLES /TABLE qn1 [COUNT COLPCT]
1406     /SLABELS POSITION=ROW VISIBLE=NO.
1407 ]])
1408 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1409                                   Custom Tables
1410 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
1411 │                                                                │     │ Column│
1412 │                                                                │Count│   %   │
1413 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
1414 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
1415 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
1416 │                                             Once a week or less│  361│   5.2%│
1417 │                                             Only certain times │  130│   1.9%│
1418 │                                             a year             │     │       │
1419 │                                             Never              │  540│   7.7%│
1420 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
1421
1422                                   Custom Tables
1423 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1424 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
1425 │other motor vehicle?                                             Column │66.9%│
1426 │                                                                 %      │     │
1427 │                                            ╶───────────────────────────┼─────┤
1428 │                                             Several days a week Count  │ 1274│
1429 │                                                                 Column │18.3%│
1430 │                                                                 %      │     │
1431 │                                            ╶───────────────────────────┼─────┤
1432 │                                             Once a week or less Count  │  361│
1433 │                                                                 Column │ 5.2%│
1434 │                                                                 %      │     │
1435 │                                            ╶───────────────────────────┼─────┤
1436 │                                             Only certain times  Count  │  130│
1437 │                                             a year              Column │ 1.9%│
1438 │                                                                 %      │     │
1439 │                                            ╶───────────────────────────┼─────┤
1440 │                                             Never               Count  │  540│
1441 │                                                                 Column │ 7.7%│
1442 │                                                                 %      │     │
1443 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1444
1445                                   Custom Tables
1446 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1447 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
1448 │motor vehicle?                                                          │66.9%│
1449 │                                                   Several days a week  │ 1274│
1450 │                                                                        │18.3%│
1451 │                                                   Once a week or less  │  361│
1452 │                                                                        │ 5.2%│
1453 │                                                   Only certain times a │  130│
1454 │                                                   year                 │ 1.9%│
1455 │                                                   Never                │  540│
1456 │                                                                        │ 7.7%│
1457 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1458 ])
1459 AT_CLEANUP
1460
1461 AT_SETUP([CTABLES simple totals])
1462 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1463 AT_DATA([ctables.sps],
1464 [[GET 'nhtsa.sav'.
1465 CTABLES /TABLE=qn17
1466     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
1467 DESCRIPTIVES qn18/STATISTICS=MEAN.
1468 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
1469     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
1470 ]])
1471 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1472                                   Custom Tables
1473 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1474 │                                                                        │Count│
1475 ├────────────────────────────────────────────────────────────────────────┼─────┤
1476 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
1477 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
1478 │                                                      Light beer        │  620│
1479 │                                                      Wine              │ 1418│
1480 │                                                      Wine coolers      │  137│
1481 │                                                      Hard liquor or    │  888│
1482 │                                                      mixed drinks      │     │
1483 │                                                      Flavored malt     │   83│
1484 │                                                      drinks            │     │
1485 │                                                      Number responding │ 4221│
1486 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1487
1488                              Descriptive Statistics
1489 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
1490 │                                                                    │  N │Mean│
1491 ├────────────────────────────────────────────────────────────────────┼────┼────┤
1492 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
1493 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
1494 │Valid N (listwise)                                                  │6999│    │
1495 │Missing N (listwise)                                                │2781│    │
1496 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
1497
1498                                   Custom Tables
1499 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
1500 │                                                      │    │     │ Valid│Total│
1501 │                                                      │Mean│Count│   N  │  N  │
1502 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1503 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
1504 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1505 │                you usually drink per sitting?        │    │     │      │     │
1506 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1507 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
1508 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1509 │                you usually drink per sitting?        │    │     │      │     │
1510 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1511 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
1512 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1513 │                you usually drink per sitting?        │    │     │      │     │
1514 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1515 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
1516 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1517 │                you usually drink per sitting?        │    │     │      │     │
1518 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1519 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
1520 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1521 │                you usually drink per sitting?        │    │     │      │     │
1522 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
1523 ])
1524 AT_CLEANUP
1525
1526 AT_SETUP([CTABLES subtotals])
1527 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1528 AT_DATA([ctables.sps],
1529 [[GET 'nhtsa.sav'.
1530 CTABLES /TABLE=qn105ba BY qns1
1531     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1532 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
1533     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
1534 CTABLES /TABLE=qn105ba BY qns1
1535     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
1536     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1537 ]])
1538 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1539                                                       Custom Tables
1540 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1541 │                                                         │ S1. Including yourself, how many members of this household │
1542 │                                                         │                    are age 16 or older?                    │
1543 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1544 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1545 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1546 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1547 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1548 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1549 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1550 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1551 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1552 │                                              likely     │       │       │         │       │        │      │          │
1553 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1554 │                                              unlikely   │       │       │         │       │        │      │          │
1555 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1556 │                                              unlikely   │       │       │         │       │        │      │          │
1557 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1558
1559                                                       Custom Tables
1560 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1561 │                                                        │  S1. Including yourself, how many members of this household │
1562 │                                                        │                     are age 16 or older?                    │
1563 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
1564 │                                                        │        │        │        │        │       │        │  6 or  │
1565 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
1566 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1567 │                                                        │        │        │        │        │ Column│        │        │
1568 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
1569 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1570 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
1571 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
1572 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
1573 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
1574 │                                             likely     │        │        │        │        │       │        │        │
1575 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
1576 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
1577 │                                             unlikely   │        │        │        │        │       │        │        │
1578 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
1579 │                                             unlikely   │        │        │        │        │       │        │        │
1580 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
1581 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
1582
1583                                                       Custom Tables
1584 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1585 │                                                         │ S1. Including yourself, how many members of this household │
1586 │                                                         │                    are age 16 or older?                    │
1587 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1588 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1589 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1590 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1591 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1592 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1593 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1594 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1595 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1596 │                                              likely     │       │       │         │       │        │      │          │
1597 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
1598 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1599 │                                              unlikely   │       │       │         │       │        │      │          │
1600 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1601 │                                              unlikely   │       │       │         │       │        │      │          │
1602 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
1603 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1604 ])
1605 AT_CLEANUP
1606
1607 AT_SETUP([CTABLES PCOMPUTE])
1608 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1609 AT_DATA([ctables.sps],
1610 [[GET 'nhtsa.sav'.
1611 CTABLES
1612     /PCOMPUTE &x=EXPR([3] + [4])
1613     /PCOMPUTE &y=EXPR([4] + [5])
1614     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
1615     /PPROPERTIES &y LABEL='4+5'
1616     /TABLE=qn105ba BY qns1
1617     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
1618 ]])
1619 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1620                                                       Custom Tables
1621 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1622 │                                                        │  S1. Including yourself, how many members of this household │
1623 │                                                        │                     are age 16 or older?                    │
1624 │                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
1625 │                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
1626 │                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1627 │                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
1628 ├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1629 │105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
1630 │had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
1631 │A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
1632 │                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
1633 │                                             likely     │       │       │          │       │        │      │          │
1634 │                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
1635 │                                             unlikely   │       │       │          │       │        │      │          │
1636 │                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
1637 │                                             unlikely   │       │       │          │       │        │      │          │
1638 ╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
1639 ])
1640 AT_CLEANUP
1641
1642 AT_SETUP([CTABLES CLABELS])
1643 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1644 AT_DATA([ctables.sps],
1645 [[GET 'nhtsa.sav'.
1646 CTABLES /TABLE AgeGroup BY qns3a.
1647 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1648 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1649 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
1650 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
1651 ]])
1652 pwd
1653 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
1654              Custom Tables
1655 ╭───────────────────────┬────────────╮
1656 │                       │S3a. GENDER:│
1657 │                       ├─────┬──────┤
1658 │                       │ Male│Female│
1659 │                       ├─────┼──────┤
1660 │                       │Count│ Count│
1661 ├───────────────────────┼─────┼──────┤
1662 │Age group 15 or younger│    0│     0│
1663 │          16 to 25     │  594│   505│
1664 │          26 to 35     │  476│   491│
1665 │          36 to 45     │  489│   548│
1666 │          46 to 55     │  526│   649│
1667 │          56 to 65     │  516│   731│
1668 │          66 or older  │  531│   943│
1669 ╰───────────────────────┴─────┴──────╯
1670
1671                                                       Custom Tables
1672 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1673 │       │                                                 S3a. GENDER:                                                 │
1674 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
1675 │       │                         Male                         │                         Female                        │
1676 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
1677 │       │  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 │
1678 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
1679 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1680 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
1681 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1682 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
1683 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
1684 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
1685
1686                 Custom Tables
1687 ╭──────────────────────────────┬────────────╮
1688 │                              │S3a. GENDER:│
1689 │                              ├────────────┤
1690 │                              │    Count   │
1691 ├──────────────────────────────┼────────────┤
1692 │Age group 15 or younger Male  │           0│
1693 │                        Female│           0│
1694 │         ╶────────────────────┼────────────┤
1695 │          16 to 25      Male  │         594│
1696 │                        Female│         505│
1697 │         ╶────────────────────┼────────────┤
1698 │          26 to 35      Male  │         476│
1699 │                        Female│         491│
1700 │         ╶────────────────────┼────────────┤
1701 │          36 to 45      Male  │         489│
1702 │                        Female│         548│
1703 │         ╶────────────────────┼────────────┤
1704 │          46 to 55      Male  │         526│
1705 │                        Female│         649│
1706 │         ╶────────────────────┼────────────┤
1707 │          56 to 65      Male  │         516│
1708 │                        Female│         731│
1709 │         ╶────────────────────┼────────────┤
1710 │          66 or older   Male  │         531│
1711 │                        Female│         943│
1712 ╰──────────────────────────────┴────────────╯
1713
1714       Custom Tables
1715 15 or younger
1716 ╭─────────┬────────────╮
1717 │         │S3a. GENDER:│
1718 │         ├─────┬──────┤
1719 │         │ Male│Female│
1720 │         ├─────┼──────┤
1721 │         │Count│ Count│
1722 ├─────────┼─────┼──────┤
1723 │Age group│    0│     0│
1724 ╰─────────┴─────┴──────╯
1725
1726       Custom Tables
1727 16 to 25
1728 ╭─────────┬────────────╮
1729 │         │S3a. GENDER:│
1730 │         ├─────┬──────┤
1731 │         │ Male│Female│
1732 │         ├─────┼──────┤
1733 │         │Count│ Count│
1734 ├─────────┼─────┼──────┤
1735 │Age group│  594│   505│
1736 ╰─────────┴─────┴──────╯
1737
1738       Custom Tables
1739 26 to 35
1740 ╭─────────┬────────────╮
1741 │         │S3a. GENDER:│
1742 │         ├─────┬──────┤
1743 │         │ Male│Female│
1744 │         ├─────┼──────┤
1745 │         │Count│ Count│
1746 ├─────────┼─────┼──────┤
1747 │Age group│  476│   491│
1748 ╰─────────┴─────┴──────╯
1749
1750       Custom Tables
1751 36 to 45
1752 ╭─────────┬────────────╮
1753 │         │S3a. GENDER:│
1754 │         ├─────┬──────┤
1755 │         │ Male│Female│
1756 │         ├─────┼──────┤
1757 │         │Count│ Count│
1758 ├─────────┼─────┼──────┤
1759 │Age group│  489│   548│
1760 ╰─────────┴─────┴──────╯
1761
1762       Custom Tables
1763 46 to 55
1764 ╭─────────┬────────────╮
1765 │         │S3a. GENDER:│
1766 │         ├─────┬──────┤
1767 │         │ Male│Female│
1768 │         ├─────┼──────┤
1769 │         │Count│ Count│
1770 ├─────────┼─────┼──────┤
1771 │Age group│  526│   649│
1772 ╰─────────┴─────┴──────╯
1773
1774       Custom Tables
1775 56 to 65
1776 ╭─────────┬────────────╮
1777 │         │S3a. GENDER:│
1778 │         ├─────┬──────┤
1779 │         │ Male│Female│
1780 │         ├─────┼──────┤
1781 │         │Count│ Count│
1782 ├─────────┼─────┼──────┤
1783 │Age group│  516│   731│
1784 ╰─────────┴─────┴──────╯
1785
1786       Custom Tables
1787 66 or older
1788 ╭─────────┬────────────╮
1789 │         │S3a. GENDER:│
1790 │         ├─────┬──────┤
1791 │         │ Male│Female│
1792 │         ├─────┼──────┤
1793 │         │Count│ Count│
1794 ├─────────┼─────┼──────┤
1795 │Age group│  531│   943│
1796 ╰─────────┴─────┴──────╯
1797
1798              Custom Tables
1799 Male
1800 ╭───────────────────────┬────────────╮
1801 │                       │S3a. GENDER:│
1802 │                       ├────────────┤
1803 │                       │    Count   │
1804 ├───────────────────────┼────────────┤
1805 │Age group 15 or younger│           0│
1806 │          16 to 25     │         594│
1807 │          26 to 35     │         476│
1808 │          36 to 45     │         489│
1809 │          46 to 55     │         526│
1810 │          56 to 65     │         516│
1811 │          66 or older  │         531│
1812 ╰───────────────────────┴────────────╯
1813
1814              Custom Tables
1815 Female
1816 ╭───────────────────────┬────────────╮
1817 │                       │S3a. GENDER:│
1818 │                       ├────────────┤
1819 │                       │    Count   │
1820 ├───────────────────────┼────────────┤
1821 │Age group 15 or younger│           0│
1822 │          16 to 25     │         505│
1823 │          26 to 35     │         491│
1824 │          36 to 45     │         548│
1825 │          46 to 55     │         649│
1826 │          56 to 65     │         731│
1827 │          66 or older  │         943│
1828 ╰───────────────────────┴────────────╯
1829 ])
1830 AT_CLEANUP
1831
1832 AT_SETUP([CTABLES missing values])
1833 AT_DATA([ctables.sps],
1834 [[DATA LIST LIST NOTABLE/x y.
1835 BEGIN DATA.
1836 1 1
1837 1 2
1838 1 3
1839 1 4
1840 1 5
1841 1 .
1842 2 1
1843 2 2
1844 2 3
1845 2 4
1846 2 5
1847 2 .
1848 3 1
1849 3 2
1850 3 3
1851 3 4
1852 3 5
1853 3 .
1854 4 1
1855 4 2
1856 4 3
1857 4 4
1858 4 5
1859 4 .
1860 5 1
1861 5 2
1862 5 3
1863 5 4
1864 5 5
1865 5 .
1866 . 1
1867 . 2
1868 . 3
1869 . 4
1870 . 5
1871 . .
1872 END DATA.
1873 MISSING VALUES x (1, 2) y (2, 3).
1874 VARIABLE LEVEL ALL (NOMINAL).
1875
1876 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1877                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1878     /CATEGORIES VARIABLES=ALL TOTAL=YES.
1879 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1880                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1881     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
1882 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1883                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1884     /CATEGORIES VARIABLES=ALL TOTAL=YES
1885     /SLABELS POSITION=ROW.
1886 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1887                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1888     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
1889     /SLABELS POSITION=ROW.
1890 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1891                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1892     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
1893     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
1894     /SLABELS POSITION=ROW.
1895 ]])
1896 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1897                                Custom Tables
1898 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1899 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1900 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1901 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1902 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1903 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1904 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
1905 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1906 dnl Note that Column Total N % doesn't add up to 100 because missing
1907 dnl values are included in the total but not shown as a category and this
1908 dnl is expected behavior.
1909
1910                                Custom Tables
1911 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1912 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1913 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1914 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1915 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1916 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1917 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1918 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1919 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
1920 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1921 dnl Note that Column Total N % doesn't add up to 100 because system-missing
1922 dnl values are included in the total but not shown as a category and this
1923 dnl is expected behavior.
1924
1925                      Custom Tables
1926 ╭────────────────────────┬───────────────────────────╮
1927 │                        │             y             │
1928 │                        ├──────┬──────┬──────┬──────┤
1929 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
1930 ├────────────────────────┼──────┼──────┼──────┼──────┤
1931 │x 3.00  Count           │     1│     1│     1│     3│
1932 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1933 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1934 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1935 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1936 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1937 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1938 │        Valid N         │      │      │      │     3│
1939 │        Total N         │      │      │      │     6│
1940 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1941 │  4.00  Count           │     1│     1│     1│     3│
1942 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1943 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1944 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1945 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1946 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1947 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1948 │        Valid N         │      │      │      │     3│
1949 │        Total N         │      │      │      │     6│
1950 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1951 │  5.00  Count           │     1│     1│     1│     3│
1952 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1953 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1954 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1955 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1956 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1957 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1958 │        Valid N         │      │      │      │     3│
1959 │        Total N         │      │      │      │     6│
1960 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1961 │  Total Count           │     3│     3│     3│     9│
1962 │        Column %        │100.0%│100.0%│100.0%│     .│
1963 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
1964 │        Column Total N %│100.0%│100.0%│100.0%│     .│
1965 │        Row %           │     .│     .│     .│     .│
1966 │        Row Valid N %   │     .│     .│     .│     .│
1967 │        Row Total N %   │     .│     .│     .│     .│
1968 │        Valid N         │     3│     3│     3│     9│
1969 │        Total N         │     6│     6│     6│    36│
1970 ╰────────────────────────┴──────┴──────┴──────┴──────╯
1971
1972                             Custom Tables
1973 ╭────────────────────────┬─────────────────────────────────────────╮
1974 │                        │                    y                    │
1975 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
1976 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1977 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1978 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
1979 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1980 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1981 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1982 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1983 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1984 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1985 │        Valid N         │      │      │      │      │      │     0│
1986 │        Total N         │      │      │      │      │      │     6│
1987 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1988 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
1989 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1990 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1991 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1992 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1993 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1994 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1995 │        Valid N         │      │      │      │      │      │     0│
1996 │        Total N         │      │      │      │      │      │     6│
1997 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1998 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
1999 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2000 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2001 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2002 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2003 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2004 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2005 │        Valid N         │      │      │      │      │      │     3│
2006 │        Total N         │      │      │      │      │      │     6│
2007 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2008 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
2009 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2010 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2011 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2012 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2013 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2014 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2015 │        Valid N         │      │      │      │      │      │     3│
2016 │        Total N         │      │      │      │      │      │     6│
2017 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2018 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
2019 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2020 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2021 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2022 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2023 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2024 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2025 │        Valid N         │      │      │      │      │      │     3│
2026 │        Total N         │      │      │      │      │      │     6│
2027 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2028 │  Total Count           │     5│     5│     5│     5│     5│    25│
2029 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2030 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
2031 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2032 │        Row %           │     .│     .│     .│     .│     .│     .│
2033 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2034 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
2035 │        Valid N         │     3│     0│     0│     3│     3│     9│
2036 │        Total N         │     6│     6│     6│     6│     6│    36│
2037 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
2038
2039                         Custom Tables
2040 ╭────────────────────────┬──────────────────────────────────╮
2041 │                        │                 y                │
2042 │                        ├──────┬──────┬──────┬──────┬──────┤
2043 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
2044 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
2045 │x 1.00  Count           │     1│     1│     1│     1│     4│
2046 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2047 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2048 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2049 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2050 │        Row Valid N %   │     .│     .│     .│     .│     .│
2051 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2052 │        Valid N         │      │      │      │      │     0│
2053 │        Total N         │      │      │      │      │     6│
2054 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2055 │  2.00  Count           │     1│     1│     1│     1│     4│
2056 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2057 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2058 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2059 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2060 │        Row Valid N %   │     .│     .│     .│     .│     .│
2061 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2062 │        Valid N         │      │      │      │      │     0│
2063 │        Total N         │      │      │      │      │     6│
2064 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2065 │  3.00  Count           │     1│     1│     1│     1│     4│
2066 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2067 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2068 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2069 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2070 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2071 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2072 │        Valid N         │      │      │      │      │     3│
2073 │        Total N         │      │      │      │      │     6│
2074 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2075 │  4.00  Count           │     1│     1│     1│     1│     4│
2076 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2077 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2078 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2079 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2080 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2081 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2082 │        Valid N         │      │      │      │      │     3│
2083 │        Total N         │      │      │      │      │     6│
2084 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2085 │  Total Count           │     4│     4│     4│     4│    16│
2086 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
2087 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
2088 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
2089 │        Row %           │     .│     .│     .│     .│     .│
2090 │        Row Valid N %   │     .│     .│     .│     .│     .│
2091 │        Row Total N %   │     .│     .│     .│     .│     .│
2092 │        Valid N         │     2│     0│     2│     2│     6│
2093 │        Total N         │     5│     5│     5│     5│    30│
2094 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
2095 ])
2096 AT_CLEANUP
2097
2098 AT_SETUP([CTABLES SMISSING=LISTWISE])
2099 AT_KEYWORDS([SMISSING LISTWISE])
2100 AT_DATA([ctables.sps],
2101 [[DATA LIST LIST NOTABLE/x y z.
2102 BEGIN DATA.
2103 1  . 40
2104 1 10 50
2105 1 20 60
2106 1  .  .
2107 1 30  .
2108 END DATA.
2109 VARIABLE LEVEL x (NOMINAL).
2110
2111 CTABLES /TABLE (y + z) > x.
2112 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
2113
2114 * The following doesn't come out as listwise because the tables are
2115 separate, not linked by an > operator.
2116 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
2117 ]])
2118 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2119   Custom Tables
2120 ╭────────┬─────╮
2121 │        │ Mean│
2122 ├────────┼─────┤
2123 │y x 1.00│20.00│
2124 ├────────┼─────┤
2125 │z x 1.00│50.00│
2126 ╰────────┴─────╯
2127
2128   Custom Tables
2129 ╭────────┬─────╮
2130 │        │ Mean│
2131 ├────────┼─────┤
2132 │y x 1.00│15.00│
2133 ├────────┼─────┤
2134 │z x 1.00│55.00│
2135 ╰────────┴─────╯
2136
2137   Custom Tables
2138 ╭────────┬─────╮
2139 │        │ Mean│
2140 ├────────┼─────┤
2141 │y x 1.00│20.00│
2142 ├────────┼─────┤
2143 │z x 1.00│50.00│
2144 ╰────────┴─────╯
2145 ])
2146 AT_CLEANUP
2147
2148 AT_SETUP([CTABLES VLABELS])
2149 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2150 AT_DATA([ctables.sps],
2151 [[GET 'nhtsa.sav'.
2152 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=DEFAULT /TABLE qnd5a BY qns3a.
2153 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NAME    /TABLE qnd5a BY qns3a.
2154 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=LABEL   /TABLE qnd5a BY qns3a.
2155 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=BOTH    /TABLE qnd5a BY qns3a.
2156 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE    /TABLE qnd5a BY qns3a.
2157 ]])
2158 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2159                                  Custom Tables
2160 ╭────────────────────────────────────────────────────────────────┬────────────╮
2161 │                                                                │S3a. GENDER:│
2162 │                                                                ├─────┬──────┤
2163 │                                                                │ Male│Female│
2164 │                                                                ├─────┼──────┤
2165 │                                                                │Count│ Count│
2166 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2167 │D5a. What would you say is your primary    Cuban                │   13│     7│
2168 │ethnic background?                         Mexican              │  175│   136│
2169 │                                           Spanish              │   20│    28│
2170 │                                           South American       │   21│    13│
2171 │                                           Central American     │   27│    25│
2172 │                                           Puerto Rican, OR     │   37│    41│
2173 │                                           Something else       │   35│    33│
2174 │                                           Multiple - cannot    │    2│     5│
2175 │                                           choose one           │     │      │
2176 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2177
2178                   Custom Tables
2179 ╭──────────────────────────────────┬────────────╮
2180 │                                  │    QNS3A   │
2181 │                                  ├─────┬──────┤
2182 │                                  │ Male│Female│
2183 │                                  ├─────┼──────┤
2184 │                                  │Count│ Count│
2185 ├──────────────────────────────────┼─────┼──────┤
2186 │QND5A Cuban                       │   13│     7│
2187 │      Mexican                     │  175│   136│
2188 │      Spanish                     │   20│    28│
2189 │      South American              │   21│    13│
2190 │      Central American            │   27│    25│
2191 │      Puerto Rican, OR            │   37│    41│
2192 │      Something else              │   35│    33│
2193 │      Multiple - cannot choose one│    2│     5│
2194 ╰──────────────────────────────────┴─────┴──────╯
2195
2196                                  Custom Tables
2197 ╭────────────────────────────────────────────────────────────────┬────────────╮
2198 │                                                                │S3a. GENDER:│
2199 │                                                                ├─────┬──────┤
2200 │                                                                │ Male│Female│
2201 │                                                                ├─────┼──────┤
2202 │                                                                │Count│ Count│
2203 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2204 │D5a. What would you say is your primary    Cuban                │   13│     7│
2205 │ethnic background?                         Mexican              │  175│   136│
2206 │                                           Spanish              │   20│    28│
2207 │                                           South American       │   21│    13│
2208 │                                           Central American     │   27│    25│
2209 │                                           Puerto Rican, OR     │   37│    41│
2210 │                                           Something else       │   35│    33│
2211 │                                           Multiple - cannot    │    2│     5│
2212 │                                           choose one           │     │      │
2213 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2214
2215                                  Custom Tables
2216 ╭────────────────────────────────────────────────────────────┬────────────────╮
2217 │                                                            │   QNS3A S3a.   │
2218 │                                                            │     GENDER:    │
2219 │                                                            ├───────┬────────┤
2220 │                                                            │  Male │ Female │
2221 │                                                            ├───────┼────────┤
2222 │                                                            │ Count │  Count │
2223 ├────────────────────────────────────────────────────────────┼───────┼────────┤
2224 │QND5A D5a. What would you say is your    Cuban              │     13│       7│
2225 │primary ethnic background?               Mexican            │    175│     136│
2226 │                                         Spanish            │     20│      28│
2227 │                                         South American     │     21│      13│
2228 │                                         Central American   │     27│      25│
2229 │                                         Puerto Rican, OR   │     37│      41│
2230 │                                         Something else     │     35│      33│
2231 │                                         Multiple - cannot  │      2│       5│
2232 │                                         choose one         │       │        │
2233 ╰────────────────────────────────────────────────────────────┴───────┴────────╯
2234
2235                Custom Tables
2236 ╭────────────────────────────┬─────┬──────╮
2237 │                            │ Male│Female│
2238 │                            ├─────┼──────┤
2239 │                            │Count│ Count│
2240 ├────────────────────────────┼─────┼──────┤
2241 │Cuban                       │   13│     7│
2242 │Mexican                     │  175│   136│
2243 │Spanish                     │   20│    28│
2244 │South American              │   21│    13│
2245 │Central American            │   27│    25│
2246 │Puerto Rican, OR            │   37│    41│
2247 │Something else              │   35│    33│
2248 │Multiple - cannot choose one│    2│     5│
2249 ╰────────────────────────────┴─────┴──────╯
2250 ])
2251 AT_CLEANUP
2252
2253 AT_SETUP([CTABLES FORMAT EMPTY])
2254 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2255 AT_DATA([ctables.sps],
2256 [[GET 'nhtsa.sav'.
2257 CTABLES /FORMAT EMPTY=ZERO /TABLE qnd5a BY qnd5.
2258 CTABLES /FORMAT EMPTY=BLANK /TABLE qnd5a BY qnd5.
2259 CTABLES /FORMAT EMPTY='n/a' /TABLE qnd5a BY qnd5.
2260 ]])
2261 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2262                                  Custom Tables
2263 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2264 │                                             │   D5. ETHNICITY: Are you of   │
2265 │                                             │  Hispanic or Latino origin or │
2266 │                                             │            descent?           │
2267 │                                             ├───────────────┬───────────────┤
2268 │                                             │      Yes      │       No      │
2269 │                                             ├───────────────┼───────────────┤
2270 │                                             │     Count     │     Count     │
2271 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2272 │D5a. What would you say is   Cuban           │             20│              0│
2273 │your primary ethnic          Mexican         │            311│              0│
2274 │background?                  Spanish         │             48│              0│
2275 │                             South American  │             34│              0│
2276 │                             Central American│             52│              0│
2277 │                             Puerto Rican, OR│             78│              0│
2278 │                             Something else  │             68│              0│
2279 │                             Multiple -      │              7│              0│
2280 │                             cannot choose   │               │               │
2281 │                             one             │               │               │
2282 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2283
2284                                  Custom Tables
2285 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2286 │                                             │   D5. ETHNICITY: Are you of   │
2287 │                                             │  Hispanic or Latino origin or │
2288 │                                             │            descent?           │
2289 │                                             ├───────────────┬───────────────┤
2290 │                                             │      Yes      │       No      │
2291 │                                             ├───────────────┼───────────────┤
2292 │                                             │     Count     │     Count     │
2293 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2294 │D5a. What would you say is   Cuban           │             20│               │
2295 │your primary ethnic          Mexican         │            311│               │
2296 │background?                  Spanish         │             48│               │
2297 │                             South American  │             34│               │
2298 │                             Central American│             52│               │
2299 │                             Puerto Rican, OR│             78│               │
2300 │                             Something else  │             68│               │
2301 │                             Multiple -      │              7│               │
2302 │                             cannot choose   │               │               │
2303 │                             one             │               │               │
2304 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2305
2306                                  Custom Tables
2307 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2308 │                                             │   D5. ETHNICITY: Are you of   │
2309 │                                             │  Hispanic or Latino origin or │
2310 │                                             │            descent?           │
2311 │                                             ├───────────────┬───────────────┤
2312 │                                             │      Yes      │       No      │
2313 │                                             ├───────────────┼───────────────┤
2314 │                                             │     Count     │     Count     │
2315 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2316 │D5a. What would you say is   Cuban           │             20│n/a            │
2317 │your primary ethnic          Mexican         │            311│n/a            │
2318 │background?                  Spanish         │             48│n/a            │
2319 │                             South American  │             34│n/a            │
2320 │                             Central American│             52│n/a            │
2321 │                             Puerto Rican, OR│             78│n/a            │
2322 │                             Something else  │             68│n/a            │
2323 │                             Multiple -      │              7│n/a            │
2324 │                             cannot choose   │               │               │
2325 │                             one             │               │               │
2326 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2327 ])
2328 AT_CLEANUP
2329
2330 AT_SETUP([CTABLES FORMAT MISSING])
2331 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2332 AT_DATA([ctables.sps],
2333 [[GET 'nhtsa.sav'.
2334 CTABLES /FORMAT MISSING='(no data)' /TABLE qnd5a[COLPCT] BY qnd5.
2335 ]])
2336 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2337                                  Custom Tables
2338 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2339 │                                             │   D5. ETHNICITY: Are you of   │
2340 │                                             │  Hispanic or Latino origin or │
2341 │                                             │            descent?           │
2342 │                                             ├───────────────┬───────────────┤
2343 │                                             │      Yes      │       No      │
2344 │                                             ├───────────────┼───────────────┤
2345 │                                             │    Column %   │    Column %   │
2346 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2347 │D5a. What would you say is   Cuban           │           3.2%│(no data)      │
2348 │your primary ethnic          Mexican         │          50.3%│(no data)      │
2349 │background?                  Spanish         │           7.8%│(no data)      │
2350 │                             South American  │           5.5%│(no data)      │
2351 │                             Central American│           8.4%│(no data)      │
2352 │                             Puerto Rican, OR│          12.6%│(no data)      │
2353 │                             Something else  │          11.0%│(no data)      │
2354 │                             Multiple -      │           1.1%│(no data)      │
2355 │                             cannot choose   │               │               │
2356 │                             one             │               │               │
2357 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2358 ])
2359 AT_CLEANUP
2360
2361 AT_SETUP([CTABLES HIDESMALLCOUNTS])
2362 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2363 AT_DATA([ctables.sps],
2364 [[GET 'nhtsa.sav'.
2365 CTABLES /TABLE qn38[c][COUNT, COLPCT].
2366 CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
2367 CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
2368 ]])
2369 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2370                                  Custom Tables
2371 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2372 │                                                              │Count│Column %│
2373 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2374 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2375 │occasion?                                        1            │  491│   34.9%│
2376 │                                                 2            │  462│   32.9%│
2377 │                                                 3            │  229│   16.3%│
2378 │                                                 4            │   82│    5.8%│
2379 │                                                 5            │   56│    4.0%│
2380 │                                                 6            │   32│    2.3%│
2381 │                                                 7            │    9│     .6%│
2382 │                                                 8            │    8│     .6%│
2383 │                                                 9            │    4│     .3%│
2384 │                                                 10           │    6│     .4%│
2385 │                                                 11           │    2│     .1%│
2386 │                                                 12           │    5│     .4%│
2387 │                                                 14           │    1│     .1%│
2388 │                                                 15           │    1│     .1%│
2389 │                                                 18           │    1│     .1%│
2390 │                                                 20           │    4│     .3%│
2391 │                                                 25           │    1│     .1%│
2392 │                                                 30           │    3│     .2%│
2393 │                                                 60           │    1│     .1%│
2394 │                                                 99+          │    0│     .0%│
2395 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2396
2397                                  Custom Tables
2398 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2399 │                                                              │Count│Column %│
2400 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2401 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2402 │occasion?                                        1            │  491│   34.9%│
2403 │                                                 2            │  462│   32.9%│
2404 │                                                 3            │  229│   16.3%│
2405 │                                                 4            │   82│    5.8%│
2406 │                                                 5            │   56│    4.0%│
2407 │                                                 6            │   32│    2.3%│
2408 │                                                 7            │    9│     .6%│
2409 │                                                 8            │    8│     .6%│
2410 │                                                 9            │<5   │     .3%│
2411 │                                                 10           │    6│     .4%│
2412 │                                                 11           │<5   │     .1%│
2413 │                                                 12           │    5│     .4%│
2414 │                                                 14           │<5   │     .1%│
2415 │                                                 15           │<5   │     .1%│
2416 │                                                 18           │<5   │     .1%│
2417 │                                                 20           │<5   │     .3%│
2418 │                                                 25           │<5   │     .1%│
2419 │                                                 30           │<5   │     .2%│
2420 │                                                 60           │<5   │     .1%│
2421 │                                                 99+          │<5   │     .0%│
2422 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2423
2424                                  Custom Tables
2425 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2426 │                                                              │Count│Column %│
2427 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2428 │38. How many drinks did you have on that         Less than one│<10  │     .5%│
2429 │occasion?                                        1            │  491│   34.9%│
2430 │                                                 2            │  462│   32.9%│
2431 │                                                 3            │  229│   16.3%│
2432 │                                                 4            │   82│    5.8%│
2433 │                                                 5            │   56│    4.0%│
2434 │                                                 6            │   32│    2.3%│
2435 │                                                 7            │<10  │     .6%│
2436 │                                                 8            │<10  │     .6%│
2437 │                                                 9            │<10  │     .3%│
2438 │                                                 10           │<10  │     .4%│
2439 │                                                 11           │<10  │     .1%│
2440 │                                                 12           │<10  │     .4%│
2441 │                                                 14           │<10  │     .1%│
2442 │                                                 15           │<10  │     .1%│
2443 │                                                 18           │<10  │     .1%│
2444 │                                                 20           │<10  │     .3%│
2445 │                                                 25           │<10  │     .1%│
2446 │                                                 30           │<10  │     .2%│
2447 │                                                 60           │<10  │     .1%│
2448 │                                                 99+          │<10  │     .0%│
2449 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2450 ])
2451 AT_CLEANUP
2452
2453 AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
2454 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2455 AT_DATA([ctables.sps],
2456 [[GET 'nhtsa.sav'.
2457 CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
2458 ]])
2459 AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
2460  Custom Tables
2461 ╭────────────╮
2462 │S3a. GENDER:│
2463 ├─────┬──────┤
2464 │ Male│Female│
2465 ├─────┼──────┤
2466 │Count│ Count│
2467 ├─────┼──────┤
2468 │ 3132│  3867│
2469 ╰─────┴──────╯
2470 ])
2471 AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
2472 AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
2473 maximumColumnWidth="192"
2474 minimumColumnWidth="96"
2475 ])
2476 AT_CLEANUP
2477
2478 AT_SETUP([CTABLES special formats])
2479 AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
2480 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2481 AT_DATA([ctables.sps],
2482 [[GET 'nhtsa.sav'.
2483 COMPUTE x = qnd3 - 4.
2484 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].
2485 ]])
2486 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2487                            Custom Tables
2488 ╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
2489 │ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
2490 ├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
2491 │x│(3.0)  │N=-3.0 │(-3.0) │(-3.0%)│8.0    │N=8.0  │(8.0)  │(8.0%) │
2492 ╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
2493 ])
2494 AT_CLEANUP