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