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