titles
[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.16-23.20: note: CTABLES: This variable on the rows axis has a
652 summary.
653    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
654       |                ^~~~~
655
656 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
657 summary.
658    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
659       |                                 ^~~~~
660
661 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
662 summary.
663    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
664       |                                                  ^~~~~
665 ]])
666 AT_CLEANUP
667
668 AT_SETUP([CTABLES one categorical variable])
669 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
670 AT_DATA([ctables.sps],
671 [[GET 'nhtsa.sav'.
672 CTABLES /TABLE qn1.
673 CTABLES /TABLE BY qn1.
674 CTABLES /TABLE BY BY qn1.
675 ]])
676 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
677                                   Custom Tables
678 ╭────────────────────────────────────────────────────────────────────────┬─────╮
679 │                                                                        │Count│
680 ├────────────────────────────────────────────────────────────────────────┼─────┤
681 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
682 │motor vehicle?                                     Several days a week  │ 1274│
683 │                                                   Once a week or less  │  361│
684 │                                                   Only certain times a │  130│
685 │                                                   year                 │     │
686 │                                                   Never                │  540│
687 ╰────────────────────────────────────────────────────────────────────────┴─────╯
688
689                                   Custom Tables
690 ╭──────────────────────────────────────────────────────────────────────────────╮
691 │        1. How often do you usually drive a car or other motor vehicle?       │
692 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
693 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
694 │Every day│       week       │       less       │          year          │Never│
695 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
696 │  Count  │       Count      │       Count      │          Count         │Count│
697 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
698 │     4667│              1274│               361│                     130│  540│
699 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
700
701 Custom Tables
702 Every day
703 ╭─────╮
704 │Count│
705 ├─────┤
706 │ 4667│
707 ╰─────╯
708 ])
709 AT_CLEANUP
710
711 AT_SETUP([CTABLES one string variable])
712 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
713 AT_DATA([ctables.sps],
714 [[GET 'nhtsa.sav'.
715 STRING licensed(A8).
716 MISSING VALUES licensed('DontKnow', 'Refused').
717 RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
718 CTABLES /TABLE licensed.
719 CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
720 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
721 * Notice that the string matching is case-sensitive.
722 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
723 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
724 CTABLES
725     /PCOMPUTE &notyes=EXPR(['No']+['DontKnow']+['Refused'])
726     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
727     /TABLE licensed
728     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'No', 'DontKnow', 'Refused'].
729 CTABLES
730     /PCOMPUTE &notyes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
731     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
732     /TABLE licensed
733     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'DontKnow' THRU 'No', 'Refused'].
734 ]])
735 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
736     Custom Tables
737 ╭────────────┬─────╮
738 │            │Count│
739 ├────────────┼─────┤
740 │licensed No │  572│
741 │         Yes│ 6379│
742 ╰────────────┴─────╯
743
744           Custom Tables
745 ╭─────────────────┬─────┬───────╮
746 │                 │Count│Valid N│
747 ├─────────────────┼─────┼───────┤
748 │licensed DontKnow│    4│       │
749 │         No      │  572│       │
750 │         Refused │   44│       │
751 │         Yes     │ 6379│       │
752 │         Total   │ 6999│   6951│
753 ╰─────────────────┴─────┴───────╯
754
755      Custom Tables
756 ╭──────────────┬─────╮
757 │              │Count│
758 ├──────────────┼─────┤
759 │licensed Yes  │ 6379│
760 │         No   │  572│
761 │         Total│ 6951│
762 ╰──────────────┴─────╯
763
764      Custom Tables
765 ╭──────────────┬─────╮
766 │              │Count│
767 ├──────────────┼─────┤
768 │licensed Yes  │ 6379│
769 │         no   │    0│
770 │         Total│ 6379│
771 ╰──────────────┴─────╯
772
773       Custom Tables
774 ╭────────────────┬─────╮
775 │                │Count│
776 ├────────────────┼─────┤
777 │licensed No     │  572│
778 │         Refused│   44│
779 │         Yes    │ 6379│
780 │         Total  │ 6995│
781 ╰────────────────┴─────╯
782
783       Custom Tables
784 ╭────────────────┬─────╮
785 │                │Count│
786 ├────────────────┼─────┤
787 │licensed Yes    │ 6379│
788 │         Not Yes│  620│
789 ╰────────────────┴─────╯
790
791       Custom Tables
792 ╭────────────────┬─────╮
793 │                │Count│
794 ├────────────────┼─────┤
795 │licensed Yes    │ 6379│
796 │         Not Yes│  620│
797 ╰────────────────┴─────╯
798 ])
799 AT_CLEANUP
800
801 AT_SETUP([CTABLES one scale variable])
802 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
803 AT_DATA([ctables.sps],
804 [[GET 'nhtsa.sav'.
805 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
806 CTABLES /TABLE BY qnd1.
807 CTABLES /TABLE BY BY qnd1.
808 ]])
809 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
810                                   Custom Tables
811 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
812 │                      │     │       │       │    │     Std    │       │       │
813 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
814 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
815 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
816 │age?                  │     │       │       │    │            │       │       │
817 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
818
819         Custom Tables
820 ╭──────────────────────────╮
821 │D1. AGE: What is your age?│
822 ├──────────────────────────┤
823 │           Mean           │
824 ├──────────────────────────┤
825 │                        48│
826 ╰──────────────────────────╯
827
828 Custom Tables
829 D1. AGE: What is your age?
830 ╭────╮
831 │Mean│
832 ├────┤
833 │  48│
834 ╰────╯
835 ])
836 AT_CLEANUP
837
838 AT_SETUP([CTABLES simple stacking])
839 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
840 AT_DATA([ctables.sps],
841 [[GET 'nhtsa.sav'.
842 CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
843 ]])
844 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
845                                   Custom Tables
846 ╭───────────────────────────────────────────────────────────────┬──────────────╮
847 │                                                               │ S3a. GENDER: │
848 │                                                               ├──────┬───────┤
849 │                                                               │ Male │ Female│
850 │                                                               ├──────┼───────┤
851 │                                                               │Column│ Column│
852 │                                                               │   %  │   %   │
853 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
854 │105b. How likely is it that drivers who have had   Almost      │   10%│    11%│
855 │too much to drink to drive safely will A. Get      certain     │      │       │
856 │stopped by the police?                             Very likely │   21%│    22%│
857 │                                                   Somewhat    │   38%│    42%│
858 │                                                   likely      │      │       │
859 │                                                   Somewhat    │   21%│    18%│
860 │                                                   unlikely    │      │       │
861 │                                                   Very        │   10%│     8%│
862 │                                                   unlikely    │      │       │
863 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
864 │105b. How likely is it that drivers who have had   Almost      │   14%│    18%│
865 │too much to drink to drive safely will B. Have an  certain     │      │       │
866 │accident?                                          Very likely │   36%│    45%│
867 │                                                   Somewhat    │   39%│    32%│
868 │                                                   likely      │      │       │
869 │                                                   Somewhat    │    9%│     4%│
870 │                                                   unlikely    │      │       │
871 │                                                   Very        │    3%│     2%│
872 │                                                   unlikely    │      │       │
873 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
874 │105b. How likely is it that drivers who have had   Almost      │   18%│    16%│
875 │too much to drink to drive safely will C. Be       certain     │      │       │
876 │convicted for drunk driving?                       Very likely │   32%│    28%│
877 │                                                   Somewhat    │   27%│    32%│
878 │                                                   likely      │      │       │
879 │                                                   Somewhat    │   15%│    15%│
880 │                                                   unlikely    │      │       │
881 │                                                   Very        │    9%│     9%│
882 │                                                   unlikely    │      │       │
883 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
884 │105b. How likely is it that drivers who have had   Almost      │   16%│    16%│
885 │too much to drink to drive safely will D. Be       certain     │      │       │
886 │arrested for drunk driving?                        Very likely │   26%│    27%│
887 │                                                   Somewhat    │   32%│    35%│
888 │                                                   likely      │      │       │
889 │                                                   Somewhat    │   17%│    15%│
890 │                                                   unlikely    │      │       │
891 │                                                   Very        │    9%│     7%│
892 │                                                   unlikely    │      │       │
893 ╰───────────────────────────────────────────────────────────────┴──────┴───────╯
894 ])
895 AT_CLEANUP
896
897 AT_SETUP([CTABLES show or hide empty categories])
898 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
899 AT_DATA([ctables.sps],
900 [[GET 'nhtsa.sav'.
901 IF (qn105ba = 2) qn105ba = 1.
902 IF (qns3a = 1) qns3a = 2.
903 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
904 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
905     /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
906 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
907     /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
908 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
909     /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
910 ]])
911 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
912                                   Custom Tables
913 ╭──────────────────────────────────────────────────────────────┬───────────────╮
914 │                                                              │  S3a. GENDER: │
915 │                                                              ├───────┬───────┤
916 │                                                              │  Male │ Female│
917 │                                                              ├───────┼───────┤
918 │                                                              │ Column│ Column│
919 │                                                              │   %   │   %   │
920 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
921 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
922 │too much to drink to drive safely will A. Get      certain    │       │       │
923 │stopped by the police?                             Very likely│      .│     0%│
924 │                                                   Somewhat   │      .│    40%│
925 │                                                   likely     │       │       │
926 │                                                   Somewhat   │      .│    19%│
927 │                                                   unlikely   │       │       │
928 │                                                   Very       │      .│     9%│
929 │                                                   unlikely   │       │       │
930 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
931
932                                   Custom Tables
933 ╭──────────────────────────────────────────────────────────────┬───────────────╮
934 │                                                              │  S3a. GENDER: │
935 │                                                              ├───────┬───────┤
936 │                                                              │  Male │ Female│
937 │                                                              ├───────┼───────┤
938 │                                                              │ Column│ Column│
939 │                                                              │   %   │   %   │
940 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
941 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
942 │too much to drink to drive safely will A. Get      certain    │       │       │
943 │stopped by the police?                             Somewhat   │      .│    40%│
944 │                                                   likely     │       │       │
945 │                                                   Somewhat   │      .│    19%│
946 │                                                   unlikely   │       │       │
947 │                                                   Very       │      .│     9%│
948 │                                                   unlikely   │       │       │
949 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
950
951                                   Custom Tables
952 ╭────────────────────────────────────────────────────────────────────┬─────────╮
953 │                                                                    │   S3a.  │
954 │                                                                    │ GENDER: │
955 │                                                                    ├─────────┤
956 │                                                                    │  Female │
957 │                                                                    ├─────────┤
958 │                                                                    │ Column %│
959 ├────────────────────────────────────────────────────────────────────┼─────────┤
960 │105b. How likely is it that drivers who have had too    Almost      │      32%│
961 │much to drink to drive safely will A. Get stopped by    certain     │         │
962 │the police?                                             Very likely │       0%│
963 │                                                        Somewhat    │      40%│
964 │                                                        likely      │         │
965 │                                                        Somewhat    │      19%│
966 │                                                        unlikely    │         │
967 │                                                        Very        │       9%│
968 │                                                        unlikely    │         │
969 ╰────────────────────────────────────────────────────────────────────┴─────────╯
970
971                                   Custom Tables
972 ╭────────────────────────────────────────────────────────────────────┬─────────╮
973 │                                                                    │   S3a.  │
974 │                                                                    │ GENDER: │
975 │                                                                    ├─────────┤
976 │                                                                    │  Female │
977 │                                                                    ├─────────┤
978 │                                                                    │ Column %│
979 ├────────────────────────────────────────────────────────────────────┼─────────┤
980 │105b. How likely is it that drivers who have had too    Almost      │      32%│
981 │much to drink to drive safely will A. Get stopped by    certain     │         │
982 │the police?                                             Somewhat    │      40%│
983 │                                                        likely      │         │
984 │                                                        Somewhat    │      19%│
985 │                                                        unlikely    │         │
986 │                                                        Very        │       9%│
987 │                                                        unlikely    │         │
988 ╰────────────────────────────────────────────────────────────────────┴─────────╯
989 ])
990 AT_CLEANUP
991
992 AT_SETUP([CTABLES sorting categories])
993 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
994 AT_DATA([ctables.sps],
995 [[GET 'nhtsa.sav'.
996 IF (QND5A=6) QND5A=-1.
997 IF (QND5A=5) QND5A=-2.
998 CTABLES /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=A
999         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=D
1000         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=A
1001         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=D.
1002 ]])
1003 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1004                                   Custom Tables
1005 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1006 │                                                                        │Count│
1007 ├────────────────────────────────────────────────────────────────────────┼─────┤
1008 │D5a. What would you say is your primary ethnic  -2.00                   │   52│
1009 │background?                                     -1.00                   │   78│
1010 │                                                Cuban                   │   20│
1011 │                                                Mexican                 │  311│
1012 │                                                Spanish                 │   48│
1013 │                                                South American          │   34│
1014 │                                                Central American        │    0│
1015 │                                                Puerto Rican, OR        │    0│
1016 │                                                Something else          │   68│
1017 │                                                Multiple - cannot choose│    7│
1018 │                                                one                     │     │
1019 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1020
1021                                   Custom Tables
1022 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1023 │                                                                        │Count│
1024 ├────────────────────────────────────────────────────────────────────────┼─────┤
1025 │D5a. What would you say is your primary ethnic  Multiple - cannot choose│    7│
1026 │background?                                     one                     │     │
1027 │                                                Something else          │   68│
1028 │                                                Puerto Rican, OR        │    0│
1029 │                                                Central American        │    0│
1030 │                                                South American          │   34│
1031 │                                                Spanish                 │   48│
1032 │                                                Mexican                 │  311│
1033 │                                                Cuban                   │   20│
1034 │                                                -1.00                   │   78│
1035 │                                                -2.00                   │   52│
1036 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1037
1038                                   Custom Tables
1039 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1040 │                                                                        │Count│
1041 ├────────────────────────────────────────────────────────────────────────┼─────┤
1042 │D5a. What would you say is your primary ethnic  Central American        │    0│
1043 │background?                                     Cuban                   │   20│
1044 │                                                Mexican                 │  311│
1045 │                                                Multiple - cannot choose│    7│
1046 │                                                one                     │     │
1047 │                                                Puerto Rican, OR        │    0│
1048 │                                                Something else          │   68│
1049 │                                                South American          │   34│
1050 │                                                Spanish                 │   48│
1051 │                                                -2.00                   │   52│
1052 │                                                -1.00                   │   78│
1053 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1054
1055                                   Custom Tables
1056 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1057 │                                                                        │Count│
1058 ├────────────────────────────────────────────────────────────────────────┼─────┤
1059 │D5a. What would you say is your primary ethnic  Spanish                 │   48│
1060 │background?                                     South American          │   34│
1061 │                                                Something else          │   68│
1062 │                                                Puerto Rican, OR        │    0│
1063 │                                                Multiple - cannot choose│    7│
1064 │                                                one                     │     │
1065 │                                                Mexican                 │  311│
1066 │                                                Cuban                   │   20│
1067 │                                                Central American        │    0│
1068 │                                                -1.00                   │   78│
1069 │                                                -2.00                   │   52│
1070 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1071 ])
1072 AT_CLEANUP
1073
1074 AT_SETUP([CTABLES simple nesting])
1075 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1076 AT_DATA([ctables.sps],
1077 [[GET 'nhtsa.sav'.
1078 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
1079   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
1080 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
1081   /CATEGORIES VARIABLES=qns3a TOTAL=YES
1082   /CLABELS ROW=OPPOSITE.
1083 ]])
1084 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1085                                   Custom Tables
1086 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
1087 │                                                                 │     │ Table│
1088 │                                                                 │Count│   %  │
1089 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1090 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
1091 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
1092 │drive safely will A. Get stopped by                        Total │  700│   10%│
1093 │the police?                           ╶──────────────────────────┼─────┼──────┤
1094 │                                       Very       S3a.     Male  │  660│   10%│
1095 │                                       likely     GENDER:  Female│  842│   12%│
1096 │                                                           Total │ 1502│   22%│
1097 │                                      ╶──────────────────────────┼─────┼──────┤
1098 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
1099 │                                       likely     GENDER:  Female│ 1589│   23%│
1100 │                                                           Total │ 2763│   40%│
1101 │                                      ╶──────────────────────────┼─────┼──────┤
1102 │                                       Somewhat   S3a.     Male  │  640│    9%│
1103 │                                       unlikely   GENDER:  Female│  667│   10%│
1104 │                                                           Total │ 1307│   19%│
1105 │                                      ╶──────────────────────────┼─────┼──────┤
1106 │                                       Very       S3a.     Male  │  311│    5%│
1107 │                                       unlikely   GENDER:  Female│  298│    4%│
1108 │                                                           Total │  609│    9%│
1109 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1110 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
1111 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
1112 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
1113 │                                      ╶──────────────────────────┼─────┼──────┤
1114 │                                       Very       S3a.     Male  │ 1104│   16%│
1115 │                                       likely     GENDER:  Female│ 1715│   25%│
1116 │                                                           Total │ 2819│   41%│
1117 │                                      ╶──────────────────────────┼─────┼──────┤
1118 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
1119 │                                       likely     GENDER:  Female│ 1214│   18%│
1120 │                                                           Total │ 2417│   35%│
1121 │                                      ╶──────────────────────────┼─────┼──────┤
1122 │                                       Somewhat   S3a.     Male  │  262│    4%│
1123 │                                       unlikely   GENDER:  Female│  168│    2%│
1124 │                                                           Total │  430│    6%│
1125 │                                      ╶──────────────────────────┼─────┼──────┤
1126 │                                       Very       S3a.     Male  │   81│    1%│
1127 │                                       unlikely   GENDER:  Female│   59│    1%│
1128 │                                                           Total │  140│    2%│
1129 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1130 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
1131 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
1132 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
1133 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1134 │                                       Very       S3a.     Male  │  988│   14%│
1135 │                                       likely     GENDER:  Female│ 1049│   15%│
1136 │                                                           Total │ 2037│   30%│
1137 │                                      ╶──────────────────────────┼─────┼──────┤
1138 │                                       Somewhat   S3a.     Male  │  822│   12%│
1139 │                                       likely     GENDER:  Female│ 1210│   18%│
1140 │                                                           Total │ 2032│   30%│
1141 │                                      ╶──────────────────────────┼─────┼──────┤
1142 │                                       Somewhat   S3a.     Male  │  446│    7%│
1143 │                                       unlikely   GENDER:  Female│  548│    8%│
1144 │                                                           Total │  994│   15%│
1145 │                                      ╶──────────────────────────┼─────┼──────┤
1146 │                                       Very       S3a.     Male  │  268│    4%│
1147 │                                       unlikely   GENDER:  Female│  354│    5%│
1148 │                                                           Total │  622│    9%│
1149 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1150 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
1151 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
1152 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
1153 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1154 │                                       Very       S3a.     Male  │  805│   12%│
1155 │                                       likely     GENDER:  Female│ 1029│   15%│
1156 │                                                           Total │ 1834│   27%│
1157 │                                      ╶──────────────────────────┼─────┼──────┤
1158 │                                       Somewhat   S3a.     Male  │  975│   14%│
1159 │                                       likely     GENDER:  Female│ 1332│   19%│
1160 │                                                           Total │ 2307│   34%│
1161 │                                      ╶──────────────────────────┼─────┼──────┤
1162 │                                       Somewhat   S3a.     Male  │  535│    8%│
1163 │                                       unlikely   GENDER:  Female│  560│    8%│
1164 │                                                           Total │ 1095│   16%│
1165 │                                      ╶──────────────────────────┼─────┼──────┤
1166 │                                       Very       S3a.     Male  │  270│    4%│
1167 │                                       unlikely   GENDER:  Female│  279│    4%│
1168 │                                                           Total │  549│    8%│
1169 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1170
1171                                   Custom Tables
1172 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
1173 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
1174 │                                 │ certain│likely│  likely │ unlikely│unlikely│
1175 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
1176 │                                 │        │ Table│         │         │        │
1177 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
1178 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1179 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
1180 │GENDER:        is it that drivers│        │      │         │         │        │
1181 │               who have had too  │        │      │         │         │        │
1182 │               much to drink to  │        │      │         │         │        │
1183 │               drive safely will │        │      │         │         │        │
1184 │               A. Get stopped by │        │      │         │         │        │
1185 │               the police?       │        │      │         │         │        │
1186 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1187 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
1188 │               is it that drivers│        │      │         │         │        │
1189 │               who have had too  │        │      │         │         │        │
1190 │               much to drink to  │        │      │         │         │        │
1191 │               drive safely will │        │      │         │         │        │
1192 │               A. Get stopped by │        │      │         │         │        │
1193 │               the police?       │        │      │         │         │        │
1194 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1195 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
1196 │               is it that drivers│        │      │         │         │        │
1197 │               who have had too  │        │      │         │         │        │
1198 │               much to drink to  │        │      │         │         │        │
1199 │               drive safely will │        │      │         │         │        │
1200 │               A. Get stopped by │        │      │         │         │        │
1201 │               the police?       │        │      │         │         │        │
1202 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1203 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
1204 │GENDER:        is it that drivers│        │      │         │         │        │
1205 │               who have had too  │        │      │         │         │        │
1206 │               much to drink to  │        │      │         │         │        │
1207 │               drive safely will │        │      │         │         │        │
1208 │               B. Have an        │        │      │         │         │        │
1209 │               accident?         │        │      │         │         │        │
1210 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1211 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
1212 │               is it that drivers│        │      │         │         │        │
1213 │               who have had too  │        │      │         │         │        │
1214 │               much to drink to  │        │      │         │         │        │
1215 │               drive safely will │        │      │         │         │        │
1216 │               B. Have an        │        │      │         │         │        │
1217 │               accident?         │        │      │         │         │        │
1218 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1219 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
1220 │               is it that drivers│        │      │         │         │        │
1221 │               who have had too  │        │      │         │         │        │
1222 │               much to drink to  │        │      │         │         │        │
1223 │               drive safely will │        │      │         │         │        │
1224 │               B. Have an        │        │      │         │         │        │
1225 │               accident?         │        │      │         │         │        │
1226 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1227 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
1228 │GENDER:        is it that drivers│        │      │         │         │        │
1229 │               who have had too  │        │      │         │         │        │
1230 │               much to drink to  │        │      │         │         │        │
1231 │               drive safely will │        │      │         │         │        │
1232 │               C. Be convicted   │        │      │         │         │        │
1233 │               for drunk driving?│        │      │         │         │        │
1234 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1235 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
1236 │               is it that drivers│        │      │         │         │        │
1237 │               who have had too  │        │      │         │         │        │
1238 │               much to drink to  │        │      │         │         │        │
1239 │               drive safely will │        │      │         │         │        │
1240 │               C. Be convicted   │        │      │         │         │        │
1241 │               for drunk driving?│        │      │         │         │        │
1242 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1243 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
1244 │               is it that drivers│        │      │         │         │        │
1245 │               who have had too  │        │      │         │         │        │
1246 │               much to drink to  │        │      │         │         │        │
1247 │               drive safely will │        │      │         │         │        │
1248 │               C. Be convicted   │        │      │         │         │        │
1249 │               for drunk driving?│        │      │         │         │        │
1250 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1251 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
1252 │GENDER:        is it that drivers│        │      │         │         │        │
1253 │               who have had too  │        │      │         │         │        │
1254 │               much to drink to  │        │      │         │         │        │
1255 │               drive safely will │        │      │         │         │        │
1256 │               D. Be arrested for│        │      │         │         │        │
1257 │               drunk driving?    │        │      │         │         │        │
1258 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1259 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
1260 │               is it that drivers│        │      │         │         │        │
1261 │               who have had too  │        │      │         │         │        │
1262 │               much to drink to  │        │      │         │         │        │
1263 │               drive safely will │        │      │         │         │        │
1264 │               D. Be arrested for│        │      │         │         │        │
1265 │               drunk driving?    │        │      │         │         │        │
1266 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1267 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
1268 │               is it that drivers│        │      │         │         │        │
1269 │               who have had too  │        │      │         │         │        │
1270 │               much to drink to  │        │      │         │         │        │
1271 │               drive safely will │        │      │         │         │        │
1272 │               D. Be arrested for│        │      │         │         │        │
1273 │               drunk driving?    │        │      │         │         │        │
1274 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
1275 ])
1276 AT_CLEANUP
1277
1278 AT_SETUP([CTABLES nesting and scale variables])
1279 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1280 AT_DATA([ctables.sps],
1281 [[GET 'nhtsa.sav'.
1282 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
1283 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
1284 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
1285   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
1286 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
1287 ]])
1288 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1289                                   Custom Tables
1290 ╭─────────────────────────────────────────────────────────────────┬────────────╮
1291 │                                                                 │S3a. GENDER:│
1292 │                                                                 ├─────┬──────┤
1293 │                                                                 │ Male│Female│
1294 │                                                                 ├─────┼──────┤
1295 │                                                                 │ Mean│ Mean │
1296 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1297 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
1298 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
1299 │                                                  week           │     │      │
1300 │                                                  Once a week or │   44│    54│
1301 │                                                  less           │     │      │
1302 │                                                  Only certain   │   34│    41│
1303 │                                                  times a year   │     │      │
1304 │                                                  Never          │   39│    55│
1305 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1306
1307                                   Custom Tables
1308 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
1309 │                                                         │Minimum│Maximum│Mean│
1310 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1311 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
1312 │What is  GENDER:         months, has there been a        │       │       │    │
1313 │your                     time when you felt you          │       │       │    │
1314 │age?                     should cut down on your      No │     16│     86│  46│
1315 │                         drinking?                       │       │       │    │
1316 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1317 │                  Female 26. During the last 12       Yes│     16│     86│  43│
1318 │                         months, has there been a        │       │       │    │
1319 │                         time when you felt you          │       │       │    │
1320 │                         should cut down on your      No │     16│     86│  48│
1321 │                         drinking?                       │       │       │    │
1322 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1323 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
1324 │What is  GENDER:         months, has there been a        │       │       │    │
1325 │your                     time when people criticized  No │     16│     86│  46│
1326 │age?                     your drinking?                  │       │       │    │
1327 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1328 │                  Female 27. During the last 12       Yes│     17│     69│  37│
1329 │                         months, has there been a        │       │       │    │
1330 │                         time when people criticized  No │     16│     86│  48│
1331 │                         your drinking?                  │       │       │    │
1332 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
1333
1334                                   Custom Tables
1335 ╭─────────────────────────────┬────────────────────────────────────────────────╮
1336 │                             │S1. Including yourself, how many members of this│
1337 │                             │         household are age 16 or older?         │
1338 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
1339 │                             │      │      │      │      │      │      │ 6 or │
1340 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
1341 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1342 │                             │Column│Column│Column│Column│Column│Column│Column│
1343 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
1344 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1345 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
1346 │SAMPLE      How      certain │      │      │      │      │      │      │      │
1347 │SOURCE:     likely           │      │      │      │      │      │      │      │
1348 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
1349 │            that     likely  │      │      │      │      │      │      │      │
1350 │            drivers          │      │      │      │      │      │      │      │
1351 │            who have         │      │      │      │      │      │      │      │
1352 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
1353 │            much to  likely  │      │      │      │      │      │      │      │
1354 │            drink to         │      │      │      │      │      │      │      │
1355 │            drive            │      │      │      │      │      │      │      │
1356 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
1357 │            will A.  unlikely│      │      │      │      │      │      │      │
1358 │            Get              │      │      │      │      │      │      │      │
1359 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
1360 │            by the   unlikely│      │      │      │      │      │      │      │
1361 │            police?          │      │      │      │      │      │      │      │
1362 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
1363
1364                                   Custom Tables
1365 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
1366 │                                                              │    │    Std   │
1367 │                                                              │Mean│ Deviation│
1368 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
1369 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
1370 │group           typical month did you have one or more        │    │          │
1371 │                alcoholic beverages to drink?                 │    │          │
1372 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1373 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
1374 │                typical month did you have one or more        │    │          │
1375 │                alcoholic beverages to drink?                 │    │          │
1376 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1377 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
1378 │                typical month did you have one or more        │    │          │
1379 │                alcoholic beverages to drink?                 │    │          │
1380 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1381 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
1382 │                typical month did you have one or more        │    │          │
1383 │                alcoholic beverages to drink?                 │    │          │
1384 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1385 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
1386 │                typical month did you have one or more        │    │          │
1387 │                alcoholic beverages to drink?                 │    │          │
1388 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1389 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
1390 │       older    typical month did you have one or more        │    │          │
1391 │                alcoholic beverages to drink?                 │    │          │
1392 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
1393 ])
1394 AT_CLEANUP
1395
1396
1397 AT_SETUP([CTABLES SLABELS])
1398 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1399 AT_DATA([ctables.sps],
1400 [[GET 'nhtsa.sav'.
1401 CTABLES /TABLE qn1 [COUNT COLPCT].
1402 CTABLES /TABLE qn1 [COUNT COLPCT]
1403     /SLABELS POSITION=ROW.
1404 CTABLES /TABLE qn1 [COUNT COLPCT]
1405     /SLABELS POSITION=ROW VISIBLE=NO.
1406 ]])
1407 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1408                                   Custom Tables
1409 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
1410 │                                                                │     │ Column│
1411 │                                                                │Count│   %   │
1412 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
1413 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
1414 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
1415 │                                             Once a week or less│  361│   5.2%│
1416 │                                             Only certain times │  130│   1.9%│
1417 │                                             a year             │     │       │
1418 │                                             Never              │  540│   7.7%│
1419 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
1420
1421                                   Custom Tables
1422 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1423 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
1424 │other motor vehicle?                                             Column │66.9%│
1425 │                                                                 %      │     │
1426 │                                            ╶───────────────────────────┼─────┤
1427 │                                             Several days a week Count  │ 1274│
1428 │                                                                 Column │18.3%│
1429 │                                                                 %      │     │
1430 │                                            ╶───────────────────────────┼─────┤
1431 │                                             Once a week or less Count  │  361│
1432 │                                                                 Column │ 5.2%│
1433 │                                                                 %      │     │
1434 │                                            ╶───────────────────────────┼─────┤
1435 │                                             Only certain times  Count  │  130│
1436 │                                             a year              Column │ 1.9%│
1437 │                                                                 %      │     │
1438 │                                            ╶───────────────────────────┼─────┤
1439 │                                             Never               Count  │  540│
1440 │                                                                 Column │ 7.7%│
1441 │                                                                 %      │     │
1442 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1443
1444                                   Custom Tables
1445 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1446 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
1447 │motor vehicle?                                                          │66.9%│
1448 │                                                   Several days a week  │ 1274│
1449 │                                                                        │18.3%│
1450 │                                                   Once a week or less  │  361│
1451 │                                                                        │ 5.2%│
1452 │                                                   Only certain times a │  130│
1453 │                                                   year                 │ 1.9%│
1454 │                                                   Never                │  540│
1455 │                                                                        │ 7.7%│
1456 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1457 ])
1458 AT_CLEANUP
1459
1460 AT_SETUP([CTABLES simple totals])
1461 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1462 AT_DATA([ctables.sps],
1463 [[GET 'nhtsa.sav'.
1464 CTABLES /TABLE=qn17
1465     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
1466 DESCRIPTIVES qn18/STATISTICS=MEAN.
1467 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
1468     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
1469 ]])
1470 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1471                                   Custom Tables
1472 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1473 │                                                                        │Count│
1474 ├────────────────────────────────────────────────────────────────────────┼─────┤
1475 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
1476 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
1477 │                                                      Light beer        │  620│
1478 │                                                      Wine              │ 1418│
1479 │                                                      Wine coolers      │  137│
1480 │                                                      Hard liquor or    │  888│
1481 │                                                      mixed drinks      │     │
1482 │                                                      Flavored malt     │   83│
1483 │                                                      drinks            │     │
1484 │                                                      Number responding │ 4221│
1485 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1486
1487                              Descriptive Statistics
1488 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
1489 │                                                                    │  N │Mean│
1490 ├────────────────────────────────────────────────────────────────────┼────┼────┤
1491 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
1492 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
1493 │Valid N (listwise)                                                  │6999│    │
1494 │Missing N (listwise)                                                │2781│    │
1495 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
1496
1497                                   Custom Tables
1498 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
1499 │                                                      │    │     │ Valid│Total│
1500 │                                                      │Mean│Count│   N  │  N  │
1501 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1502 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
1503 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1504 │                you usually drink per sitting?        │    │     │      │     │
1505 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1506 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
1507 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1508 │                you usually drink per sitting?        │    │     │      │     │
1509 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1510 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
1511 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1512 │                you usually drink per sitting?        │    │     │      │     │
1513 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1514 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
1515 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1516 │                you usually drink per sitting?        │    │     │      │     │
1517 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1518 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
1519 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1520 │                you usually drink per sitting?        │    │     │      │     │
1521 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
1522 ])
1523 AT_CLEANUP
1524
1525 AT_SETUP([CTABLES subtotals])
1526 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1527 AT_DATA([ctables.sps],
1528 [[GET 'nhtsa.sav'.
1529 CTABLES /TABLE=qn105ba BY qns1
1530     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1531 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
1532     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
1533 CTABLES /TABLE=qn105ba BY qns1
1534     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
1535     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1536 ]])
1537 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1538                                                       Custom Tables
1539 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1540 │                                                         │ S1. Including yourself, how many members of this household │
1541 │                                                         │                    are age 16 or older?                    │
1542 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1543 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1544 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1545 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1546 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1547 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1548 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1549 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1550 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1551 │                                              likely     │       │       │         │       │        │      │          │
1552 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1553 │                                              unlikely   │       │       │         │       │        │      │          │
1554 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1555 │                                              unlikely   │       │       │         │       │        │      │          │
1556 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1557
1558                                                       Custom Tables
1559 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1560 │                                                        │  S1. Including yourself, how many members of this household │
1561 │                                                        │                     are age 16 or older?                    │
1562 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
1563 │                                                        │        │        │        │        │       │        │  6 or  │
1564 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
1565 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1566 │                                                        │        │        │        │        │ Column│        │        │
1567 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
1568 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1569 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
1570 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
1571 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
1572 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
1573 │                                             likely     │        │        │        │        │       │        │        │
1574 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
1575 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
1576 │                                             unlikely   │        │        │        │        │       │        │        │
1577 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
1578 │                                             unlikely   │        │        │        │        │       │        │        │
1579 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
1580 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
1581
1582                                                       Custom Tables
1583 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1584 │                                                         │ S1. Including yourself, how many members of this household │
1585 │                                                         │                    are age 16 or older?                    │
1586 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1587 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1588 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1589 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1590 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1591 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1592 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1593 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1594 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1595 │                                              likely     │       │       │         │       │        │      │          │
1596 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
1597 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1598 │                                              unlikely   │       │       │         │       │        │      │          │
1599 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1600 │                                              unlikely   │       │       │         │       │        │      │          │
1601 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
1602 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1603 ])
1604 AT_CLEANUP
1605
1606 AT_SETUP([CTABLES PCOMPUTE])
1607 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1608 AT_DATA([ctables.sps],
1609 [[GET 'nhtsa.sav'.
1610 CTABLES
1611     /PCOMPUTE &x=EXPR([3] + [4])
1612     /PCOMPUTE &y=EXPR([4] + [5])
1613     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
1614     /PPROPERTIES &y LABEL='4+5'
1615     /TABLE=qn105ba BY qns1
1616     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
1617 ]])
1618 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1619                                                       Custom Tables
1620 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1621 │                                                        │  S1. Including yourself, how many members of this household │
1622 │                                                        │                     are age 16 or older?                    │
1623 │                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
1624 │                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
1625 │                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1626 │                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
1627 ├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
1628 │105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
1629 │had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
1630 │A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
1631 │                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
1632 │                                             likely     │       │       │          │       │        │      │          │
1633 │                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
1634 │                                             unlikely   │       │       │          │       │        │      │          │
1635 │                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
1636 │                                             unlikely   │       │       │          │       │        │      │          │
1637 ╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
1638 ])
1639 AT_CLEANUP
1640
1641 AT_SETUP([CTABLES CLABELS])
1642 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1643 AT_DATA([ctables.sps],
1644 [[GET 'nhtsa.sav'.
1645 CTABLES /TABLE AgeGroup BY qns3a.
1646 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1647 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1648 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
1649 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
1650 ]])
1651 pwd
1652 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
1653              Custom Tables
1654 ╭───────────────────────┬────────────╮
1655 │                       │S3a. GENDER:│
1656 │                       ├─────┬──────┤
1657 │                       │ Male│Female│
1658 │                       ├─────┼──────┤
1659 │                       │Count│ Count│
1660 ├───────────────────────┼─────┼──────┤
1661 │Age group 15 or younger│    0│     0│
1662 │          16 to 25     │  594│   505│
1663 │          26 to 35     │  476│   491│
1664 │          36 to 45     │  489│   548│
1665 │          46 to 55     │  526│   649│
1666 │          56 to 65     │  516│   731│
1667 │          66 or older  │  531│   943│
1668 ╰───────────────────────┴─────┴──────╯
1669
1670                                                       Custom Tables
1671 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1672 │       │                                                 S3a. GENDER:                                                 │
1673 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
1674 │       │                         Male                         │                         Female                        │
1675 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
1676 │       │  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 │
1677 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
1678 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1679 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
1680 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1681 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
1682 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
1683 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
1684
1685                 Custom Tables
1686 ╭──────────────────────────────┬────────────╮
1687 │                              │S3a. GENDER:│
1688 │                              ├────────────┤
1689 │                              │    Count   │
1690 ├──────────────────────────────┼────────────┤
1691 │Age group 15 or younger Male  │           0│
1692 │                        Female│           0│
1693 │         ╶────────────────────┼────────────┤
1694 │          16 to 25      Male  │         594│
1695 │                        Female│         505│
1696 │         ╶────────────────────┼────────────┤
1697 │          26 to 35      Male  │         476│
1698 │                        Female│         491│
1699 │         ╶────────────────────┼────────────┤
1700 │          36 to 45      Male  │         489│
1701 │                        Female│         548│
1702 │         ╶────────────────────┼────────────┤
1703 │          46 to 55      Male  │         526│
1704 │                        Female│         649│
1705 │         ╶────────────────────┼────────────┤
1706 │          56 to 65      Male  │         516│
1707 │                        Female│         731│
1708 │         ╶────────────────────┼────────────┤
1709 │          66 or older   Male  │         531│
1710 │                        Female│         943│
1711 ╰──────────────────────────────┴────────────╯
1712
1713       Custom Tables
1714 15 or younger
1715 ╭─────────┬────────────╮
1716 │         │S3a. GENDER:│
1717 │         ├─────┬──────┤
1718 │         │ Male│Female│
1719 │         ├─────┼──────┤
1720 │         │Count│ Count│
1721 ├─────────┼─────┼──────┤
1722 │Age group│    0│     0│
1723 ╰─────────┴─────┴──────╯
1724
1725       Custom Tables
1726 16 to 25
1727 ╭─────────┬────────────╮
1728 │         │S3a. GENDER:│
1729 │         ├─────┬──────┤
1730 │         │ Male│Female│
1731 │         ├─────┼──────┤
1732 │         │Count│ Count│
1733 ├─────────┼─────┼──────┤
1734 │Age group│  594│   505│
1735 ╰─────────┴─────┴──────╯
1736
1737       Custom Tables
1738 26 to 35
1739 ╭─────────┬────────────╮
1740 │         │S3a. GENDER:│
1741 │         ├─────┬──────┤
1742 │         │ Male│Female│
1743 │         ├─────┼──────┤
1744 │         │Count│ Count│
1745 ├─────────┼─────┼──────┤
1746 │Age group│  476│   491│
1747 ╰─────────┴─────┴──────╯
1748
1749       Custom Tables
1750 36 to 45
1751 ╭─────────┬────────────╮
1752 │         │S3a. GENDER:│
1753 │         ├─────┬──────┤
1754 │         │ Male│Female│
1755 │         ├─────┼──────┤
1756 │         │Count│ Count│
1757 ├─────────┼─────┼──────┤
1758 │Age group│  489│   548│
1759 ╰─────────┴─────┴──────╯
1760
1761       Custom Tables
1762 46 to 55
1763 ╭─────────┬────────────╮
1764 │         │S3a. GENDER:│
1765 │         ├─────┬──────┤
1766 │         │ Male│Female│
1767 │         ├─────┼──────┤
1768 │         │Count│ Count│
1769 ├─────────┼─────┼──────┤
1770 │Age group│  526│   649│
1771 ╰─────────┴─────┴──────╯
1772
1773       Custom Tables
1774 56 to 65
1775 ╭─────────┬────────────╮
1776 │         │S3a. GENDER:│
1777 │         ├─────┬──────┤
1778 │         │ Male│Female│
1779 │         ├─────┼──────┤
1780 │         │Count│ Count│
1781 ├─────────┼─────┼──────┤
1782 │Age group│  516│   731│
1783 ╰─────────┴─────┴──────╯
1784
1785       Custom Tables
1786 66 or older
1787 ╭─────────┬────────────╮
1788 │         │S3a. GENDER:│
1789 │         ├─────┬──────┤
1790 │         │ Male│Female│
1791 │         ├─────┼──────┤
1792 │         │Count│ Count│
1793 ├─────────┼─────┼──────┤
1794 │Age group│  531│   943│
1795 ╰─────────┴─────┴──────╯
1796
1797              Custom Tables
1798 Male
1799 ╭───────────────────────┬────────────╮
1800 │                       │S3a. GENDER:│
1801 │                       ├────────────┤
1802 │                       │    Count   │
1803 ├───────────────────────┼────────────┤
1804 │Age group 15 or younger│           0│
1805 │          16 to 25     │         594│
1806 │          26 to 35     │         476│
1807 │          36 to 45     │         489│
1808 │          46 to 55     │         526│
1809 │          56 to 65     │         516│
1810 │          66 or older  │         531│
1811 ╰───────────────────────┴────────────╯
1812
1813              Custom Tables
1814 Female
1815 ╭───────────────────────┬────────────╮
1816 │                       │S3a. GENDER:│
1817 │                       ├────────────┤
1818 │                       │    Count   │
1819 ├───────────────────────┼────────────┤
1820 │Age group 15 or younger│           0│
1821 │          16 to 25     │         505│
1822 │          26 to 35     │         491│
1823 │          36 to 45     │         548│
1824 │          46 to 55     │         649│
1825 │          56 to 65     │         731│
1826 │          66 or older  │         943│
1827 ╰───────────────────────┴────────────╯
1828 ])
1829 AT_CLEANUP
1830
1831 AT_SETUP([CTABLES missing values])
1832 AT_DATA([ctables.sps],
1833 [[DATA LIST LIST NOTABLE/x y.
1834 BEGIN DATA.
1835 1 1
1836 1 2
1837 1 3
1838 1 4
1839 1 5
1840 1 .
1841 2 1
1842 2 2
1843 2 3
1844 2 4
1845 2 5
1846 2 .
1847 3 1
1848 3 2
1849 3 3
1850 3 4
1851 3 5
1852 3 .
1853 4 1
1854 4 2
1855 4 3
1856 4 4
1857 4 5
1858 4 .
1859 5 1
1860 5 2
1861 5 3
1862 5 4
1863 5 5
1864 5 .
1865 . 1
1866 . 2
1867 . 3
1868 . 4
1869 . 5
1870 . .
1871 END DATA.
1872 MISSING VALUES x (1, 2) y (2, 3).
1873 VARIABLE LEVEL ALL (NOMINAL).
1874
1875 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1876                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1877     /CATEGORIES VARIABLES=ALL TOTAL=YES.
1878 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
1879                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
1880     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
1881 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1882                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1883     /CATEGORIES VARIABLES=ALL TOTAL=YES
1884     /SLABELS POSITION=ROW.
1885 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1886                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1887     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
1888     /SLABELS POSITION=ROW.
1889 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
1890                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
1891     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
1892     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
1893     /SLABELS POSITION=ROW.
1894 ]])
1895 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1896                                Custom Tables
1897 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1898 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1899 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1900 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1901 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1902 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1903 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
1904 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1905 dnl Note that Column Total N % doesn't add up to 100 because missing
1906 dnl values are included in the total but not shown as a category and this
1907 dnl is expected behavior.
1908
1909                                Custom Tables
1910 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1911 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1912 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1913 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1914 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1915 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1916 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1917 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1918 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
1919 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1920 dnl Note that Column Total N % doesn't add up to 100 because system-missing
1921 dnl values are included in the total but not shown as a category and this
1922 dnl is expected behavior.
1923
1924                      Custom Tables
1925 ╭────────────────────────┬───────────────────────────╮
1926 │                        │             y             │
1927 │                        ├──────┬──────┬──────┬──────┤
1928 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
1929 ├────────────────────────┼──────┼──────┼──────┼──────┤
1930 │x 3.00  Count           │     1│     1│     1│     3│
1931 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1932 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1933 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1934 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1935 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1936 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1937 │        Valid N         │      │      │      │     3│
1938 │        Total N         │      │      │      │     6│
1939 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1940 │  4.00  Count           │     1│     1│     1│     3│
1941 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1942 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1943 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1944 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1945 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1946 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1947 │        Valid N         │      │      │      │     3│
1948 │        Total N         │      │      │      │     6│
1949 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1950 │  5.00  Count           │     1│     1│     1│     3│
1951 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1952 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1953 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1954 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1955 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1956 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1957 │        Valid N         │      │      │      │     3│
1958 │        Total N         │      │      │      │     6│
1959 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1960 │  Total Count           │     3│     3│     3│     9│
1961 │        Column %        │100.0%│100.0%│100.0%│     .│
1962 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
1963 │        Column Total N %│100.0%│100.0%│100.0%│     .│
1964 │        Row %           │     .│     .│     .│     .│
1965 │        Row Valid N %   │     .│     .│     .│     .│
1966 │        Row Total N %   │     .│     .│     .│     .│
1967 │        Valid N         │     3│     3│     3│     9│
1968 │        Total N         │     6│     6│     6│    36│
1969 ╰────────────────────────┴──────┴──────┴──────┴──────╯
1970
1971                             Custom Tables
1972 ╭────────────────────────┬─────────────────────────────────────────╮
1973 │                        │                    y                    │
1974 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
1975 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1976 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1977 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
1978 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1979 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1980 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1981 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1982 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1983 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1984 │        Valid N         │      │      │      │      │      │     0│
1985 │        Total N         │      │      │      │      │      │     6│
1986 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1987 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
1988 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1989 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1990 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1991 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1992 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1993 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1994 │        Valid N         │      │      │      │      │      │     0│
1995 │        Total N         │      │      │      │      │      │     6│
1996 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1997 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
1998 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1999 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2000 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2001 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2002 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2003 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2004 │        Valid N         │      │      │      │      │      │     3│
2005 │        Total N         │      │      │      │      │      │     6│
2006 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2007 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
2008 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2009 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2010 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2011 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2012 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2013 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2014 │        Valid N         │      │      │      │      │      │     3│
2015 │        Total N         │      │      │      │      │      │     6│
2016 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2017 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
2018 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2019 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2020 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2021 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2022 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2023 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2024 │        Valid N         │      │      │      │      │      │     3│
2025 │        Total N         │      │      │      │      │      │     6│
2026 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2027 │  Total Count           │     5│     5│     5│     5│     5│    25│
2028 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2029 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
2030 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2031 │        Row %           │     .│     .│     .│     .│     .│     .│
2032 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2033 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
2034 │        Valid N         │     3│     0│     0│     3│     3│     9│
2035 │        Total N         │     6│     6│     6│     6│     6│    36│
2036 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
2037
2038                         Custom Tables
2039 ╭────────────────────────┬──────────────────────────────────╮
2040 │                        │                 y                │
2041 │                        ├──────┬──────┬──────┬──────┬──────┤
2042 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
2043 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
2044 │x 1.00  Count           │     1│     1│     1│     1│     4│
2045 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2046 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2047 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2048 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2049 │        Row Valid N %   │     .│     .│     .│     .│     .│
2050 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2051 │        Valid N         │      │      │      │      │     0│
2052 │        Total N         │      │      │      │      │     6│
2053 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2054 │  2.00  Count           │     1│     1│     1│     1│     4│
2055 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2056 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2057 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2058 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2059 │        Row Valid N %   │     .│     .│     .│     .│     .│
2060 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2061 │        Valid N         │      │      │      │      │     0│
2062 │        Total N         │      │      │      │      │     6│
2063 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2064 │  3.00  Count           │     1│     1│     1│     1│     4│
2065 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2066 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2067 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2068 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2069 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2070 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2071 │        Valid N         │      │      │      │      │     3│
2072 │        Total N         │      │      │      │      │     6│
2073 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2074 │  4.00  Count           │     1│     1│     1│     1│     4│
2075 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2076 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2077 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2078 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2079 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2080 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2081 │        Valid N         │      │      │      │      │     3│
2082 │        Total N         │      │      │      │      │     6│
2083 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2084 │  Total Count           │     4│     4│     4│     4│    16│
2085 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
2086 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
2087 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
2088 │        Row %           │     .│     .│     .│     .│     .│
2089 │        Row Valid N %   │     .│     .│     .│     .│     .│
2090 │        Row Total N %   │     .│     .│     .│     .│     .│
2091 │        Valid N         │     2│     0│     2│     2│     6│
2092 │        Total N         │     5│     5│     5│     5│    30│
2093 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
2094 ])
2095 AT_CLEANUP
2096
2097 AT_SETUP([CTABLES SMISSING=LISTWISE])
2098 AT_KEYWORDS([SMISSING LISTWISE])
2099 AT_DATA([ctables.sps],
2100 [[DATA LIST LIST NOTABLE/x y z.
2101 BEGIN DATA.
2102 1  . 40
2103 1 10 50
2104 1 20 60
2105 1  .  .
2106 1 30  .
2107 END DATA.
2108 VARIABLE LEVEL x (NOMINAL).
2109
2110 CTABLES /TABLE (y + z) > x.
2111 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
2112
2113 * The following doesn't come out as listwise because the tables are
2114 separate, not linked by an > operator.
2115 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
2116 ]])
2117 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2118   Custom Tables
2119 ╭────────┬─────╮
2120 │        │ Mean│
2121 ├────────┼─────┤
2122 │y x 1.00│20.00│
2123 ├────────┼─────┤
2124 │z x 1.00│50.00│
2125 ╰────────┴─────╯
2126
2127   Custom Tables
2128 ╭────────┬─────╮
2129 │        │ Mean│
2130 ├────────┼─────┤
2131 │y x 1.00│15.00│
2132 ├────────┼─────┤
2133 │z x 1.00│55.00│
2134 ╰────────┴─────╯
2135
2136   Custom Tables
2137 ╭────────┬─────╮
2138 │        │ Mean│
2139 ├────────┼─────┤
2140 │y x 1.00│20.00│
2141 ├────────┼─────┤
2142 │z x 1.00│50.00│
2143 ╰────────┴─────╯
2144 ])
2145 AT_CLEANUP
2146
2147 AT_SETUP([CTABLES VLABELS])
2148 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2149 AT_DATA([ctables.sps],
2150 [[GET 'nhtsa.sav'.
2151 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=DEFAULT /TABLE qnd5a BY qns3a.
2152 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NAME    /TABLE qnd5a BY qns3a.
2153 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=LABEL   /TABLE qnd5a BY qns3a.
2154 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=BOTH    /TABLE qnd5a BY qns3a.
2155 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE    /TABLE qnd5a BY qns3a.
2156 ]])
2157 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2158                                  Custom Tables
2159 ╭────────────────────────────────────────────────────────────────┬────────────╮
2160 │                                                                │S3a. GENDER:│
2161 │                                                                ├─────┬──────┤
2162 │                                                                │ Male│Female│
2163 │                                                                ├─────┼──────┤
2164 │                                                                │Count│ Count│
2165 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2166 │D5a. What would you say is your primary    Cuban                │   13│     7│
2167 │ethnic background?                         Mexican              │  175│   136│
2168 │                                           Spanish              │   20│    28│
2169 │                                           South American       │   21│    13│
2170 │                                           Central American     │   27│    25│
2171 │                                           Puerto Rican, OR     │   37│    41│
2172 │                                           Something else       │   35│    33│
2173 │                                           Multiple - cannot    │    2│     5│
2174 │                                           choose one           │     │      │
2175 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2176
2177                   Custom Tables
2178 ╭──────────────────────────────────┬────────────╮
2179 │                                  │    QNS3A   │
2180 │                                  ├─────┬──────┤
2181 │                                  │ Male│Female│
2182 │                                  ├─────┼──────┤
2183 │                                  │Count│ Count│
2184 ├──────────────────────────────────┼─────┼──────┤
2185 │QND5A Cuban                       │   13│     7│
2186 │      Mexican                     │  175│   136│
2187 │      Spanish                     │   20│    28│
2188 │      South American              │   21│    13│
2189 │      Central American            │   27│    25│
2190 │      Puerto Rican, OR            │   37│    41│
2191 │      Something else              │   35│    33│
2192 │      Multiple - cannot choose one│    2│     5│
2193 ╰──────────────────────────────────┴─────┴──────╯
2194
2195                                  Custom Tables
2196 ╭────────────────────────────────────────────────────────────────┬────────────╮
2197 │                                                                │S3a. GENDER:│
2198 │                                                                ├─────┬──────┤
2199 │                                                                │ Male│Female│
2200 │                                                                ├─────┼──────┤
2201 │                                                                │Count│ Count│
2202 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2203 │D5a. What would you say is your primary    Cuban                │   13│     7│
2204 │ethnic background?                         Mexican              │  175│   136│
2205 │                                           Spanish              │   20│    28│
2206 │                                           South American       │   21│    13│
2207 │                                           Central American     │   27│    25│
2208 │                                           Puerto Rican, OR     │   37│    41│
2209 │                                           Something else       │   35│    33│
2210 │                                           Multiple - cannot    │    2│     5│
2211 │                                           choose one           │     │      │
2212 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2213
2214                                  Custom Tables
2215 ╭────────────────────────────────────────────────────────────┬────────────────╮
2216 │                                                            │   QNS3A S3a.   │
2217 │                                                            │     GENDER:    │
2218 │                                                            ├───────┬────────┤
2219 │                                                            │  Male │ Female │
2220 │                                                            ├───────┼────────┤
2221 │                                                            │ Count │  Count │
2222 ├────────────────────────────────────────────────────────────┼───────┼────────┤
2223 │QND5A D5a. What would you say is your    Cuban              │     13│       7│
2224 │primary ethnic background?               Mexican            │    175│     136│
2225 │                                         Spanish            │     20│      28│
2226 │                                         South American     │     21│      13│
2227 │                                         Central American   │     27│      25│
2228 │                                         Puerto Rican, OR   │     37│      41│
2229 │                                         Something else     │     35│      33│
2230 │                                         Multiple - cannot  │      2│       5│
2231 │                                         choose one         │       │        │
2232 ╰────────────────────────────────────────────────────────────┴───────┴────────╯
2233
2234                Custom Tables
2235 ╭────────────────────────────┬─────┬──────╮
2236 │                            │ Male│Female│
2237 │                            ├─────┼──────┤
2238 │                            │Count│ Count│
2239 ├────────────────────────────┼─────┼──────┤
2240 │Cuban                       │   13│     7│
2241 │Mexican                     │  175│   136│
2242 │Spanish                     │   20│    28│
2243 │South American              │   21│    13│
2244 │Central American            │   27│    25│
2245 │Puerto Rican, OR            │   37│    41│
2246 │Something else              │   35│    33│
2247 │Multiple - cannot choose one│    2│     5│
2248 ╰────────────────────────────┴─────┴──────╯
2249 ])
2250 AT_CLEANUP
2251
2252 AT_SETUP([CTABLES FORMAT EMPTY])
2253 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2254 AT_DATA([ctables.sps],
2255 [[GET 'nhtsa.sav'.
2256 CTABLES /FORMAT EMPTY=ZERO /TABLE qnd5a BY qnd5.
2257 CTABLES /FORMAT EMPTY=BLANK /TABLE qnd5a BY qnd5.
2258 CTABLES /FORMAT EMPTY='n/a' /TABLE qnd5a BY qnd5.
2259 ]])
2260 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2261                                  Custom Tables
2262 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2263 │                                             │   D5. ETHNICITY: Are you of   │
2264 │                                             │  Hispanic or Latino origin or │
2265 │                                             │            descent?           │
2266 │                                             ├───────────────┬───────────────┤
2267 │                                             │      Yes      │       No      │
2268 │                                             ├───────────────┼───────────────┤
2269 │                                             │     Count     │     Count     │
2270 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2271 │D5a. What would you say is   Cuban           │             20│              0│
2272 │your primary ethnic          Mexican         │            311│              0│
2273 │background?                  Spanish         │             48│              0│
2274 │                             South American  │             34│              0│
2275 │                             Central American│             52│              0│
2276 │                             Puerto Rican, OR│             78│              0│
2277 │                             Something else  │             68│              0│
2278 │                             Multiple -      │              7│              0│
2279 │                             cannot choose   │               │               │
2280 │                             one             │               │               │
2281 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2282
2283                                  Custom Tables
2284 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2285 │                                             │   D5. ETHNICITY: Are you of   │
2286 │                                             │  Hispanic or Latino origin or │
2287 │                                             │            descent?           │
2288 │                                             ├───────────────┬───────────────┤
2289 │                                             │      Yes      │       No      │
2290 │                                             ├───────────────┼───────────────┤
2291 │                                             │     Count     │     Count     │
2292 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2293 │D5a. What would you say is   Cuban           │             20│               │
2294 │your primary ethnic          Mexican         │            311│               │
2295 │background?                  Spanish         │             48│               │
2296 │                             South American  │             34│               │
2297 │                             Central American│             52│               │
2298 │                             Puerto Rican, OR│             78│               │
2299 │                             Something else  │             68│               │
2300 │                             Multiple -      │              7│               │
2301 │                             cannot choose   │               │               │
2302 │                             one             │               │               │
2303 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2304
2305                                  Custom Tables
2306 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2307 │                                             │   D5. ETHNICITY: Are you of   │
2308 │                                             │  Hispanic or Latino origin or │
2309 │                                             │            descent?           │
2310 │                                             ├───────────────┬───────────────┤
2311 │                                             │      Yes      │       No      │
2312 │                                             ├───────────────┼───────────────┤
2313 │                                             │     Count     │     Count     │
2314 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2315 │D5a. What would you say is   Cuban           │             20│n/a            │
2316 │your primary ethnic          Mexican         │            311│n/a            │
2317 │background?                  Spanish         │             48│n/a            │
2318 │                             South American  │             34│n/a            │
2319 │                             Central American│             52│n/a            │
2320 │                             Puerto Rican, OR│             78│n/a            │
2321 │                             Something else  │             68│n/a            │
2322 │                             Multiple -      │              7│n/a            │
2323 │                             cannot choose   │               │               │
2324 │                             one             │               │               │
2325 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2326 ])
2327 AT_CLEANUP
2328
2329 AT_SETUP([CTABLES FORMAT MISSING])
2330 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2331 AT_DATA([ctables.sps],
2332 [[GET 'nhtsa.sav'.
2333 CTABLES /FORMAT MISSING='(no data)' /TABLE qnd5a[COLPCT] BY qnd5.
2334 ]])
2335 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2336                                  Custom Tables
2337 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2338 │                                             │   D5. ETHNICITY: Are you of   │
2339 │                                             │  Hispanic or Latino origin or │
2340 │                                             │            descent?           │
2341 │                                             ├───────────────┬───────────────┤
2342 │                                             │      Yes      │       No      │
2343 │                                             ├───────────────┼───────────────┤
2344 │                                             │    Column %   │    Column %   │
2345 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2346 │D5a. What would you say is   Cuban           │           3.2%│(no data)      │
2347 │your primary ethnic          Mexican         │          50.3%│(no data)      │
2348 │background?                  Spanish         │           7.8%│(no data)      │
2349 │                             South American  │           5.5%│(no data)      │
2350 │                             Central American│           8.4%│(no data)      │
2351 │                             Puerto Rican, OR│          12.6%│(no data)      │
2352 │                             Something else  │          11.0%│(no data)      │
2353 │                             Multiple -      │           1.1%│(no data)      │
2354 │                             cannot choose   │               │               │
2355 │                             one             │               │               │
2356 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2357 ])
2358 AT_CLEANUP
2359
2360 AT_SETUP([CTABLES HIDESMALLCOUNTS])
2361 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2362 AT_DATA([ctables.sps],
2363 [[GET 'nhtsa.sav'.
2364 CTABLES /TABLE qn38[c][COUNT, COLPCT].
2365 CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
2366 CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
2367 ]])
2368 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2369                                  Custom Tables
2370 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2371 │                                                              │Count│Column %│
2372 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2373 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2374 │occasion?                                        1            │  491│   34.9%│
2375 │                                                 2            │  462│   32.9%│
2376 │                                                 3            │  229│   16.3%│
2377 │                                                 4            │   82│    5.8%│
2378 │                                                 5            │   56│    4.0%│
2379 │                                                 6            │   32│    2.3%│
2380 │                                                 7            │    9│     .6%│
2381 │                                                 8            │    8│     .6%│
2382 │                                                 9            │    4│     .3%│
2383 │                                                 10           │    6│     .4%│
2384 │                                                 11           │    2│     .1%│
2385 │                                                 12           │    5│     .4%│
2386 │                                                 14           │    1│     .1%│
2387 │                                                 15           │    1│     .1%│
2388 │                                                 18           │    1│     .1%│
2389 │                                                 20           │    4│     .3%│
2390 │                                                 25           │    1│     .1%│
2391 │                                                 30           │    3│     .2%│
2392 │                                                 60           │    1│     .1%│
2393 │                                                 99+          │    0│     .0%│
2394 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2395
2396                                  Custom Tables
2397 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2398 │                                                              │Count│Column %│
2399 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2400 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2401 │occasion?                                        1            │  491│   34.9%│
2402 │                                                 2            │  462│   32.9%│
2403 │                                                 3            │  229│   16.3%│
2404 │                                                 4            │   82│    5.8%│
2405 │                                                 5            │   56│    4.0%│
2406 │                                                 6            │   32│    2.3%│
2407 │                                                 7            │    9│     .6%│
2408 │                                                 8            │    8│     .6%│
2409 │                                                 9            │<5   │     .3%│
2410 │                                                 10           │    6│     .4%│
2411 │                                                 11           │<5   │     .1%│
2412 │                                                 12           │    5│     .4%│
2413 │                                                 14           │<5   │     .1%│
2414 │                                                 15           │<5   │     .1%│
2415 │                                                 18           │<5   │     .1%│
2416 │                                                 20           │<5   │     .3%│
2417 │                                                 25           │<5   │     .1%│
2418 │                                                 30           │<5   │     .2%│
2419 │                                                 60           │<5   │     .1%│
2420 │                                                 99+          │<5   │     .0%│
2421 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2422
2423                                  Custom Tables
2424 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2425 │                                                              │Count│Column %│
2426 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2427 │38. How many drinks did you have on that         Less than one│<10  │     .5%│
2428 │occasion?                                        1            │  491│   34.9%│
2429 │                                                 2            │  462│   32.9%│
2430 │                                                 3            │  229│   16.3%│
2431 │                                                 4            │   82│    5.8%│
2432 │                                                 5            │   56│    4.0%│
2433 │                                                 6            │   32│    2.3%│
2434 │                                                 7            │<10  │     .6%│
2435 │                                                 8            │<10  │     .6%│
2436 │                                                 9            │<10  │     .3%│
2437 │                                                 10           │<10  │     .4%│
2438 │                                                 11           │<10  │     .1%│
2439 │                                                 12           │<10  │     .4%│
2440 │                                                 14           │<10  │     .1%│
2441 │                                                 15           │<10  │     .1%│
2442 │                                                 18           │<10  │     .1%│
2443 │                                                 20           │<10  │     .3%│
2444 │                                                 25           │<10  │     .1%│
2445 │                                                 30           │<10  │     .2%│
2446 │                                                 60           │<10  │     .1%│
2447 │                                                 99+          │<10  │     .0%│
2448 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2449 ])
2450 AT_CLEANUP
2451
2452 AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
2453 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2454 AT_DATA([ctables.sps],
2455 [[GET 'nhtsa.sav'.
2456 CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
2457 ]])
2458 AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
2459  Custom Tables
2460 ╭────────────╮
2461 │S3a. GENDER:│
2462 ├─────┬──────┤
2463 │ Male│Female│
2464 ├─────┼──────┤
2465 │Count│ Count│
2466 ├─────┼──────┤
2467 │ 3132│  3867│
2468 ╰─────┴──────╯
2469 ])
2470 AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
2471 AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
2472 maximumColumnWidth="192"
2473 minimumColumnWidth="96"
2474 ])
2475 AT_CLEANUP
2476
2477 AT_SETUP([CTABLES special formats])
2478 AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
2479 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2480 AT_DATA([ctables.sps],
2481 [[GET 'nhtsa.sav'.
2482 COMPUTE x = qnd3 - 4.
2483 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].
2484 ]])
2485 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2486                            Custom Tables
2487 ╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
2488 │ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
2489 ├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
2490 │x│(3.0)  │N=-3.0 │(-3.0) │(-3.0%)│8.0    │N=8.0  │(8.0)  │(8.0%) │
2491 ╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
2492 ])
2493 AT_CLEANUP
2494
2495 AT_SETUP([CTABLES TITLES])
2496 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2497 AT_DATA([ctables.sps],
2498 [[GET 'nhtsa.sav'.
2499 CTABLES
2500     /VLABELS VARIABLES=qn1 DISPLAY=NONE
2501     /TABLE ((qn1[c][COUNT])) BY qns3a[c] > qnd5
2502     /TITLES TITLE='How often do you drive?'
2503             CAPTION='Generated )TIME on )DATE'
2504             CORNER=')TABLE'.
2505 ]])
2506 AT_CHECK([pspp ctables.sps -O box=unicode | sed 's/..:..:../HH:MM:SS/
2507 s&../../..&MM/DD/YY&'], [0], [dnl
2508                             How often do you drive?
2509 ╭───────────────────────────────────┬─────────────────────────────────────────╮
2510 │                                   │               S3a. GENDER:              │
2511 │                                   ├────────────────────┬────────────────────┤
2512 │                                   │        Male        │       Female       │
2513 │                                   ├────────────────────┼────────────────────┤
2514 │                                   │ D5. ETHNICITY: Are │ D5. ETHNICITY: Are │
2515 │                                   │ you of Hispanic or │ you of Hispanic or │
2516 │                                   │  Latino origin or  │  Latino origin or  │
2517 │( ( 1. How often do you usually    │      descent?      │      descent?      │
2518 │drive a car or other motor         ├─────────┬──────────┼─────────┬──────────┤
2519 │vehicle?) ) BY S3a. GENDER: > D5.  │   Yes   │    No    │   Yes   │    No    │
2520 │ETHNICITY: Are you of Hispanic or  ├─────────┼──────────┼─────────┼──────────┤
2521 │Latino origin or descent?          │  Count  │   Count  │  Count  │   Count  │
2522 ├───────────────────────────────────┼─────────┼──────────┼─────────┼──────────┤
2523 │Every day                          │      218│      2066│      166│      2175│
2524 │Several days a week                │       44│       391│       45│       782│
2525 │Once a week or less                │       16│       109│       12│       223│
2526 │Only certain times a year          │       15│        41│       11│        61│
2527 │Never                              │       39│       150│       56│       278│
2528 ╰───────────────────────────────────┴─────────┴──────────┴─────────┴──────────╯
2529 Generated HH:MM:SS on MM/DD/YY
2530 ])
2531 AT_CLEANUP