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