dates
[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 - Summary functions:
11 dnl   * U-prefix for unweighted summaries.
12 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
13 dnl - SPLIT FILE with SEPARATE splits
14 dnl - Definition of columns/rows when labels are rotated from one axis to another.
15 dnl
16 dnl Not for v1:
17 dnl - Multiple response sets
18 dnl - MRSETS subcommand.
19 dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
20 dnl - SIGTEST
21 dnl - COMPARETEST
22 dnl - Summary functions:
23 dnl   * .LCL and .UCL suffixes.
24 dnl   * .SE suffixes.
25 dnl - CATEGORIES:
26 dnl   * Data-dependent sorting.
27
28 AT_SETUP([CTABLES parsing])
29 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
30 AT_DATA([ctables.sps],
31 [[GET 'nhtsa.sav'.
32 CTABLES
33     /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
34     /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
35     /FORMAT UNITS=CM EMPTY="(-)"
36     /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
37     /VLABELS VARIABLES=qn17 DISPLAY=NAME
38     /VLABELS VARIABLES=qns3a DISPLAY=LABEL
39     /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
40     /VLABELS VARIABLES=qn20 DISPLAY=NONE
41     /MRSETS COUNTDUPLICATES=NO
42     /MRSETS COUNTDUPLICATES=YES
43     /SMISSING VARIABLE
44     /SMISSING LISTWISE
45     /WEIGHT VARIABLE=qns3a
46     /HIDESMALLCOUNTS
47     /HIDESMALLCOUNTS COUNT=10
48     /TABLE qnsa1
49     /SLABELS POSITION=COLUMN VISIBLE=YES
50     /SLABELS VISIBLE=NO POSITION=ROW
51     /SLABELS POSITION=LAYER
52     /CLABELS AUTO
53     /CLABELS ROWLABELS=OPPOSITE
54     /CRITERIA CILEVEL=50
55     /CATEGORIES VARIABLES=qn1 qn17
56                 ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
57                 POSITION=BEFORE EMPTY=INCLUDE.
58 CTABLES /TABLE qnsa1 /CLABELS ROWLABELS=LAYER.
59 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=OPPOSITE.
60 CTABLES /TABLE qnsa1 /CLABELS COLLABELS=LAYER.
61 ]])
62 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
63          Custom Tables
64 Count
65 ╭───────────────────┬────┬────╮
66 │                   │ RDD│CELL│
67 ├───────────────────┼────┼────┤
68 │Sa1. SAMPLE SOURCE:│5392│1607│
69 ╰───────────────────┴────┴────╯
70
71        Custom Tables
72 RDD
73 ╭───────────────────┬─────╮
74 │                   │Count│
75 ├───────────────────┼─────┤
76 │Sa1. SAMPLE SOURCE:│ 5392│
77 ╰───────────────────┴─────╯
78
79           Custom Tables
80 ╭────────────────────────┬─────╮
81 │                        │Count│
82 ├────────────────────────┼─────┤
83 │Sa1. SAMPLE SOURCE: RDD │ 5392│
84 │                    CELL│ 1607│
85 ╰────────────────────────┴─────╯
86
87           Custom Tables
88 ╭────────────────────────┬─────╮
89 │                        │Count│
90 ├────────────────────────┼─────┤
91 │Sa1. SAMPLE SOURCE: RDD │ 5392│
92 │                    CELL│ 1607│
93 ╰────────────────────────┴─────╯
94 ])
95 AT_CLEANUP
96
97 AT_SETUP([CTABLES parsing - negative])
98 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
99 AT_DATA([ctables.sps],
100 [[GET 'nhtsa.sav'.
101 CTABLES.
102 CTABLES /FORMAT MINCOLWIDTH='foo'.
103 CTABLES /TABLE qn1 [**].
104 CTABLES /TABLE qn1 [NOTAFUNCTION].
105 CTABLES /TABLE (qn1.
106 CTABLES /TABLE **.
107 CTABLES /TABLE NOTAVAR.
108 STRING string(A8).
109 CTABLES /TABLE string[S].
110 CTABLES /TABLE qn1 [PTILE 101].
111 CTABLES /TABLE qn1 [MEAN F0.1].
112 CTABLES /TABLE qn1 [MEAN NEGPAREN1.2].
113 CTABLES /TABLE qn1 [MEAN NEGPAREN3.4].
114 CTABLES /TABLE qn1 [MEAN TOTALS].
115 CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
116 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [SUBTOTAL=x].
117 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO **].
118 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO THRU x].
119 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1 THRU **].
120 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['x' THRU **].
121 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&**].
122 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
123 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 101).
124 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1.
125 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN.
126 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 MISSING=**.
127 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 TOTAL=**.
128 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 LABEL=**.
129 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 POSITION=**.
130 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 EMPTY=**.
131 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 **.
132 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1,2,3] **.
133 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[0]).
134 CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[1**]).
135 CTABLES /PCOMPUTE &k=EXPR([LO **]).
136 CTABLES /PCOMPUTE &k=EXPR([LO THRU **]).
137 CTABLES /PCOMPUTE &k=EXPR([1 THRU **]).
138 CTABLES /PCOMPUTE &k=EXPR([1**]).
139 CTABLES /PCOMPUTE &k=EXPR((1x)).
140 CTABLES /PCOMPUTE **k.
141 CTABLES /PCOMPUTE &1.
142 CTABLES /PCOMPUTE &k**.
143 CTABLES /PCOMPUTE &k=**.
144 CTABLES /PCOMPUTE &k=EXPR**.
145 CTABLES /PCOMPUTE &k=EXPR(1x).
146 CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
147 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=NOTAFUNCTION.
148 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=PTILE **.
149 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k LABEL=**.
150 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k HIDESOURCECATS=**.
151 CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k **.
152 CTABLES /FORMAT EMPTY=**.
153 CTABLES /FORMAT MISSING=**.
154 CTABLES /FORMAT **.
155 CTABLES /FORMAT MINCOLWIDTH=20 MAXCOLWIDTH=10/.
156 CTABLES /VLABELS **.
157 CTABLES /VLABELS VARIABLES=NOTAVAR.
158 CTABLES /VLABELS VARIABLES=qn1 **.
159 CTABLES /VLABELS VARIABLES=qn1 DISPLAY=**.
160 CTABLES /MRSETS **.
161 CTABLES /MRSETS COUNTDUPLICATES=**.
162 CTABLES /SMISSING **.
163 CTABLES /WEIGHT **.
164 CTABLES /WEIGHT VARIABLE=NOTAVAR.
165 CTABLES /HIDESMALLCOUNTS COUNT=1.
166 CTABLES /QUUX.
167 CTABLES /HIDESMALLCOUNTS COUNT=2.
168 CTABLES /TABLE qn1**.
169 CTABLES /TABLE qn1 /SLABELS POSITION=**.
170 CTABLES /TABLE qn1 /SLABELS VISIBLE=**.
171 CTABLES /TABLE qn1 /SLABELS **.
172 CTABLES /TABLE qn1 /CLABELS ROWLABELS=**.
173 CTABLES /TABLE qn1 /CLABELS COLLABELS=**.
174 CTABLES /TABLE qn1 /CLABELS **.
175 CTABLES /TABLE qn1 /CRITERIA **.
176 CTABLES /TABLE qn1 /CRITERIA CILEVEL=101.
177 CTABLES /TABLE qn1 /TITLES **.
178 CTABLES /TABLE qn1 /SIGTEST TYPE=**.
179 CTABLES /TABLE qn1 /SIGTEST ALPHA=**.
180 CTABLES /TABLE qn1 /SIGTEST INCLUDEMRSETS=**.
181 CTABLES /TABLE qn1 /SIGTEST CATEGORIES=**.
182 CTABLES /TABLE qn1 /SIGTEST **.
183 CTABLES /TABLE qn1 /COMPARETEST TYPE=**.
184 CTABLES /TABLE qn1 /COMPARETEST ALPHA=**.
185 CTABLES /TABLE qn1 /COMPARETEST ALPHA=0,5.
186 CTABLES /TABLE qn1 /COMPARETEST ADJUST=**.
187 CTABLES /TABLE qn1 /COMPARETEST INCLUDEMRSETS=**.
188 CTABLES /TABLE qn1 /COMPARETEST MEANSVARIANCE=**.
189 CTABLES /TABLE qn1 /COMPARETEST CATEGORIES=**.
190 CTABLES /TABLE qn1 /COMPARETEST MERGE=**.
191 CTABLES /TABLE qn1 /COMPARETEST STYLE=**.
192 CTABLES /TABLE qn1 /COMPARETEST SHOWSIG=**.
193 CTABLES /TABLE qn1 /COMPARETEST **.
194 CTABLES /TABLE qn1 / **.
195 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CLABELS COLLABELS=OPPOSITE.
196 CTABLES /TABLE qn20 > qnd1.
197 CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
198 NUMERIC datetime (DATETIME17.0).
199 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
200 ]])
201 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
202 [[ctables.sps:2.8: error: CTABLES: Syntax error at end of command: expecting `/'.
203
204 ctables.sps:3.29-3.33: error: CTABLES: Syntax error at `'foo'': Expected non-
205 negative number for MINCOLWIDTH.
206
207 ctables.sps:4.21-4.22: error: CTABLES: Syntax error at `**': expecting
208 identifier.
209
210 ctables.sps:5.21-5.32: error: CTABLES: Syntax error at `NOTAFUNCTION': Expecting
211 summary function name.
212
213 ctables.sps:6.20: error: CTABLES: Syntax error at end of command: expecting `@:}@'.
214
215 ctables.sps:7.16-7.17: error: CTABLES: Syntax error at `**': expecting
216 identifier.
217
218 ctables.sps:8: error: CTABLES: NOTAVAR is not a variable name.
219
220 ctables.sps:10.16-10.24: error: CTABLES: Cannot use string variable string as a
221 scale variable.
222    10 | CTABLES /TABLE string[S].
223       |                ^~~~~~~~~
224
225 ctables.sps:11.27-11.29: error: CTABLES: Syntax error at `101': Expected number
226 between 0 and 100 for PTILE.
227
228 ctables.sps:12: error: CTABLES: Output format F0.1 specifies width 0, but F
229 requires a width between 1 and 40.
230
231 ctables.sps:13.26-13.36: error: CTABLES: Syntax error at `NEGPAREN1.2': Output
232 format NEGPAREN requires width 2 or greater.
233
234 ctables.sps:14.26-14.36: error: CTABLES: Syntax error at `NEGPAREN3.4': Output
235 format NEGPAREN requires width greater than decimals.
236
237 ctables.sps:15.21-15.24: error: CTABLES: Summary function MEAN applies only to
238 scale variables.
239    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
240       |                     ^~~~
241
242 ctables.sps:15.16-15.18: note: CTABLES: 'QN1' is not a scale variable.
243    15 | CTABLES /TABLE qn1 [MEAN TOTALS].
244       |                ^~~
245
246 ctables.sps:15.32: error: CTABLES: Syntax error at `@:>@': expecting `@<:@'.
247
248 ctables.sps:16.21-16.24: error: CTABLES: Summary function MEAN applies only to
249 scale variables.
250    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
251       |                     ^~~~
252
253 ctables.sps:16.16-16.18: note: CTABLES: 'QN1' is not a scale variable.
254    16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
255       |                ^~~
256
257 ctables.sps:16.40: error: CTABLES: Syntax error at `%': expecting `@:>@'.
258
259 ctables.sps:17.56: error: CTABLES: Syntax error at `x': expecting string.
260
261 ctables.sps:18.50-18.51: error: CTABLES: Syntax error at `**': expecting THRU.
262
263 ctables.sps:19.55: error: CTABLES: Syntax error at `x': expecting number.
264
265 ctables.sps:20.54-20.55: error: CTABLES: Syntax error at `**': expecting number.
266
267 ctables.sps:21.56-21.57: error: CTABLES: Syntax error at `**': expecting string.
268
269 ctables.sps:22.48-22.49: error: CTABLES: Syntax error at `**': expecting
270 identifier.
271
272 ctables.sps:23.47-23.48: error: CTABLES: Unknown postcompute &x.
273    23 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
274       |                                               ^~
275
276 ctables.sps:24.61-24.63: error: CTABLES: Syntax error at `101': Expected number
277 between 0 and 100 for PTILE.
278
279 ctables.sps:25.58: error: CTABLES: Syntax error at end of command: expecting
280 `@:}@'.
281
282 ctables.sps:26.54: error: CTABLES: Syntax error at end of command: expecting
283 `@{:@'.
284
285 ctables.sps:27.54-27.55: error: CTABLES: Syntax error at `**': expecting INCLUDE
286 or EXCLUDE.
287
288 ctables.sps:28.52-28.53: error: CTABLES: Syntax error at `**': expecting YES or
289 NO.
290
291 ctables.sps:29.52-29.53: error: CTABLES: Syntax error at `**': expecting string.
292
293 ctables.sps:30.55-30.56: error: CTABLES: Syntax error at `**': expecting BEFORE
294 or AFTER.
295
296 ctables.sps:31.52-31.53: error: CTABLES: Syntax error at `**': expecting INCLUDE
297 or EXCLUDE.
298
299 ctables.sps:32.46-32.47: error: CTABLES: Syntax error at `**': expecting ORDER,
300 KEY, MISSING, TOTAL, LABEL, POSITION, or EMPTY.
301
302 ctables.sps:33.54-33.55: error: CTABLES: Syntax error at `**': expecting TOTAL,
303 LABEL, POSITION, or EMPTY.
304
305 ctables.sps:34.36: error: CTABLES: Syntax error at `0': Expected positive
306 integer for SUBTOTAL.
307
308 ctables.sps:35.37-35.38: error: CTABLES: Syntax error at `**': expecting `@:>@'.
309
310 ctables.sps:36.31-36.32: error: CTABLES: Syntax error at `**': expecting THRU.
311
312 ctables.sps:37.36-37.37: error: CTABLES: Syntax error at `**': expecting number.
313
314 ctables.sps:38.35-38.36: error: CTABLES: Syntax error at `**': expecting number.
315
316 ctables.sps:39.29-39.30: error: CTABLES: Syntax error at `**': expecting `@:>@'.
317
318 ctables.sps:40.29: error: CTABLES: Syntax error at `x': expecting `@:}@'.
319
320 ctables.sps:41.19-41.20: error: CTABLES: Syntax error at `**': expecting &.
321
322 ctables.sps:42.20: error: CTABLES: Syntax error at `1': expecting identifier.
323
324 ctables.sps:43.21-43.22: error: CTABLES: Syntax error at `**': expecting `='.
325
326 ctables.sps:44.22-44.23: error: CTABLES: Syntax error at `**': expecting EXPR.
327
328 ctables.sps:45.26-45.27: error: CTABLES: Syntax error at `**': expecting `('.
329
330 ctables.sps:46.28: error: CTABLES: Syntax error at `x': expecting `)'.
331
332 ctables.sps:47.31-47.49: warning: CTABLES: New definition of &k will override
333 the previous definition.
334    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
335       |                               ^~~~~~~~~~~~~~~~~~~
336
337 ctables.sps:47.10-47.28: note: CTABLES: This is the previous definition.
338    47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
339       |          ^~~~~~~~~~~~~~~~~~~
340
341 ctables.sps:47.50: error: CTABLES: Syntax error at end of command: expecting
342 `/'.
343
344 ctables.sps:48.53-48.64: error: CTABLES: Syntax error at `NOTAFUNCTION':
345 Expecting summary function name.
346
347 ctables.sps:49.59-49.60: error: CTABLES: Syntax error at `**': Expected number
348 between 0 and 100 for PTILE.
349
350 ctables.sps:50.52-50.53: error: CTABLES: Syntax error at `**': expecting string.
351
352 ctables.sps:51.61-51.62: error: CTABLES: Syntax error at `**': expecting YES or
353 NO.
354
355 ctables.sps:52.46-52.47: error: CTABLES: Syntax error at `**': expecting LABEL,
356 FORMAT, or HIDESOURCECATS.
357
358 ctables.sps:53.23-53.24: error: CTABLES: Syntax error at `**': expecting string.
359
360 ctables.sps:54.25-54.26: error: CTABLES: Syntax error at `**': expecting string.
361
362 ctables.sps:55.17-55.18: error: CTABLES: Syntax error at `**': expecting
363 MINCOLWIDTH, MAXCOLWIDTH, UNITS, EMPTY, or MISSING.
364
365 ctables.sps:56: error: CTABLES: MINCOLWIDTH must not be greater than
366 MAXCOLWIDTH.
367
368 ctables.sps:57.18-57.19: error: CTABLES: Syntax error at `**': expecting
369 VARIABLES.
370
371 ctables.sps:58: error: CTABLES: NOTAVAR is not a variable name.
372
373 ctables.sps:59.32-59.33: error: CTABLES: Syntax error at `**': expecting
374 DISPLAY.
375
376 ctables.sps:60.40-60.41: error: CTABLES: Syntax error at `**': expecting
377 DEFAULT, NAME, LABEL, BOTH, or NONE.
378
379 ctables.sps:61.17-61.18: error: CTABLES: Syntax error at `**': expecting
380 COUNTDUPLICATES.
381
382 ctables.sps:62.33-62.34: error: CTABLES: Syntax error at `**': expecting YES or
383 NO.
384
385 ctables.sps:63.19-63.20: error: CTABLES: Syntax error at `**': expecting
386 VARIABLE or LISTWISE.
387
388 ctables.sps:64.17-64.18: error: CTABLES: Syntax error at `**': expecting
389 VARIABLE.
390
391 ctables.sps:65: error: CTABLES: NOTAVAR is not a variable name.
392
393 ctables.sps:66.32: error: CTABLES: Syntax error at `1': Expected integer 2 or
394 greater for HIDESMALLCOUNTS COUNT.
395
396 ctables.sps:67.10-67.13: error: CTABLES: Syntax error at `QUUX': expecting
397 FORMAT, VLABELS, MRSETS, SMISSING, PCOMPUTE, PPROPERTIES, WEIGHT,
398 HIDESMALLCOUNTS, or TABLE.
399
400 ctables.sps:68.33: error: CTABLES: Syntax error at end of command: expecting
401 `/'.
402
403 ctables.sps:69.19-69.20: error: CTABLES: Syntax error at `**': expecting `/'.
404
405 ctables.sps:70.38-70.39: error: CTABLES: Syntax error at `**': expecting COLUMN,
406 ROW, or LAYER.
407
408 ctables.sps:71.37-71.38: error: CTABLES: Syntax error at `**': expecting YES or
409 NO.
410
411 ctables.sps:72.29-72.30: error: CTABLES: Syntax error at `**': expecting
412 POSITION or VISIBLE.
413
414 ctables.sps:73.39-73.40: error: CTABLES: Syntax error at `**': expecting
415 OPPOSITE or LAYER.
416
417 ctables.sps:74.39-74.40: error: CTABLES: Syntax error at `**': expecting
418 OPPOSITE or LAYER.
419
420 ctables.sps:75.29-75.30: error: CTABLES: Syntax error at `**': expecting AUTO,
421 ROWLABELS, or COLLABELS.
422
423 ctables.sps:76.30-76.31: error: CTABLES: Syntax error at `**': expecting
424 CILEVEL.
425
426 ctables.sps:77.38-77.40: error: CTABLES: Syntax error at `101': Expected number
427 in @<:@0,100@:}@ for CILEVEL.
428
429 ctables.sps:78.28-78.29: error: CTABLES: Syntax error at `**': expecting
430 CAPTION, CORNER, or TITLE.
431
432 ctables.sps:79.34-79.35: error: CTABLES: Syntax error at `**': expecting
433 CHISQUARE.
434
435 ctables.sps:80.35-80.36: error: CTABLES: Syntax error at `**': Expected number
436 in @<:@0,1@:}@ for ALPHA.
437
438 ctables.sps:81.43-81.44: error: CTABLES: Syntax error at `**': expecting YES or
439 NO.
440
441 ctables.sps:82.40-82.41: error: CTABLES: Syntax error at `**': expecting
442 ALLVISIBLE or SUBTOTALS.
443
444 ctables.sps:83.29-83.30: error: CTABLES: Syntax error at `**': expecting TYPE,
445 ALPHA, INCLUDEMRSETS, or CATEGORIES.
446
447 ctables.sps:84.38-84.39: error: CTABLES: Syntax error at `**': expecting PROP or
448 MEAN.
449
450 ctables.sps:85.39-85.40: error: CTABLES: Syntax error at `**': Expected number
451 in (0,1) for ALPHA.
452
453 ctables.sps:86.39: error: CTABLES: Syntax error at `0': Expected number in (0,1)
454 for ALPHA.
455
456 ctables.sps:87.40-87.41: error: CTABLES: Syntax error at `**': expecting
457 BONFERRONI, BH, or NONE.
458
459 ctables.sps:88.47-88.48: error: CTABLES: Syntax error at `**': expecting YES or
460 NO.
461
462 ctables.sps:89.47-89.48: error: CTABLES: Syntax error at `**': expecting ALLCATS
463 or TESTEDCATS.
464
465 ctables.sps:90.44-90.45: error: CTABLES: Syntax error at `**': expecting
466 ALLVISIBLE or SUBTOTALS.
467
468 ctables.sps:91.39-91.40: error: CTABLES: Syntax error at `**': expecting YES or
469 NO.
470
471 ctables.sps:92.39-92.40: error: CTABLES: Syntax error at `**': expecting APA or
472 SIMPLE.
473
474 ctables.sps:93.41-93.42: error: CTABLES: Syntax error at `**': expecting YES or
475 NO.
476
477 ctables.sps:94.33-94.34: error: CTABLES: Syntax error at `**': expecting TYPE,
478 ALPHA, ADJUST, INCLUDEMRSETS, MEANSVARIANCE, CATEGORIES, MERGE, STYLE, or
479 SHOWSIG.
480
481 ctables.sps:95.22-95.23: error: CTABLES: Syntax error at `**': expecting TABLE,
482 SLABELS, CLABELS, CRITERIA, CATEGORIES, TITLES, SIGTEST, or COMPARETEST.
483
484 ctables.sps:96: error: CTABLES: ROWLABELS and COLLABELS may not both be
485 specified.
486
487 ctables.sps:97.16-97.26: error: CTABLES: Cannot nest scale variables.
488    97 | CTABLES /TABLE qn20 > qnd1.
489       |                ^~~~~~~~~~~
490
491 ctables.sps:97.16-97.19: note: CTABLES: This is an outer scale variable.
492    97 | CTABLES /TABLE qn20 > qnd1.
493       |                ^~~~
494
495 ctables.sps:97.23-97.26: note: CTABLES: This is an inner scale variable.
496    97 | CTABLES /TABLE qn20 > qnd1.
497       |                       ^~~~
498
499 ctables.sps:98.16-98.35: error: CTABLES: Summaries may only be requested for
500 categorical variables at the innermost nesting level.
501    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
502       |                ^~~~~~~~~~~~~~~~~~~~
503
504 ctables.sps:98.16-98.18: note: CTABLES: This outer categorical variable has a
505 summary.
506    98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
507       |                ^~~
508
509 ctables.sps:100.52-100.56: error: CTABLES: Failed to parse category
510 specification as format DATETIME: Day (123) must be between 1 and 31..
511   100 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
512       |                                                    ^~~~~
513 ]])
514 AT_CLEANUP
515
516 AT_SETUP([CTABLES parsing - more negative])
517 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
518 AT_DATA([ctables.sps],
519 [[GET 'nhtsa.sav'.
520 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
521 CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
522 CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
523
524 STRING string(A8).
525 CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
526 CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
527
528 CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1).
529
530 CTABLES /TABLE qnd1 /CLABELS ROWLABELS=OPPOSITE.
531 CTABLES /TABLE qn1 + string /CLABELS ROWLABELS=OPPOSITE.
532 CTABLES /TABLE qn1 + qnsa1 /CLABELS ROWLABELS=OPPOSITE.
533 CTABLES /TABLE qn105ba + qn105bb /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn105ba [1,2,3].
534
535 CTABLES /PCOMPUTE &x=EXPR(1**2**3).
536 CTABLES /PCOMPUTE &x=EXPR([**]).
537 CTABLES /PCOMPUTE &x=EXPR(**).
538
539 CTABLES /TABLE.
540
541 CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. 
542 ]])
543 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
544 [[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a
545 category not included in the category list.
546     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
547 VARIABLES=qn1 [&pc].
548       |
549 ^~~
550
551 ctables.sps:2.28-2.35: note: CTABLES: This is the missing category.
552     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
553 VARIABLES=qn1 [&pc].
554       |                            ^~~~~~~~
555
556 ctables.sps:2.76-2.79: note: CTABLES: To fix the problem, add subtotals to the
557 list of categories here.
558     2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
559 VARIABLES=qn1 [&pc].
560       |
561 ^~~~
562
563 ctables.sps:3.73-3.75: error: CTABLES: Computed category &pc references a
564 category not included in the category list.
565     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
566 [&pc].
567       |
568 ^~~
569
570 ctables.sps:3.28-3.32: note: CTABLES: This is the missing category.
571     3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
572 [&pc].
573       |                            ^~~~~
574
575 ctables.sps:3: note: CTABLES: To fix the problem, add TOTAL=YES to the
576 variable's CATEGORIES specification.
577
578 ctables.sps:4.76-4.99: error: CTABLES: These categories include 2 instances of
579 SUBTOTAL or HSUBTOTAL, so references from computed categories must refer to
580 subtotals by position, e.g. SUBTOTAL[1].
581     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
582 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
583       |
584 ^~~~~~~~~~~~~~~~~~~~~~~~
585
586 ctables.sps:4.28-4.35: note: CTABLES: This is the reference that lacks a
587 position.
588     4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
589 VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
590       |                            ^~~~~~~~
591
592 ctables.sps:7.47-7.54: error: CTABLES: This category specification may be
593 applied only to string variables, but this subcommand tries to apply it to
594 numeric variable QN1.
595     7 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
596       |                                               ^~~~~~~~
597
598 ctables.sps:8.53: error: CTABLES: This category specification may be applied
599 only to numeric variables, but this subcommand tries to apply it to string
600 variable string.
601     8 | CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
602       |                                                     ^
603
604 ctables.sps:10: error: CTABLES: ROWLABELS=OPPOSITE is not allowed with sorting
605 based on a summary function.
606
607 ctables.sps:12: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
608 moved to be categorical, but qnd1 is a scale variable.
609
610 ctables.sps:13: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
611 moved to have the same width, but QN1 has width 0 and string has width 8.
612
613 ctables.sps:14: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
614 moved to have the same value labels, but QN1 and QNSA1 have different value
615 labels.
616
617 ctables.sps:15: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
618 moved to have the same category specifications, but QN105BA and QN105BB have
619 different category specifications.
620
621 ctables.sps:17.27-17.33: warning: CTABLES: The exponentiation operator (`**') is
622 left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'.  To disable
623 this warning, insert parentheses.
624    17 | CTABLES /PCOMPUTE &x=EXPR(1**2**3).
625       |                           ^~~~~~~
626
627 ctables.sps:17.35: error: CTABLES: Syntax error at end of command: expecting
628 `/'.
629
630 ctables.sps:18.28-18.29: error: CTABLES: Syntax error at `**'.
631
632 ctables.sps:19.27-19.28: error: CTABLES: Syntax error at `**'.
633
634 ctables.sps:21.15: error: CTABLES: Syntax error at end of command: At least one
635 variable must be specified.
636
637 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
638
639 ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
640 summary.
641    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
642       |                                                  ^~~~~
643
644 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
645 summary.
646    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
647       |                ^~~~~
648
649 ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
650 summary.
651    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
652       |                                 ^~~~~
653
654 ctables.sps:23.33-23.37: note: CTABLES: This is a scale variable, so it always
655 has a summary even if the syntax does not explicitly specify one.
656    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
657       |                                 ^~~~~
658 ]])
659 AT_CLEANUP
660
661 AT_SETUP([CTABLES one categorical variable])
662 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
663 AT_DATA([ctables.sps],
664 [[GET 'nhtsa.sav'.
665 CTABLES /TABLE qn1.
666 CTABLES /TABLE BY qn1.
667 CTABLES /TABLE BY BY qn1.
668 ]])
669 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
670                                   Custom Tables
671 ╭────────────────────────────────────────────────────────────────────────┬─────╮
672 │                                                                        │Count│
673 ├────────────────────────────────────────────────────────────────────────┼─────┤
674 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
675 │motor vehicle?                                     Several days a week  │ 1274│
676 │                                                   Once a week or less  │  361│
677 │                                                   Only certain times a │  130│
678 │                                                   year                 │     │
679 │                                                   Never                │  540│
680 ╰────────────────────────────────────────────────────────────────────────┴─────╯
681
682                                   Custom Tables
683 ╭──────────────────────────────────────────────────────────────────────────────╮
684 │        1. How often do you usually drive a car or other motor vehicle?       │
685 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
686 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
687 │Every day│       week       │       less       │          year          │Never│
688 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
689 │  Count  │       Count      │       Count      │          Count         │Count│
690 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
691 │     4667│              1274│               361│                     130│  540│
692 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
693
694 Custom Tables
695 Every day
696 ╭─────╮
697 │Count│
698 ├─────┤
699 │ 4667│
700 ╰─────╯
701 ])
702 AT_CLEANUP
703
704 AT_SETUP([CTABLES one string variable])
705 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
706 AT_DATA([ctables.sps],
707 [[GET 'nhtsa.sav'.
708 STRING licensed(A8).
709 MISSING VALUES licensed('DontKnow', 'Refused').
710 RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
711 CTABLES /TABLE licensed.
712 CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
713 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
714 * Notice that the string matching is case-sensitive.
715 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
716 CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
717 CTABLES
718     /PCOMPUTE &notyes=EXPR(['No']+['DontKnow']+['Refused'])
719     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
720     /TABLE licensed
721     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'No', 'DontKnow', 'Refused'].
722 CTABLES
723     /PCOMPUTE &notyes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
724     /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
725     /TABLE licensed
726     /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'DontKnow' THRU 'No', 'Refused'].
727 ]])
728 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
729     Custom Tables
730 ╭────────────┬─────╮
731 │            │Count│
732 ├────────────┼─────┤
733 │licensed No │  572│
734 │         Yes│ 6379│
735 ╰────────────┴─────╯
736
737           Custom Tables
738 ╭─────────────────┬─────┬───────╮
739 │                 │Count│Valid N│
740 ├─────────────────┼─────┼───────┤
741 │licensed DontKnow│    4│       │
742 │         No      │  572│       │
743 │         Refused │   44│       │
744 │         Yes     │ 6379│       │
745 │         Total   │ 6999│   6951│
746 ╰─────────────────┴─────┴───────╯
747
748      Custom Tables
749 ╭──────────────┬─────╮
750 │              │Count│
751 ├──────────────┼─────┤
752 │licensed Yes  │ 6379│
753 │         No   │  572│
754 │         Total│ 6951│
755 ╰──────────────┴─────╯
756
757      Custom Tables
758 ╭──────────────┬─────╮
759 │              │Count│
760 ├──────────────┼─────┤
761 │licensed Yes  │ 6379│
762 │         no   │    0│
763 │         Total│ 6379│
764 ╰──────────────┴─────╯
765
766       Custom Tables
767 ╭────────────────┬─────╮
768 │                │Count│
769 ├────────────────┼─────┤
770 │licensed No     │  572│
771 │         Refused│   44│
772 │         Yes    │ 6379│
773 │         Total  │ 6995│
774 ╰────────────────┴─────╯
775
776       Custom Tables
777 ╭────────────────┬─────╮
778 │                │Count│
779 ├────────────────┼─────┤
780 │licensed Yes    │ 6379│
781 │         Not Yes│  620│
782 ╰────────────────┴─────╯
783
784       Custom Tables
785 ╭────────────────┬─────╮
786 │                │Count│
787 ├────────────────┼─────┤
788 │licensed Yes    │ 6379│
789 │         Not Yes│  620│
790 ╰────────────────┴─────╯
791 ])
792 AT_CLEANUP
793
794 AT_SETUP([CTABLES one scale variable])
795 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
796 AT_DATA([ctables.sps],
797 [[GET 'nhtsa.sav'.
798 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
799 CTABLES /TABLE BY qnd1.
800 CTABLES /TABLE BY BY qnd1.
801 ]])
802 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
803                                   Custom Tables
804 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
805 │                      │     │       │       │    │     Std    │       │       │
806 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
807 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
808 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
809 │age?                  │     │       │       │    │            │       │       │
810 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
811
812         Custom Tables
813 ╭──────────────────────────╮
814 │D1. AGE: What is your age?│
815 ├──────────────────────────┤
816 │           Mean           │
817 ├──────────────────────────┤
818 │                        48│
819 ╰──────────────────────────╯
820
821 Custom Tables
822 D1. AGE: What is your age?
823 ╭────╮
824 │Mean│
825 ├────┤
826 │  48│
827 ╰────╯
828 ])
829 AT_CLEANUP
830
831 AT_SETUP([CTABLES simple stacking])
832 AT_KEYWORDS([stack stacked])
833 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
834 AT_DATA([ctables.sps],
835 [[GET 'nhtsa.sav'.
836 CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
837 ]])
838 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
839                                   Custom Tables
840 ╭───────────────────────────────────────────────────────────────┬──────────────╮
841 │                                                               │ S3a. GENDER: │
842 │                                                               ├──────┬───────┤
843 │                                                               │ Male │ Female│
844 │                                                               ├──────┼───────┤
845 │                                                               │Column│ Column│
846 │                                                               │   %  │   %   │
847 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
848 │105b. How likely is it that drivers who have had   Almost      │   10%│    11%│
849 │too much to drink to drive safely will A. Get      certain     │      │       │
850 │stopped by the police?                             Very likely │   21%│    22%│
851 │                                                   Somewhat    │   38%│    42%│
852 │                                                   likely      │      │       │
853 │                                                   Somewhat    │   21%│    18%│
854 │                                                   unlikely    │      │       │
855 │                                                   Very        │   10%│     8%│
856 │                                                   unlikely    │      │       │
857 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
858 │105b. How likely is it that drivers who have had   Almost      │   14%│    18%│
859 │too much to drink to drive safely will B. Have an  certain     │      │       │
860 │accident?                                          Very likely │   36%│    45%│
861 │                                                   Somewhat    │   39%│    32%│
862 │                                                   likely      │      │       │
863 │                                                   Somewhat    │    9%│     4%│
864 │                                                   unlikely    │      │       │
865 │                                                   Very        │    3%│     2%│
866 │                                                   unlikely    │      │       │
867 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
868 │105b. How likely is it that drivers who have had   Almost      │   18%│    16%│
869 │too much to drink to drive safely will C. Be       certain     │      │       │
870 │convicted for drunk driving?                       Very likely │   32%│    28%│
871 │                                                   Somewhat    │   27%│    32%│
872 │                                                   likely      │      │       │
873 │                                                   Somewhat    │   15%│    15%│
874 │                                                   unlikely    │      │       │
875 │                                                   Very        │    9%│     9%│
876 │                                                   unlikely    │      │       │
877 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
878 │105b. How likely is it that drivers who have had   Almost      │   16%│    16%│
879 │too much to drink to drive safely will D. Be       certain     │      │       │
880 │arrested for drunk driving?                        Very likely │   26%│    27%│
881 │                                                   Somewhat    │   32%│    35%│
882 │                                                   likely      │      │       │
883 │                                                   Somewhat    │   17%│    15%│
884 │                                                   unlikely    │      │       │
885 │                                                   Very        │    9%│     7%│
886 │                                                   unlikely    │      │       │
887 ╰───────────────────────────────────────────────────────────────┴──────┴───────╯
888 ])
889 AT_CLEANUP
890
891 AT_SETUP([CTABLES show or hide empty categories])
892 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
893 AT_DATA([ctables.sps],
894 [[GET 'nhtsa.sav'.
895 IF (qn105ba = 2) qn105ba = 1.
896 IF (qns3a = 1) qns3a = 2.
897 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
898 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
899     /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
900 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
901     /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
902 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
903     /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
904 ]])
905 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
906                                   Custom Tables
907 ╭──────────────────────────────────────────────────────────────┬───────────────╮
908 │                                                              │  S3a. GENDER: │
909 │                                                              ├───────┬───────┤
910 │                                                              │  Male │ Female│
911 │                                                              ├───────┼───────┤
912 │                                                              │ Column│ Column│
913 │                                                              │   %   │   %   │
914 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
915 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
916 │too much to drink to drive safely will A. Get      certain    │       │       │
917 │stopped by the police?                             Very likely│      .│     0%│
918 │                                                   Somewhat   │      .│    40%│
919 │                                                   likely     │       │       │
920 │                                                   Somewhat   │      .│    19%│
921 │                                                   unlikely   │       │       │
922 │                                                   Very       │      .│     9%│
923 │                                                   unlikely   │       │       │
924 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
925
926                                   Custom Tables
927 ╭──────────────────────────────────────────────────────────────┬───────────────╮
928 │                                                              │  S3a. GENDER: │
929 │                                                              ├───────┬───────┤
930 │                                                              │  Male │ Female│
931 │                                                              ├───────┼───────┤
932 │                                                              │ Column│ Column│
933 │                                                              │   %   │   %   │
934 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
935 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
936 │too much to drink to drive safely will A. Get      certain    │       │       │
937 │stopped by the police?                             Somewhat   │      .│    40%│
938 │                                                   likely     │       │       │
939 │                                                   Somewhat   │      .│    19%│
940 │                                                   unlikely   │       │       │
941 │                                                   Very       │      .│     9%│
942 │                                                   unlikely   │       │       │
943 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
944
945                                   Custom Tables
946 ╭────────────────────────────────────────────────────────────────────┬─────────╮
947 │                                                                    │   S3a.  │
948 │                                                                    │ GENDER: │
949 │                                                                    ├─────────┤
950 │                                                                    │  Female │
951 │                                                                    ├─────────┤
952 │                                                                    │ Column %│
953 ├────────────────────────────────────────────────────────────────────┼─────────┤
954 │105b. How likely is it that drivers who have had too    Almost      │      32%│
955 │much to drink to drive safely will A. Get stopped by    certain     │         │
956 │the police?                                             Very likely │       0%│
957 │                                                        Somewhat    │      40%│
958 │                                                        likely      │         │
959 │                                                        Somewhat    │      19%│
960 │                                                        unlikely    │         │
961 │                                                        Very        │       9%│
962 │                                                        unlikely    │         │
963 ╰────────────────────────────────────────────────────────────────────┴─────────╯
964
965                                   Custom Tables
966 ╭────────────────────────────────────────────────────────────────────┬─────────╮
967 │                                                                    │   S3a.  │
968 │                                                                    │ GENDER: │
969 │                                                                    ├─────────┤
970 │                                                                    │  Female │
971 │                                                                    ├─────────┤
972 │                                                                    │ Column %│
973 ├────────────────────────────────────────────────────────────────────┼─────────┤
974 │105b. How likely is it that drivers who have had too    Almost      │      32%│
975 │much to drink to drive safely will A. Get stopped by    certain     │         │
976 │the police?                                             Somewhat    │      40%│
977 │                                                        likely      │         │
978 │                                                        Somewhat    │      19%│
979 │                                                        unlikely    │         │
980 │                                                        Very        │       9%│
981 │                                                        unlikely    │         │
982 ╰────────────────────────────────────────────────────────────────────┴─────────╯
983 ])
984 AT_CLEANUP
985
986 AT_SETUP([CTABLES sorting categories])
987 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
988 AT_DATA([ctables.sps],
989 [[GET 'nhtsa.sav'.
990 IF (QND5A=6) QND5A=-1.
991 IF (QND5A=5) QND5A=-2.
992 CTABLES /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=A
993         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=D
994         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=A
995         /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=D.
996 ]])
997 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
998                                   Custom Tables
999 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1000 │                                                                        │Count│
1001 ├────────────────────────────────────────────────────────────────────────┼─────┤
1002 │D5a. What would you say is your primary ethnic  -2.00                   │   52│
1003 │background?                                     -1.00                   │   78│
1004 │                                                Cuban                   │   20│
1005 │                                                Mexican                 │  311│
1006 │                                                Spanish                 │   48│
1007 │                                                South American          │   34│
1008 │                                                Central American        │    0│
1009 │                                                Puerto Rican, OR        │    0│
1010 │                                                Something else          │   68│
1011 │                                                Multiple - cannot choose│    7│
1012 │                                                one                     │     │
1013 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1014
1015                                   Custom Tables
1016 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1017 │                                                                        │Count│
1018 ├────────────────────────────────────────────────────────────────────────┼─────┤
1019 │D5a. What would you say is your primary ethnic  Multiple - cannot choose│    7│
1020 │background?                                     one                     │     │
1021 │                                                Something else          │   68│
1022 │                                                Puerto Rican, OR        │    0│
1023 │                                                Central American        │    0│
1024 │                                                South American          │   34│
1025 │                                                Spanish                 │   48│
1026 │                                                Mexican                 │  311│
1027 │                                                Cuban                   │   20│
1028 │                                                -1.00                   │   78│
1029 │                                                -2.00                   │   52│
1030 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1031
1032                                   Custom Tables
1033 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1034 │                                                                        │Count│
1035 ├────────────────────────────────────────────────────────────────────────┼─────┤
1036 │D5a. What would you say is your primary ethnic  Central American        │    0│
1037 │background?                                     Cuban                   │   20│
1038 │                                                Mexican                 │  311│
1039 │                                                Multiple - cannot choose│    7│
1040 │                                                one                     │     │
1041 │                                                Puerto Rican, OR        │    0│
1042 │                                                Something else          │   68│
1043 │                                                South American          │   34│
1044 │                                                Spanish                 │   48│
1045 │                                                -2.00                   │   52│
1046 │                                                -1.00                   │   78│
1047 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1048
1049                                   Custom Tables
1050 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1051 │                                                                        │Count│
1052 ├────────────────────────────────────────────────────────────────────────┼─────┤
1053 │D5a. What would you say is your primary ethnic  Spanish                 │   48│
1054 │background?                                     South American          │   34│
1055 │                                                Something else          │   68│
1056 │                                                Puerto Rican, OR        │    0│
1057 │                                                Multiple - cannot choose│    7│
1058 │                                                one                     │     │
1059 │                                                Mexican                 │  311│
1060 │                                                Cuban                   │   20│
1061 │                                                Central American        │    0│
1062 │                                                -1.00                   │   78│
1063 │                                                -2.00                   │   52│
1064 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1065 ])
1066 AT_CLEANUP
1067
1068 AT_SETUP([CTABLES simple nesting])
1069 AT_KEYWORDS([nest nested])
1070 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1071 AT_DATA([ctables.sps],
1072 [[GET 'nhtsa.sav'.
1073 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
1074   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
1075 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
1076   /CATEGORIES VARIABLES=qns3a TOTAL=YES
1077   /CLABELS ROW=OPPOSITE.
1078 ]])
1079 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1080                                   Custom Tables
1081 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
1082 │                                                                 │     │ Table│
1083 │                                                                 │Count│   %  │
1084 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1085 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
1086 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
1087 │drive safely will A. Get stopped by                        Total │  700│   10%│
1088 │the police?                           ╶──────────────────────────┼─────┼──────┤
1089 │                                       Very       S3a.     Male  │  660│   10%│
1090 │                                       likely     GENDER:  Female│  842│   12%│
1091 │                                                           Total │ 1502│   22%│
1092 │                                      ╶──────────────────────────┼─────┼──────┤
1093 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
1094 │                                       likely     GENDER:  Female│ 1589│   23%│
1095 │                                                           Total │ 2763│   40%│
1096 │                                      ╶──────────────────────────┼─────┼──────┤
1097 │                                       Somewhat   S3a.     Male  │  640│    9%│
1098 │                                       unlikely   GENDER:  Female│  667│   10%│
1099 │                                                           Total │ 1307│   19%│
1100 │                                      ╶──────────────────────────┼─────┼──────┤
1101 │                                       Very       S3a.     Male  │  311│    5%│
1102 │                                       unlikely   GENDER:  Female│  298│    4%│
1103 │                                                           Total │  609│    9%│
1104 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1105 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
1106 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
1107 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
1108 │                                      ╶──────────────────────────┼─────┼──────┤
1109 │                                       Very       S3a.     Male  │ 1104│   16%│
1110 │                                       likely     GENDER:  Female│ 1715│   25%│
1111 │                                                           Total │ 2819│   41%│
1112 │                                      ╶──────────────────────────┼─────┼──────┤
1113 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
1114 │                                       likely     GENDER:  Female│ 1214│   18%│
1115 │                                                           Total │ 2417│   35%│
1116 │                                      ╶──────────────────────────┼─────┼──────┤
1117 │                                       Somewhat   S3a.     Male  │  262│    4%│
1118 │                                       unlikely   GENDER:  Female│  168│    2%│
1119 │                                                           Total │  430│    6%│
1120 │                                      ╶──────────────────────────┼─────┼──────┤
1121 │                                       Very       S3a.     Male  │   81│    1%│
1122 │                                       unlikely   GENDER:  Female│   59│    1%│
1123 │                                                           Total │  140│    2%│
1124 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1125 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
1126 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
1127 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
1128 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1129 │                                       Very       S3a.     Male  │  988│   14%│
1130 │                                       likely     GENDER:  Female│ 1049│   15%│
1131 │                                                           Total │ 2037│   30%│
1132 │                                      ╶──────────────────────────┼─────┼──────┤
1133 │                                       Somewhat   S3a.     Male  │  822│   12%│
1134 │                                       likely     GENDER:  Female│ 1210│   18%│
1135 │                                                           Total │ 2032│   30%│
1136 │                                      ╶──────────────────────────┼─────┼──────┤
1137 │                                       Somewhat   S3a.     Male  │  446│    7%│
1138 │                                       unlikely   GENDER:  Female│  548│    8%│
1139 │                                                           Total │  994│   15%│
1140 │                                      ╶──────────────────────────┼─────┼──────┤
1141 │                                       Very       S3a.     Male  │  268│    4%│
1142 │                                       unlikely   GENDER:  Female│  354│    5%│
1143 │                                                           Total │  622│    9%│
1144 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1145 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
1146 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
1147 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
1148 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
1149 │                                       Very       S3a.     Male  │  805│   12%│
1150 │                                       likely     GENDER:  Female│ 1029│   15%│
1151 │                                                           Total │ 1834│   27%│
1152 │                                      ╶──────────────────────────┼─────┼──────┤
1153 │                                       Somewhat   S3a.     Male  │  975│   14%│
1154 │                                       likely     GENDER:  Female│ 1332│   19%│
1155 │                                                           Total │ 2307│   34%│
1156 │                                      ╶──────────────────────────┼─────┼──────┤
1157 │                                       Somewhat   S3a.     Male  │  535│    8%│
1158 │                                       unlikely   GENDER:  Female│  560│    8%│
1159 │                                                           Total │ 1095│   16%│
1160 │                                      ╶──────────────────────────┼─────┼──────┤
1161 │                                       Very       S3a.     Male  │  270│    4%│
1162 │                                       unlikely   GENDER:  Female│  279│    4%│
1163 │                                                           Total │  549│    8%│
1164 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1165
1166                                   Custom Tables
1167 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
1168 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
1169 │                                 │ certain│likely│  likely │ unlikely│unlikely│
1170 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
1171 │                                 │        │ Table│         │         │        │
1172 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
1173 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1174 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
1175 │GENDER:        is it that drivers│        │      │         │         │        │
1176 │               who have had too  │        │      │         │         │        │
1177 │               much to drink to  │        │      │         │         │        │
1178 │               drive safely will │        │      │         │         │        │
1179 │               A. Get stopped by │        │      │         │         │        │
1180 │               the police?       │        │      │         │         │        │
1181 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1182 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
1183 │               is it that drivers│        │      │         │         │        │
1184 │               who have had too  │        │      │         │         │        │
1185 │               much to drink to  │        │      │         │         │        │
1186 │               drive safely will │        │      │         │         │        │
1187 │               A. Get stopped by │        │      │         │         │        │
1188 │               the police?       │        │      │         │         │        │
1189 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1190 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
1191 │               is it that drivers│        │      │         │         │        │
1192 │               who have had too  │        │      │         │         │        │
1193 │               much to drink to  │        │      │         │         │        │
1194 │               drive safely will │        │      │         │         │        │
1195 │               A. Get stopped by │        │      │         │         │        │
1196 │               the police?       │        │      │         │         │        │
1197 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1198 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
1199 │GENDER:        is it that drivers│        │      │         │         │        │
1200 │               who have had too  │        │      │         │         │        │
1201 │               much to drink to  │        │      │         │         │        │
1202 │               drive safely will │        │      │         │         │        │
1203 │               B. Have an        │        │      │         │         │        │
1204 │               accident?         │        │      │         │         │        │
1205 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1206 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
1207 │               is it that drivers│        │      │         │         │        │
1208 │               who have had too  │        │      │         │         │        │
1209 │               much to drink to  │        │      │         │         │        │
1210 │               drive safely will │        │      │         │         │        │
1211 │               B. Have an        │        │      │         │         │        │
1212 │               accident?         │        │      │         │         │        │
1213 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1214 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
1215 │               is it that drivers│        │      │         │         │        │
1216 │               who have had too  │        │      │         │         │        │
1217 │               much to drink to  │        │      │         │         │        │
1218 │               drive safely will │        │      │         │         │        │
1219 │               B. Have an        │        │      │         │         │        │
1220 │               accident?         │        │      │         │         │        │
1221 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1222 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
1223 │GENDER:        is it that drivers│        │      │         │         │        │
1224 │               who have had too  │        │      │         │         │        │
1225 │               much to drink to  │        │      │         │         │        │
1226 │               drive safely will │        │      │         │         │        │
1227 │               C. Be convicted   │        │      │         │         │        │
1228 │               for drunk driving?│        │      │         │         │        │
1229 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1230 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
1231 │               is it that drivers│        │      │         │         │        │
1232 │               who have had too  │        │      │         │         │        │
1233 │               much to drink to  │        │      │         │         │        │
1234 │               drive safely will │        │      │         │         │        │
1235 │               C. Be convicted   │        │      │         │         │        │
1236 │               for drunk driving?│        │      │         │         │        │
1237 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1238 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
1239 │               is it that drivers│        │      │         │         │        │
1240 │               who have had too  │        │      │         │         │        │
1241 │               much to drink to  │        │      │         │         │        │
1242 │               drive safely will │        │      │         │         │        │
1243 │               C. Be convicted   │        │      │         │         │        │
1244 │               for drunk driving?│        │      │         │         │        │
1245 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1246 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
1247 │GENDER:        is it that drivers│        │      │         │         │        │
1248 │               who have had too  │        │      │         │         │        │
1249 │               much to drink to  │        │      │         │         │        │
1250 │               drive safely will │        │      │         │         │        │
1251 │               D. Be arrested for│        │      │         │         │        │
1252 │               drunk driving?    │        │      │         │         │        │
1253 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1254 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
1255 │               is it that drivers│        │      │         │         │        │
1256 │               who have had too  │        │      │         │         │        │
1257 │               much to drink to  │        │      │         │         │        │
1258 │               drive safely will │        │      │         │         │        │
1259 │               D. Be arrested for│        │      │         │         │        │
1260 │               drunk driving?    │        │      │         │         │        │
1261 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
1262 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
1263 │               is it that drivers│        │      │         │         │        │
1264 │               who have had too  │        │      │         │         │        │
1265 │               much to drink to  │        │      │         │         │        │
1266 │               drive safely will │        │      │         │         │        │
1267 │               D. Be arrested for│        │      │         │         │        │
1268 │               drunk driving?    │        │      │         │         │        │
1269 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
1270 ])
1271 AT_CLEANUP
1272
1273 AT_SETUP([CTABLES nesting and scale variables])
1274 AT_KEYWORDS([nest nested])
1275 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1276 AT_DATA([ctables.sps],
1277 [[GET 'nhtsa.sav'.
1278 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
1279 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
1280 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
1281   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
1282 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
1283 ]])
1284 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1285                                   Custom Tables
1286 ╭─────────────────────────────────────────────────────────────────┬────────────╮
1287 │                                                                 │S3a. GENDER:│
1288 │                                                                 ├─────┬──────┤
1289 │                                                                 │ Male│Female│
1290 │                                                                 ├─────┼──────┤
1291 │                                                                 │ Mean│ Mean │
1292 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
1293 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
1294 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
1295 │                                                  week           │     │      │
1296 │                                                  Once a week or │   44│    54│
1297 │                                                  less           │     │      │
1298 │                                                  Only certain   │   34│    41│
1299 │                                                  times a year   │     │      │
1300 │                                                  Never          │   39│    55│
1301 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
1302
1303                                   Custom Tables
1304 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
1305 │                                                         │Minimum│Maximum│Mean│
1306 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1307 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
1308 │What is  GENDER:         months, has there been a        │       │       │    │
1309 │your                     time when you felt you          │       │       │    │
1310 │age?                     should cut down on your      No │     16│     86│  46│
1311 │                         drinking?                       │       │       │    │
1312 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1313 │                  Female 26. During the last 12       Yes│     16│     86│  43│
1314 │                         months, has there been a        │       │       │    │
1315 │                         time when you felt you          │       │       │    │
1316 │                         should cut down on your      No │     16│     86│  48│
1317 │                         drinking?                       │       │       │    │
1318 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
1319 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
1320 │What is  GENDER:         months, has there been a        │       │       │    │
1321 │your                     time when people criticized  No │     16│     86│  46│
1322 │age?                     your drinking?                  │       │       │    │
1323 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
1324 │                  Female 27. During the last 12       Yes│     17│     69│  37│
1325 │                         months, has there been a        │       │       │    │
1326 │                         time when people criticized  No │     16│     86│  48│
1327 │                         your drinking?                  │       │       │    │
1328 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
1329
1330                                   Custom Tables
1331 ╭─────────────────────────────┬────────────────────────────────────────────────╮
1332 │                             │S1. Including yourself, how many members of this│
1333 │                             │         household are age 16 or older?         │
1334 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
1335 │                             │      │      │      │      │      │      │ 6 or │
1336 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
1337 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1338 │                             │Column│Column│Column│Column│Column│Column│Column│
1339 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
1340 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
1341 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
1342 │SAMPLE      How      certain │      │      │      │      │      │      │      │
1343 │SOURCE:     likely           │      │      │      │      │      │      │      │
1344 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
1345 │            that     likely  │      │      │      │      │      │      │      │
1346 │            drivers          │      │      │      │      │      │      │      │
1347 │            who have         │      │      │      │      │      │      │      │
1348 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
1349 │            much to  likely  │      │      │      │      │      │      │      │
1350 │            drink to         │      │      │      │      │      │      │      │
1351 │            drive            │      │      │      │      │      │      │      │
1352 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
1353 │            will A.  unlikely│      │      │      │      │      │      │      │
1354 │            Get              │      │      │      │      │      │      │      │
1355 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
1356 │            by the   unlikely│      │      │      │      │      │      │      │
1357 │            police?          │      │      │      │      │      │      │      │
1358 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
1359
1360                                   Custom Tables
1361 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
1362 │                                                              │    │    Std   │
1363 │                                                              │Mean│ Deviation│
1364 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
1365 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
1366 │group           typical month did you have one or more        │    │          │
1367 │                alcoholic beverages to drink?                 │    │          │
1368 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1369 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
1370 │                typical month did you have one or more        │    │          │
1371 │                alcoholic beverages to drink?                 │    │          │
1372 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1373 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
1374 │                typical month did you have one or more        │    │          │
1375 │                alcoholic beverages to drink?                 │    │          │
1376 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1377 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
1378 │                typical month did you have one or more        │    │          │
1379 │                alcoholic beverages to drink?                 │    │          │
1380 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1381 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
1382 │                typical month did you have one or more        │    │          │
1383 │                alcoholic beverages to drink?                 │    │          │
1384 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
1385 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
1386 │       older    typical month did you have one or more        │    │          │
1387 │                alcoholic beverages to drink?                 │    │          │
1388 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
1389 ])
1390 AT_CLEANUP
1391
1392
1393 AT_SETUP([CTABLES SLABELS])
1394 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1395 AT_DATA([ctables.sps],
1396 [[GET 'nhtsa.sav'.
1397 CTABLES /TABLE qn1 [COUNT COLPCT].
1398 CTABLES /TABLE qn1 [COUNT COLPCT]
1399     /SLABELS POSITION=ROW.
1400 CTABLES /TABLE qn1 [COUNT COLPCT]
1401     /SLABELS POSITION=ROW VISIBLE=NO.
1402 ]])
1403 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1404                                   Custom Tables
1405 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
1406 │                                                                │     │ Column│
1407 │                                                                │Count│   %   │
1408 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
1409 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
1410 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
1411 │                                             Once a week or less│  361│   5.2%│
1412 │                                             Only certain times │  130│   1.9%│
1413 │                                             a year             │     │       │
1414 │                                             Never              │  540│   7.7%│
1415 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
1416
1417                                   Custom Tables
1418 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1419 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
1420 │other motor vehicle?                                             Column │66.9%│
1421 │                                                                 %      │     │
1422 │                                            ╶───────────────────────────┼─────┤
1423 │                                             Several days a week Count  │ 1274│
1424 │                                                                 Column │18.3%│
1425 │                                                                 %      │     │
1426 │                                            ╶───────────────────────────┼─────┤
1427 │                                             Once a week or less Count  │  361│
1428 │                                                                 Column │ 5.2%│
1429 │                                                                 %      │     │
1430 │                                            ╶───────────────────────────┼─────┤
1431 │                                             Only certain times  Count  │  130│
1432 │                                             a year              Column │ 1.9%│
1433 │                                                                 %      │     │
1434 │                                            ╶───────────────────────────┼─────┤
1435 │                                             Never               Count  │  540│
1436 │                                                                 Column │ 7.7%│
1437 │                                                                 %      │     │
1438 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1439
1440                                   Custom Tables
1441 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1442 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
1443 │motor vehicle?                                                          │66.9%│
1444 │                                                   Several days a week  │ 1274│
1445 │                                                                        │18.3%│
1446 │                                                   Once a week or less  │  361│
1447 │                                                                        │ 5.2%│
1448 │                                                   Only certain times a │  130│
1449 │                                                   year                 │ 1.9%│
1450 │                                                   Never                │  540│
1451 │                                                                        │ 7.7%│
1452 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1453 ])
1454 AT_CLEANUP
1455
1456 AT_SETUP([CTABLES simple totals])
1457 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1458 AT_DATA([ctables.sps],
1459 [[GET 'nhtsa.sav'.
1460 CTABLES /TABLE=qn17
1461     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
1462 DESCRIPTIVES qn18/STATISTICS=MEAN.
1463 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
1464     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
1465 ]])
1466 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
1467                                   Custom Tables
1468 ╭────────────────────────────────────────────────────────────────────────┬─────╮
1469 │                                                                        │Count│
1470 ├────────────────────────────────────────────────────────────────────────┼─────┤
1471 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
1472 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
1473 │                                                      Light beer        │  620│
1474 │                                                      Wine              │ 1418│
1475 │                                                      Wine coolers      │  137│
1476 │                                                      Hard liquor or    │  888│
1477 │                                                      mixed drinks      │     │
1478 │                                                      Flavored malt     │   83│
1479 │                                                      drinks            │     │
1480 │                                                      Number responding │ 4221│
1481 ╰────────────────────────────────────────────────────────────────────────┴─────╯
1482
1483                              Descriptive Statistics
1484 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
1485 │                                                                    │  N │Mean│
1486 ├────────────────────────────────────────────────────────────────────┼────┼────┤
1487 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
1488 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
1489 │Valid N (listwise)                                                  │6999│    │
1490 │Missing N (listwise)                                                │2781│    │
1491 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
1492
1493                                   Custom Tables
1494 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
1495 │                                                      │    │     │ Valid│Total│
1496 │                                                      │Mean│Count│   N  │  N  │
1497 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1498 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
1499 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1500 │                you usually drink per sitting?        │    │     │      │     │
1501 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1502 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
1503 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1504 │                you usually drink per sitting?        │    │     │      │     │
1505 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1506 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
1507 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1508 │                you usually drink per sitting?        │    │     │      │     │
1509 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1510 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
1511 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1512 │                you usually drink per sitting?        │    │     │      │     │
1513 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
1514 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
1515 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
1516 │                you usually drink per sitting?        │    │     │      │     │
1517 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
1518 ])
1519 AT_CLEANUP
1520
1521 AT_SETUP([CTABLES subtotals])
1522 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1523 AT_DATA([ctables.sps],
1524 [[GET 'nhtsa.sav'.
1525 CTABLES /TABLE=qn105ba BY qns1
1526     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1527 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
1528     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
1529 CTABLES /TABLE=qn105ba BY qns1
1530     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
1531     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
1532 ]])
1533 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1534                                                       Custom Tables
1535 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1536 │                                                         │ S1. Including yourself, how many members of this household │
1537 │                                                         │                    are age 16 or older?                    │
1538 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1539 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1540 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1541 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1542 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1543 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1544 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1545 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1546 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1547 │                                              likely     │       │       │         │       │        │      │          │
1548 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1549 │                                              unlikely   │       │       │         │       │        │      │          │
1550 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1551 │                                              unlikely   │       │       │         │       │        │      │          │
1552 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1553
1554                                                       Custom Tables
1555 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
1556 │                                                        │  S1. Including yourself, how many members of this household │
1557 │                                                        │                     are age 16 or older?                    │
1558 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
1559 │                                                        │        │        │        │        │       │        │  6 or  │
1560 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
1561 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1562 │                                                        │        │        │        │        │ Column│        │        │
1563 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
1564 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
1565 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
1566 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
1567 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
1568 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
1569 │                                             likely     │        │        │        │        │       │        │        │
1570 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
1571 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
1572 │                                             unlikely   │        │        │        │        │       │        │        │
1573 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
1574 │                                             unlikely   │        │        │        │        │       │        │        │
1575 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
1576 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
1577
1578                                                       Custom Tables
1579 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
1580 │                                                         │ S1. Including yourself, how many members of this household │
1581 │                                                         │                    are age 16 or older?                    │
1582 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
1583 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
1584 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1585 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
1586 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
1587 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
1588 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
1589 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
1590 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
1591 │                                              likely     │       │       │         │       │        │      │          │
1592 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
1593 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
1594 │                                              unlikely   │       │       │         │       │        │      │          │
1595 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
1596 │                                              unlikely   │       │       │         │       │        │      │          │
1597 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
1598 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
1599 ])
1600 AT_CLEANUP
1601
1602 AT_SETUP([CTABLES PCOMPUTE])
1603 AT_KEYWORDS([postcompute])
1604 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1605 AT_DATA([ctables.sps],
1606 [[GET 'nhtsa.sav'.
1607 CTABLES
1608     /PCOMPUTE &x=EXPR([3] + [4])
1609     /PCOMPUTE &y=EXPR([4] + [5])
1610     /PPROPERTIES &x LABEL='3+4' FORMAT=COUNT F8.2
1611     /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]'
1612     /TABLE=qn105ba [COUNT, ROWPCT] BY qns1
1613     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL] TOTAL=YES
1614
1615 * Adding HIDESOURCECATS=YES for one PPROPERTIES.
1616 CTABLES
1617     /PCOMPUTE &x=EXPR([3] + [4])
1618     /PCOMPUTE &y=EXPR([4] + [5])
1619     /PPROPERTIES &x LABEL='3+4' FORMAT=COUNT F8.2
1620     /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]' HIDESOURCECATS=YES
1621     /TABLE=qn105ba [COUNT, ROWPCT] BY qns1
1622     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL] TOTAL=YES
1623 ]])
1624 AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
1625                                                                 Custom Tables
1626 ╭───────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1627 │                   │                    S1. Including yourself, how many members of this household are age 16 or older?                   │
1628 │                   ├───────────┬───────────┬───────────┬───────────┬──────────┬──────────┬────────────┬──────────┬───────────┬────────────┤
1629 │                   │     1     │     2     │  Subtotal │     3     │     4    │     5    │     3+4    │    4+5   │  Subtotal │    Total   │
1630 │                   ├─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┼─────┬────┼─────┬────┼──────┬─────┼─────┬────┼─────┬─────┼─────┬──────┤
1631 │                   │     │     │     │     │     │     │     │     │     │ Row│     │ Row│      │     │     │ Row│     │     │     │      │
1632 │                   │Count│Row %│Count│Row %│Count│Row %│Count│Row %│Count│  % │Count│  % │ Count│Row %│Count│  % │Count│Row %│Count│ Row %│
1633 ├───────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼────┼─────┼────┼──────┼─────┼─────┼────┼─────┼─────┼─────┼──────┤
1634 │105b. How  Almost  │  147│30.3%│  246│50.7%│  393│81.0%│   62│12.8%│   19│3.9%│   11│2.3%│ 81.00│16.7%│   30│6.2%│   92│19.0%│  485│100.0%│
1635 │likely is  certain │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1636 │it that            │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1637 │drivers    Very    │  384│34.3%│  552│49.2%│  936│83.5%│  120│10.7%│   51│4.5%│   14│1.2%│171.00│15.3%│   65│5.8%│  185│16.5%│ 1121│100.0%│
1638 │who have   likely  │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1639 │had too            │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1640 │much to    Somewhat│  590│27.8%│ 1249│58.8%│ 1839│86.6%│  193│ 9.1%│   72│3.4%│   20│ .9%│265.00│12.5%│   92│4.3%│  285│13.4%│ 2124│100.0%│
1641 │drink to   likely  │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1642 │drive              │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1643 │safely     Somewhat│  278│26.6%│  647│61.8%│  925│88.3%│   84│ 8.0%│   32│3.1%│    6│ .6%│116.00│11.1%│   38│3.6%│  122│11.7%│ 1047│100.0%│
1644 │will A.    unlikely│     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1645 │Get                │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1646 │stopped by Very    │  141│28.5%│  290│58.7%│  431│87.2%│   41│ 8.3%│   18│3.6%│    4│ .8%│ 59.00│11.9%│   22│4.5%│   63│12.8%│  494│100.0%│
1647 │the        unlikely│     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1648 │police?            │     │     │     │     │     │     │     │     │     │    │     │    │      │     │     │    │     │     │     │      │
1649 ╰───────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴────┴─────┴────┴──────┴─────┴─────┴────┴─────┴─────┴─────┴──────╯
1650
1651                                                                 Custom Tables
1652 ╭─────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────╮
1653 │                                         │         S1. Including yourself, how many members of this household are age 16 or older?        │
1654 │                                         ├───────────┬───────────┬───────────┬───────────┬────────────┬──────────┬───────────┬────────────┤
1655 │                                         │     1     │     2     │  Subtotal │     3     │     3+4    │    4+5   │  Subtotal │    Total   │
1656 │                                         ├─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┼──────┬─────┼─────┬────┼─────┬─────┼─────┬──────┤
1657 │                                         │     │     │     │     │     │     │     │     │      │     │     │ Row│     │     │     │      │
1658 │                                         │Count│Row %│Count│Row %│Count│Row %│Count│Row %│ Count│Row %│Count│  % │Count│Row %│Count│ Row %│
1659 ├─────────────────────────────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼──────┼─────┼─────┼────┼─────┼─────┼─────┼──────┤
1660 │105b. How likely is it that    Almost    │  147│30.3%│  246│50.7%│  393│81.0%│   62│12.8%│ 81.00│16.7%│   30│6.2%│   92│19.0%│  485│100.0%│
1661 │drivers who have had too much  certain   │     │     │     │     │     │     │     │     │      │     │     │    │     │     │     │      │
1662 │to drink to drive safely will  Very      │  384│34.3%│  552│49.2%│  936│83.5%│  120│10.7%│171.00│15.3%│   65│5.8%│  185│16.5%│ 1121│100.0%│
1663 │A. Get stopped by the police?  likely    │     │     │     │     │     │     │     │     │      │     │     │    │     │     │     │      │
1664 │                               Somewhat  │  590│27.8%│ 1249│58.8%│ 1839│86.6%│  193│ 9.1%│265.00│12.5%│   92│4.3%│  285│13.4%│ 2124│100.0%│
1665 │                               likely    │     │     │     │     │     │     │     │     │      │     │     │    │     │     │     │      │
1666 │                               Somewhat  │  278│26.6%│  647│61.8%│  925│88.3%│   84│ 8.0%│116.00│11.1%│   38│3.6%│  122│11.7%│ 1047│100.0%│
1667 │                               unlikely  │     │     │     │     │     │     │     │     │      │     │     │    │     │     │     │      │
1668 │                               Very      │  141│28.5%│  290│58.7%│  431│87.2%│   41│ 8.3%│ 59.00│11.9%│   22│4.5%│   63│12.8%│  494│100.0%│
1669 │                               unlikely  │     │     │     │     │     │     │     │     │      │     │     │    │     │     │     │      │
1670 ╰─────────────────────────────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴──────┴─────┴─────┴────┴─────┴─────┴─────┴──────╯
1671 ])
1672 AT_CLEANUP
1673
1674 AT_SETUP([CTABLES PCOMPUTE - OTHERNM and MISSING])
1675 AT_KEYWORDS([postcompute])
1676 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1677 AT_DATA([ctables.sps],
1678 [[GET 'nhtsa.sav'.
1679 CTABLES
1680     /PCOMPUTE &x=EXPR(OTHERNM)
1681     /PCOMPUTE &y=EXPR(MISSING)
1682     /PPROPERTIES &x LABEL='Drivers'
1683     /PPROPERTIES &y LABEL='Missing Values 2'
1684     /TABLE=qn1 BY qns3a
1685     /CATEGORIES VARIABLES=qn1 [OTHERNM, 5, &x, SUBTOTAL='Valid Values', MISSING, SUBTOTAL='Missing Values', &y]
1686 ]])
1687 AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
1688                                               Custom Tables
1689 ╭──────────────────────────────────────────────────────────────────────────────────────────┬────────────╮
1690 │                                                                                          │S3a. GENDER:│
1691 │                                                                                          ├─────┬──────┤
1692 │                                                                                          │ Male│Female│
1693 │                                                                                          ├─────┼──────┤
1694 │                                                                                          │Count│ Count│
1695 ├──────────────────────────────────────────────────────────────────────────────────────────┼─────┼──────┤
1696 │ 1. How often do you usually drive a car or other motor vehicle? Every day                │ 2305│  2362│
1697 │                                                                 Several days a week      │  440│   834│
1698 │                                                                 Once a week or less      │  125│   236│
1699 │                                                                 Only certain times a year│   58│    72│
1700 │                                                                 Never                    │  192│   348│
1701 │                                                                 Drivers                  │ 2928│  3504│
1702 │                                                                 Valid Values             │ 3120│  3852│
1703 │                                                                 Don't know               │    3│     5│
1704 │                                                                 Refused                  │    9│    10│
1705 │                                                                 Missing Values           │   12│    15│
1706 │                                                                 Missing Values 2         │   12│    15│
1707 ╰──────────────────────────────────────────────────────────────────────────────────────────┴─────┴──────╯
1708 ])
1709 AT_CLEANUP
1710
1711 AT_SETUP([CTABLES PCOMPUTE - THRU])
1712 AT_KEYWORDS([postcompute])
1713 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1714 AT_DATA([ctables.sps],
1715 [[GET 'nhtsa.sav'.
1716 CTABLES
1717     /PCOMPUTE &x=EXPR([1 THRU 2])
1718     /PCOMPUTE &y=EXPR([3 THRU 4])
1719     /PCOMPUTE &z=EXPR([5] + MISSING)
1720     /PPROPERTIES &x LABEL='Frequent Drivers'
1721     /PPROPERTIES &y LABEL='Infrequent Drivers'
1722     /PPROPERTIES &z LABEL='Not Drivers or Missing'
1723     /TABLE=qn1 BY qns3a
1724     /CATEGORIES VARIABLES=qn1 [1 THRU 2, &x, 3 THRU 4, &y, SUBTOTAL='Drivers', 5, MISSING, &z]
1725 ]])
1726 AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
1727                                               Custom Tables
1728 ╭──────────────────────────────────────────────────────────────────────────────────────────┬────────────╮
1729 │                                                                                          │S3a. GENDER:│
1730 │                                                                                          ├─────┬──────┤
1731 │                                                                                          │ Male│Female│
1732 │                                                                                          ├─────┼──────┤
1733 │                                                                                          │Count│ Count│
1734 ├──────────────────────────────────────────────────────────────────────────────────────────┼─────┼──────┤
1735 │ 1. How often do you usually drive a car or other motor vehicle? Every day                │ 2305│  2362│
1736 │                                                                 Several days a week      │  440│   834│
1737 │                                                                 Frequent Drivers         │ 2745│  3196│
1738 │                                                                 Once a week or less      │  125│   236│
1739 │                                                                 Only certain times a year│   58│    72│
1740 │                                                                 Infrequent Drivers       │  183│   308│
1741 │                                                                 Drivers                  │ 2928│  3504│
1742 │                                                                 Never                    │  192│   348│
1743 │                                                                 Don't know               │    3│     5│
1744 │                                                                 Refused                  │    9│    10│
1745 │                                                                 Not Drivers or Missing   │  204│   363│
1746 ╰──────────────────────────────────────────────────────────────────────────────────────────┴─────┴──────╯
1747 ])
1748 AT_CLEANUP
1749
1750 dnl I'm not sure that this is the correct behavior (see
1751 dnl https://mail.gnu.org/archive/html/pspp-users/2022-07/msg00002.html)
1752 dnl but at least this test will notify us if the behavior changes.
1753 AT_SETUP([CTABLES intersecting PCOMPUTEs])
1754 AT_KEYWORDS([PCOMPUTE postcompute])
1755 AT_DATA([ctables.sps],
1756 [[DATA LIST LIST NOTABLE/x y z.
1757 WEIGHT by z.
1758 FORMATS ALL (F1.0).
1759 VARIABLE LEVEL x y (NOMINAL).
1760 BEGIN DATA.
1761 1 4 5
1762 1 5 2
1763 1 6 9
1764 2 4 2
1765 2 5 3
1766 2 6 4
1767 3 4 1
1768 3 5 6
1769 3 6 1
1770 END DATA.
1771
1772 CTABLES
1773     /PCOMPUTE &a = EXPR([1] + [2])
1774     /PCOMPUTE &b = EXPR([2] + [3])
1775     /PCOMPUTE &c = EXPR([4] * [5])
1776     /PCOMPUTE &d = EXPR([5] * [6])
1777     /TABLE x BY y
1778     /CATEGORIES VARIABLES=x [1, &a, 2, &b, 3]
1779     /CATEGORIES VARIABLES=y [4, &c, 5, &d, 6].
1780 ]])
1781 AT_CHECK([pspp ctables.sps -O box=unicode], [0],
1782 [[                   Custom Tables
1783 ╭───────────┬─────────────────────────────────────╮
1784 │           │                  y                  │
1785 │           ├─────┬─────────┬─────┬─────────┬─────┤
1786 │           │  4  │[4] * [5]│  5  │[5] * [6]│  6  │
1787 │           ├─────┼─────────┼─────┼─────────┼─────┤
1788 │           │Count│  Count  │Count│  Count  │Count│
1789 ├───────────┼─────┼─────────┼─────┼─────────┼─────┤
1790 │x 1        │    5│       10│    2│       18│    9│
1791 │  [1] + [2]│    7│        .│    5│        .│   13│
1792 │  2        │    2│        6│    3│       12│    4│
1793 │  [2] + [3]│    3│        .│    9│        .│    5│
1794 │  3        │    1│        6│    6│        6│    1│
1795 ╰───────────┴─────┴─────────┴─────┴─────────┴─────╯
1796 ]])
1797 AT_CLEANUP
1798
1799 AT_SETUP([CTABLES string and date and time])
1800
1801 weight=1
1802 for gender in F M; do
1803     for month in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
1804         for wkday in Sun Mon Tue Wed Thu Fri Sat Sun; do
1805             printf "$weight $gender $month $wkday\n"
1806             weight=$(expr \( $weight + 3 \) % 7 + 2)
1807         done
1808     done
1809 done > ctables.txt
1810
1811 AT_DATA([ctables.sps],
1812 [[DATA LIST LIST NOTABLE FILE='ctables.txt'
1813     /w (F5.0) gender (A1) fmon (MONTH3) fday (WKDAY3).
1814 WEIGHT by w.
1815 VARIABLE LEVEL w (SCALE).
1816 VARIABLE LEVEL gender fmon fday (NOMINAL).
1817 VARIABLE LABEL
1818   gender 'Gender'
1819   fmon 'Favorite month'
1820   fday 'Favorite day of the week'.
1821 VALUE LABELS /gender 'M' 'Male' 'F' 'Female'.
1822 CTABLES
1823     /PCOMPUTE &q2 = EXPR(['APR' THRU 'June'])
1824     /PPROPERTIES &q2 LABEL='Q2'
1825     /PCOMPUTE &weekend = EXPR(['sun'] + ['Sat'])
1826     /PPROPERTIES &weekend LABEL='Weekend'
1827     /TABLE fmon BY gender > fday
1828     /CATEGORIES VARIABLES=fmon ['JAN', 'FEB', 'Mar', SUBTOTAL="Q1",
1829                                 4 THRU 6, &q2,
1830                                 'JUL' THRU 'sep', SUBTOTAL="Q3",
1831                                 OTHERNM, SUBTOTAL='Q4']
1832     /CATEGORIES VARIABLES=gender ['M', 'F']
1833     /CATEGORIES VARIABLE=fday ['Sun', 2 THRU 6, 'Sat', &weekend] TOTAL=YES
1834     /SLABELS VISIBLE=NO.
1835 ]])
1836 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1837                                               Custom Tables
1838 ╭──────────────────┬───────────────────────────────────────────────────────────────────────────────────╮
1839 │                  │                                       Gender                                      │
1840 │                  ├─────────────────────────────────────────┬─────────────────────────────────────────┤
1841 │                  │                   Male                  │                  Female                 │
1842 │                  ├─────────────────────────────────────────┼─────────────────────────────────────────┤
1843 │                  │         Favorite day of the week        │         Favorite day of the week        │
1844 │                  ├───┬───┬───┬───┬───┬───┬───┬───────┬─────┼───┬───┬───┬───┬───┬───┬───┬───────┬─────┤
1845 │                  │SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│
1846 ├──────────────────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┤
1847 │Favorite month JAN│ 10│  3│  8│  6│  4│  2│  7│     17│   40│  9│  6│  4│  2│  7│  5│  3│     12│   36│
1848 │               FEB│  6│  8│  6│  4│  2│  7│  5│     11│   38│ 12│  4│  2│  7│  5│  3│  8│     20│   41│
1849 │               MAR│ 16│  6│  4│  2│  7│  5│  3│     19│   43│  8│  2│  7│  5│  3│  8│  6│     14│   39│
1850 │               Q1 │ 32│ 17│ 18│ 12│ 13│ 14│ 15│       │     │ 29│ 12│ 13│ 14│ 15│ 16│ 17│       │     │
1851 │               APR│ 12│  4│  2│  7│  5│  3│  8│     20│   41│  4│  7│  5│  3│  8│  6│  4│      8│   37│
1852 │               MAY│  8│  2│  7│  5│  3│  8│  6│     14│   39│ 14│  5│  3│  8│  6│  4│  2│     16│   42│
1853 │               JUN│  4│  7│  5│  3│  8│  6│  4│      8│   37│ 10│  3│  8│  6│  4│  2│  7│     17│   40│
1854 │               Q2 │ 24│ 13│ 14│ 15│ 16│ 17│ 18│      .│     │ 28│ 15│ 16│ 17│ 18│ 12│ 13│      .│     │
1855 │               JUL│ 14│  5│  3│  8│  6│  4│  2│     16│   42│  6│  8│  6│  4│  2│  7│  5│     11│   38│
1856 │               AUG│ 10│  3│  8│  6│  4│  2│  7│     17│   40│ 16│  6│  4│  2│  7│  5│  3│     19│   43│
1857 │               SEP│  6│  8│  6│  4│  2│  7│  5│     11│   38│ 12│  4│  2│  7│  5│  3│  8│     20│   41│
1858 │               Q3 │ 54│ 29│ 31│ 33│ 28│ 30│ 32│       │     │ 62│ 33│ 28│ 30│ 32│ 27│ 29│       │     │
1859 │               OCT│ 16│  6│  4│  2│  7│  5│  3│     19│   43│  8│  2│  7│  5│  3│  8│  6│     14│   39│
1860 │               NOV│ 12│  4│  2│  7│  5│  3│  8│     20│   41│  4│  7│  5│  3│  8│  6│  4│      8│   37│
1861 │               DEC│  8│  2│  7│  5│  3│  8│  6│     14│   39│ 14│  5│  3│  8│  6│  4│  2│     16│   42│
1862 │               Q4 │ 36│ 12│ 13│ 14│ 15│ 16│ 17│       │     │ 26│ 14│ 15│ 16│ 17│ 18│ 12│       │     │
1863 ╰──────────────────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────╯
1864 ])
1865 AT_CLEANUP
1866
1867 AT_SETUP([CTABLES CLABELS])
1868 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
1869 AT_DATA([ctables.sps],
1870 [[GET 'nhtsa.sav'.
1871 CTABLES /TABLE AgeGroup BY qns3a.
1872 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1873 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1874 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
1875 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
1876 ]])
1877 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
1878              Custom Tables
1879 ╭───────────────────────┬────────────╮
1880 │                       │S3a. GENDER:│
1881 │                       ├─────┬──────┤
1882 │                       │ Male│Female│
1883 │                       ├─────┼──────┤
1884 │                       │Count│ Count│
1885 ├───────────────────────┼─────┼──────┤
1886 │Age group 15 or younger│    0│     0│
1887 │          16 to 25     │  594│   505│
1888 │          26 to 35     │  476│   491│
1889 │          36 to 45     │  489│   548│
1890 │          46 to 55     │  526│   649│
1891 │          56 to 65     │  516│   731│
1892 │          66 or older  │  531│   943│
1893 ╰───────────────────────┴─────┴──────╯
1894
1895                                                       Custom Tables
1896 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
1897 │       │                                                 S3a. GENDER:                                                 │
1898 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
1899 │       │                         Male                         │                         Female                        │
1900 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
1901 │       │  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 │
1902 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
1903 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1904 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
1905 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
1906 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
1907 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
1908 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
1909
1910                 Custom Tables
1911 ╭──────────────────────────────┬────────────╮
1912 │                              │S3a. GENDER:│
1913 │                              ├────────────┤
1914 │                              │    Count   │
1915 ├──────────────────────────────┼────────────┤
1916 │Age group 15 or younger Male  │           0│
1917 │                        Female│           0│
1918 │         ╶────────────────────┼────────────┤
1919 │          16 to 25      Male  │         594│
1920 │                        Female│         505│
1921 │         ╶────────────────────┼────────────┤
1922 │          26 to 35      Male  │         476│
1923 │                        Female│         491│
1924 │         ╶────────────────────┼────────────┤
1925 │          36 to 45      Male  │         489│
1926 │                        Female│         548│
1927 │         ╶────────────────────┼────────────┤
1928 │          46 to 55      Male  │         526│
1929 │                        Female│         649│
1930 │         ╶────────────────────┼────────────┤
1931 │          56 to 65      Male  │         516│
1932 │                        Female│         731│
1933 │         ╶────────────────────┼────────────┤
1934 │          66 or older   Male  │         531│
1935 │                        Female│         943│
1936 ╰──────────────────────────────┴────────────╯
1937
1938       Custom Tables
1939 15 or younger
1940 ╭─────────┬────────────╮
1941 │         │S3a. GENDER:│
1942 │         ├─────┬──────┤
1943 │         │ Male│Female│
1944 │         ├─────┼──────┤
1945 │         │Count│ Count│
1946 ├─────────┼─────┼──────┤
1947 │Age group│    0│     0│
1948 ╰─────────┴─────┴──────╯
1949
1950       Custom Tables
1951 16 to 25
1952 ╭─────────┬────────────╮
1953 │         │S3a. GENDER:│
1954 │         ├─────┬──────┤
1955 │         │ Male│Female│
1956 │         ├─────┼──────┤
1957 │         │Count│ Count│
1958 ├─────────┼─────┼──────┤
1959 │Age group│  594│   505│
1960 ╰─────────┴─────┴──────╯
1961
1962       Custom Tables
1963 26 to 35
1964 ╭─────────┬────────────╮
1965 │         │S3a. GENDER:│
1966 │         ├─────┬──────┤
1967 │         │ Male│Female│
1968 │         ├─────┼──────┤
1969 │         │Count│ Count│
1970 ├─────────┼─────┼──────┤
1971 │Age group│  476│   491│
1972 ╰─────────┴─────┴──────╯
1973
1974       Custom Tables
1975 36 to 45
1976 ╭─────────┬────────────╮
1977 │         │S3a. GENDER:│
1978 │         ├─────┬──────┤
1979 │         │ Male│Female│
1980 │         ├─────┼──────┤
1981 │         │Count│ Count│
1982 ├─────────┼─────┼──────┤
1983 │Age group│  489│   548│
1984 ╰─────────┴─────┴──────╯
1985
1986       Custom Tables
1987 46 to 55
1988 ╭─────────┬────────────╮
1989 │         │S3a. GENDER:│
1990 │         ├─────┬──────┤
1991 │         │ Male│Female│
1992 │         ├─────┼──────┤
1993 │         │Count│ Count│
1994 ├─────────┼─────┼──────┤
1995 │Age group│  526│   649│
1996 ╰─────────┴─────┴──────╯
1997
1998       Custom Tables
1999 56 to 65
2000 ╭─────────┬────────────╮
2001 │         │S3a. GENDER:│
2002 │         ├─────┬──────┤
2003 │         │ Male│Female│
2004 │         ├─────┼──────┤
2005 │         │Count│ Count│
2006 ├─────────┼─────┼──────┤
2007 │Age group│  516│   731│
2008 ╰─────────┴─────┴──────╯
2009
2010       Custom Tables
2011 66 or older
2012 ╭─────────┬────────────╮
2013 │         │S3a. GENDER:│
2014 │         ├─────┬──────┤
2015 │         │ Male│Female│
2016 │         ├─────┼──────┤
2017 │         │Count│ Count│
2018 ├─────────┼─────┼──────┤
2019 │Age group│  531│   943│
2020 ╰─────────┴─────┴──────╯
2021
2022              Custom Tables
2023 Male
2024 ╭───────────────────────┬────────────╮
2025 │                       │S3a. GENDER:│
2026 │                       ├────────────┤
2027 │                       │    Count   │
2028 ├───────────────────────┼────────────┤
2029 │Age group 15 or younger│           0│
2030 │          16 to 25     │         594│
2031 │          26 to 35     │         476│
2032 │          36 to 45     │         489│
2033 │          46 to 55     │         526│
2034 │          56 to 65     │         516│
2035 │          66 or older  │         531│
2036 ╰───────────────────────┴────────────╯
2037
2038              Custom Tables
2039 Female
2040 ╭───────────────────────┬────────────╮
2041 │                       │S3a. GENDER:│
2042 │                       ├────────────┤
2043 │                       │    Count   │
2044 ├───────────────────────┼────────────┤
2045 │Age group 15 or younger│           0│
2046 │          16 to 25     │         505│
2047 │          26 to 35     │         491│
2048 │          36 to 45     │         548│
2049 │          46 to 55     │         649│
2050 │          56 to 65     │         731│
2051 │          66 or older  │         943│
2052 ╰───────────────────────┴────────────╯
2053 ])
2054 AT_CLEANUP
2055
2056 AT_SETUP([CTABLES missing values])
2057 AT_DATA([ctables.sps],
2058 [[DATA LIST LIST NOTABLE/x y.
2059 BEGIN DATA.
2060 1 1
2061 1 2
2062 1 3
2063 1 4
2064 1 5
2065 1 .
2066 2 1
2067 2 2
2068 2 3
2069 2 4
2070 2 5
2071 2 .
2072 3 1
2073 3 2
2074 3 3
2075 3 4
2076 3 5
2077 3 .
2078 4 1
2079 4 2
2080 4 3
2081 4 4
2082 4 5
2083 4 .
2084 5 1
2085 5 2
2086 5 3
2087 5 4
2088 5 5
2089 5 .
2090 . 1
2091 . 2
2092 . 3
2093 . 4
2094 . 5
2095 . .
2096 END DATA.
2097 MISSING VALUES x (1, 2) y (2, 3).
2098 VARIABLE LEVEL ALL (NOMINAL).
2099
2100 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
2101                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
2102     /CATEGORIES VARIABLES=ALL TOTAL=YES.
2103 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
2104                  TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
2105     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
2106 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
2107                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
2108     /CATEGORIES VARIABLES=ALL TOTAL=YES
2109     /SLABELS POSITION=ROW.
2110 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
2111                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
2112     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
2113     /SLABELS POSITION=ROW.
2114 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
2115                       TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
2116     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
2117     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
2118     /SLABELS POSITION=ROW.
2119 ]])
2120 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2121                                Custom Tables
2122 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
2123 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
2124 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
2125 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
2126 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
2127 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
2128 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
2129 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
2130 dnl Note that Column Total N % doesn't add up to 100 because missing
2131 dnl values are included in the total but not shown as a category and this
2132 dnl is expected behavior.
2133
2134                                Custom Tables
2135 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
2136 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
2137 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
2138 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
2139 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
2140 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
2141 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
2142 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
2143 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
2144 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
2145 dnl Note that Column Total N % doesn't add up to 100 because system-missing
2146 dnl values are included in the total but not shown as a category and this
2147 dnl is expected behavior.
2148
2149                      Custom Tables
2150 ╭────────────────────────┬───────────────────────────╮
2151 │                        │             y             │
2152 │                        ├──────┬──────┬──────┬──────┤
2153 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
2154 ├────────────────────────┼──────┼──────┼──────┼──────┤
2155 │x 3.00  Count           │     1│     1│     1│     3│
2156 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
2157 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
2158 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
2159 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
2160 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
2161 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
2162 │        Valid N         │      │      │      │     3│
2163 │        Total N         │      │      │      │     6│
2164 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
2165 │  4.00  Count           │     1│     1│     1│     3│
2166 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
2167 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
2168 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
2169 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
2170 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
2171 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
2172 │        Valid N         │      │      │      │     3│
2173 │        Total N         │      │      │      │     6│
2174 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
2175 │  5.00  Count           │     1│     1│     1│     3│
2176 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
2177 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
2178 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
2179 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
2180 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
2181 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
2182 │        Valid N         │      │      │      │     3│
2183 │        Total N         │      │      │      │     6│
2184 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
2185 │  Total Count           │     3│     3│     3│     9│
2186 │        Column %        │100.0%│100.0%│100.0%│     .│
2187 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
2188 │        Column Total N %│100.0%│100.0%│100.0%│     .│
2189 │        Row %           │     .│     .│     .│     .│
2190 │        Row Valid N %   │     .│     .│     .│     .│
2191 │        Row Total N %   │     .│     .│     .│     .│
2192 │        Valid N         │     3│     3│     3│     9│
2193 │        Total N         │     6│     6│     6│    36│
2194 ╰────────────────────────┴──────┴──────┴──────┴──────╯
2195
2196                             Custom Tables
2197 ╭────────────────────────┬─────────────────────────────────────────╮
2198 │                        │                    y                    │
2199 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
2200 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
2201 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2202 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
2203 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2204 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
2205 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2206 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2207 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2208 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2209 │        Valid N         │      │      │      │      │      │     0│
2210 │        Total N         │      │      │      │      │      │     6│
2211 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2212 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
2213 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2214 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
2215 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2216 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2217 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2218 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2219 │        Valid N         │      │      │      │      │      │     0│
2220 │        Total N         │      │      │      │      │      │     6│
2221 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2222 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
2223 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2224 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2225 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2226 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2227 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2228 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2229 │        Valid N         │      │      │      │      │      │     3│
2230 │        Total N         │      │      │      │      │      │     6│
2231 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2232 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
2233 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2234 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2235 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2236 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2237 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2238 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2239 │        Valid N         │      │      │      │      │      │     3│
2240 │        Total N         │      │      │      │      │      │     6│
2241 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2242 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
2243 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2244 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
2245 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
2246 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
2247 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
2248 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2249 │        Valid N         │      │      │      │      │      │     3│
2250 │        Total N         │      │      │      │      │      │     6│
2251 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
2252 │  Total Count           │     5│     5│     5│     5│     5│    25│
2253 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2254 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
2255 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
2256 │        Row %           │     .│     .│     .│     .│     .│     .│
2257 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
2258 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
2259 │        Valid N         │     3│     0│     0│     3│     3│     9│
2260 │        Total N         │     6│     6│     6│     6│     6│    36│
2261 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
2262
2263                         Custom Tables
2264 ╭────────────────────────┬──────────────────────────────────╮
2265 │                        │                 y                │
2266 │                        ├──────┬──────┬──────┬──────┬──────┤
2267 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
2268 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
2269 │x 1.00  Count           │     1│     1│     1│     1│     4│
2270 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2271 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2272 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2273 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2274 │        Row Valid N %   │     .│     .│     .│     .│     .│
2275 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2276 │        Valid N         │      │      │      │      │     0│
2277 │        Total N         │      │      │      │      │     6│
2278 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2279 │  2.00  Count           │     1│     1│     1│     1│     4│
2280 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2281 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
2282 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2283 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2284 │        Row Valid N %   │     .│     .│     .│     .│     .│
2285 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2286 │        Valid N         │      │      │      │      │     0│
2287 │        Total N         │      │      │      │      │     6│
2288 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2289 │  3.00  Count           │     1│     1│     1│     1│     4│
2290 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2291 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2292 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2293 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2294 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2295 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2296 │        Valid N         │      │      │      │      │     3│
2297 │        Total N         │      │      │      │      │     6│
2298 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2299 │  4.00  Count           │     1│     1│     1│     1│     4│
2300 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
2301 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
2302 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
2303 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
2304 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
2305 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
2306 │        Valid N         │      │      │      │      │     3│
2307 │        Total N         │      │      │      │      │     6│
2308 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
2309 │  Total Count           │     4│     4│     4│     4│    16│
2310 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
2311 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
2312 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
2313 │        Row %           │     .│     .│     .│     .│     .│
2314 │        Row Valid N %   │     .│     .│     .│     .│     .│
2315 │        Row Total N %   │     .│     .│     .│     .│     .│
2316 │        Valid N         │     2│     0│     2│     2│     6│
2317 │        Total N         │     5│     5│     5│     5│    30│
2318 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
2319 ])
2320 AT_CLEANUP
2321
2322 AT_SETUP([CTABLES SMISSING=LISTWISE])
2323 AT_KEYWORDS([SMISSING LISTWISE])
2324 AT_DATA([ctables.sps],
2325 [[DATA LIST LIST NOTABLE/x y z.
2326 BEGIN DATA.
2327 1  . 40
2328 1 10 50
2329 1 20 60
2330 1  .  .
2331 1 30  .
2332 END DATA.
2333 VARIABLE LEVEL x (NOMINAL).
2334
2335 CTABLES /TABLE (y + z) > x.
2336 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
2337
2338 * The following doesn't come out as listwise because the tables are
2339 separate, not linked by an > operator.
2340 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
2341 ]])
2342 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
2343   Custom Tables
2344 ╭────────┬─────╮
2345 │        │ Mean│
2346 ├────────┼─────┤
2347 │y x 1.00│20.00│
2348 ├────────┼─────┤
2349 │z x 1.00│50.00│
2350 ╰────────┴─────╯
2351
2352   Custom Tables
2353 ╭────────┬─────╮
2354 │        │ Mean│
2355 ├────────┼─────┤
2356 │y x 1.00│15.00│
2357 ├────────┼─────┤
2358 │z x 1.00│55.00│
2359 ╰────────┴─────╯
2360
2361   Custom Tables
2362 ╭────────┬─────╮
2363 │        │ Mean│
2364 ├────────┼─────┤
2365 │y x 1.00│20.00│
2366 ├────────┼─────┤
2367 │z x 1.00│50.00│
2368 ╰────────┴─────╯
2369 ])
2370 AT_CLEANUP
2371
2372 AT_SETUP([CTABLES VLABELS - variables on different axes])
2373 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2374 AT_DATA([ctables.sps],
2375 [[GET 'nhtsa.sav'.
2376 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=DEFAULT /TABLE qnd5a BY qns3a.
2377 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NAME    /TABLE qnd5a BY qns3a.
2378 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=LABEL   /TABLE qnd5a BY qns3a.
2379 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=BOTH    /TABLE qnd5a BY qns3a.
2380 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE    /TABLE qnd5a BY qns3a.
2381 ]])
2382 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2383                                  Custom Tables
2384 ╭────────────────────────────────────────────────────────────────┬────────────╮
2385 │                                                                │S3a. GENDER:│
2386 │                                                                ├─────┬──────┤
2387 │                                                                │ Male│Female│
2388 │                                                                ├─────┼──────┤
2389 │                                                                │Count│ Count│
2390 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2391 │D5a. What would you say is your primary    Cuban                │   13│     7│
2392 │ethnic background?                         Mexican              │  175│   136│
2393 │                                           Spanish              │   20│    28│
2394 │                                           South American       │   21│    13│
2395 │                                           Central American     │   27│    25│
2396 │                                           Puerto Rican, OR     │   37│    41│
2397 │                                           Something else       │   35│    33│
2398 │                                           Multiple - cannot    │    2│     5│
2399 │                                           choose one           │     │      │
2400 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2401
2402                   Custom Tables
2403 ╭──────────────────────────────────┬────────────╮
2404 │                                  │    QNS3A   │
2405 │                                  ├─────┬──────┤
2406 │                                  │ Male│Female│
2407 │                                  ├─────┼──────┤
2408 │                                  │Count│ Count│
2409 ├──────────────────────────────────┼─────┼──────┤
2410 │QND5A Cuban                       │   13│     7│
2411 │      Mexican                     │  175│   136│
2412 │      Spanish                     │   20│    28│
2413 │      South American              │   21│    13│
2414 │      Central American            │   27│    25│
2415 │      Puerto Rican, OR            │   37│    41│
2416 │      Something else              │   35│    33│
2417 │      Multiple - cannot choose one│    2│     5│
2418 ╰──────────────────────────────────┴─────┴──────╯
2419
2420                                  Custom Tables
2421 ╭────────────────────────────────────────────────────────────────┬────────────╮
2422 │                                                                │S3a. GENDER:│
2423 │                                                                ├─────┬──────┤
2424 │                                                                │ Male│Female│
2425 │                                                                ├─────┼──────┤
2426 │                                                                │Count│ Count│
2427 ├────────────────────────────────────────────────────────────────┼─────┼──────┤
2428 │D5a. What would you say is your primary    Cuban                │   13│     7│
2429 │ethnic background?                         Mexican              │  175│   136│
2430 │                                           Spanish              │   20│    28│
2431 │                                           South American       │   21│    13│
2432 │                                           Central American     │   27│    25│
2433 │                                           Puerto Rican, OR     │   37│    41│
2434 │                                           Something else       │   35│    33│
2435 │                                           Multiple - cannot    │    2│     5│
2436 │                                           choose one           │     │      │
2437 ╰────────────────────────────────────────────────────────────────┴─────┴──────╯
2438
2439                                  Custom Tables
2440 ╭────────────────────────────────────────────────────────────┬────────────────╮
2441 │                                                            │   QNS3A S3a.   │
2442 │                                                            │     GENDER:    │
2443 │                                                            ├───────┬────────┤
2444 │                                                            │  Male │ Female │
2445 │                                                            ├───────┼────────┤
2446 │                                                            │ Count │  Count │
2447 ├────────────────────────────────────────────────────────────┼───────┼────────┤
2448 │QND5A D5a. What would you say is your    Cuban              │     13│       7│
2449 │primary ethnic background?               Mexican            │    175│     136│
2450 │                                         Spanish            │     20│      28│
2451 │                                         South American     │     21│      13│
2452 │                                         Central American   │     27│      25│
2453 │                                         Puerto Rican, OR   │     37│      41│
2454 │                                         Something else     │     35│      33│
2455 │                                         Multiple - cannot  │      2│       5│
2456 │                                         choose one         │       │        │
2457 ╰────────────────────────────────────────────────────────────┴───────┴────────╯
2458
2459                Custom Tables
2460 ╭────────────────────────────┬─────┬──────╮
2461 │                            │ Male│Female│
2462 │                            ├─────┼──────┤
2463 │                            │Count│ Count│
2464 ├────────────────────────────┼─────┼──────┤
2465 │Cuban                       │   13│     7│
2466 │Mexican                     │  175│   136│
2467 │Spanish                     │   20│    28│
2468 │South American              │   21│    13│
2469 │Central American            │   27│    25│
2470 │Puerto Rican, OR            │   37│    41│
2471 │Something else              │   35│    33│
2472 │Multiple - cannot choose one│    2│     5│
2473 ╰────────────────────────────┴─────┴──────╯
2474 ])
2475 AT_CLEANUP
2476
2477 AT_SETUP([CTABLES VLABELS - stacked variables])
2478 AT_KEYWORDS([stack stacking])
2479 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2480 AT_DATA([ctables.sps],
2481 [[GET 'nhtsa.sav'.
2482 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a + qns3a.
2483 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a + qns3a.
2484 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a + qns3a.
2485 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
2486 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
2487 ]])
2488 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2489                                  Custom Tables
2490 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2491 │                                                                       │Count│
2492 ├───────────────────────────────────────────────────────────────────────┼─────┤
2493 │D5a. What would you say is your primary ethnic  Cuban                  │   20│
2494 │background?                                     Mexican                │  311│
2495 │                                                Spanish                │   48│
2496 │                                                South American         │   34│
2497 │                                                Central American       │   52│
2498 │                                                Puerto Rican, OR       │   78│
2499 │                                                Something else         │   68│
2500 │                                                Multiple - cannot      │    7│
2501 │                                                choose one             │     │
2502 ├───────────────────────────────────────────────────────────────────────┼─────┤
2503 │QNS3A                                           Male                   │ 3132│
2504 │                                                Female                 │ 3867│
2505 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2506
2507                   Custom Tables
2508 ╭─────────────────────────────────────────┬─────╮
2509 │                                         │Count│
2510 ├─────────────────────────────────────────┼─────┤
2511 │QND5A        Cuban                       │   20│
2512 │             Mexican                     │  311│
2513 │             Spanish                     │   48│
2514 │             South American              │   34│
2515 │             Central American            │   52│
2516 │             Puerto Rican, OR            │   78│
2517 │             Something else              │   68│
2518 │             Multiple - cannot choose one│    7│
2519 ├─────────────────────────────────────────┼─────┤
2520 │S3a. GENDER: Male                        │ 3132│
2521 │             Female                      │ 3867│
2522 ╰─────────────────────────────────────────┴─────╯
2523
2524                                  Custom Tables
2525 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2526 │                                                                       │Count│
2527 ├───────────────────────────────────────────────────────────────────────┼─────┤
2528 │D5a. What would you say is your primary ethnic  Cuban                  │   20│
2529 │background?                                     Mexican                │  311│
2530 │                                                Spanish                │   48│
2531 │                                                South American         │   34│
2532 │                                                Central American       │   52│
2533 │                                                Puerto Rican, OR       │   78│
2534 │                                                Something else         │   68│
2535 │                                                Multiple - cannot      │    7│
2536 │                                                choose one             │     │
2537 ├───────────────────────────────────────────────────────────────────────┼─────┤
2538 │Male                                                                   │ 3132│
2539 ├───────────────────────────────────────────────────────────────────────┼─────┤
2540 │Female                                                                 │ 3867│
2541 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2542
2543             Custom Tables
2544 ╭─────────────────────────────┬─────╮
2545 │                             │Count│
2546 ├─────────────────────────────┼─────┤
2547 │Cuban                        │   20│
2548 ├─────────────────────────────┼─────┤
2549 │Mexican                      │  311│
2550 ├─────────────────────────────┼─────┤
2551 │Spanish                      │   48│
2552 ├─────────────────────────────┼─────┤
2553 │South American               │   34│
2554 ├─────────────────────────────┼─────┤
2555 │Central American             │   52│
2556 ├─────────────────────────────┼─────┤
2557 │Puerto Rican, OR             │   78│
2558 ├─────────────────────────────┼─────┤
2559 │Something else               │   68│
2560 ├─────────────────────────────┼─────┤
2561 │Multiple - cannot choose one │    7│
2562 ├─────────────────────────────┼─────┤
2563 │S3a. GENDER:     Male        │ 3132│
2564 │                 Female      │ 3867│
2565 ╰─────────────────────────────┴─────╯
2566
2567             Custom Tables
2568 ╭────────────────────────────┬─────╮
2569 │                            │Count│
2570 ├────────────────────────────┼─────┤
2571 │Cuban                       │   20│
2572 │Mexican                     │  311│
2573 │Spanish                     │   48│
2574 │South American              │   34│
2575 │Central American            │   52│
2576 │Puerto Rican, OR            │   78│
2577 │Something else              │   68│
2578 │Multiple - cannot choose one│    7│
2579 │Male                        │ 3132│
2580 │Female                      │ 3867│
2581 ╰────────────────────────────┴─────╯
2582 ])
2583 AT_CLEANUP
2584
2585 AT_SETUP([CTABLES VLABELS - nested variables])
2586 AT_KEYWORDS([nest nesting])
2587 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2588 AT_DATA([ctables.sps],
2589 [[GET 'nhtsa.sav'.
2590 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a > qns3a.
2591 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a > qns3a.
2592 CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a > qns3a.
2593 CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
2594 CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
2595 ]])
2596 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2597                                  Custom Tables
2598 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2599 │                                                                       │Count│
2600 ├───────────────────────────────────────────────────────────────────────┼─────┤
2601 │D5a. What would you say is your       Cuban                QNS3A Male  │   13│
2602 │primary ethnic background?                                       Female│    7│
2603 │                                     ╶─────────────────────────────────┼─────┤
2604 │                                      Mexican              QNS3A Male  │  175│
2605 │                                                                 Female│  136│
2606 │                                     ╶─────────────────────────────────┼─────┤
2607 │                                      Spanish              QNS3A Male  │   20│
2608 │                                                                 Female│   28│
2609 │                                     ╶─────────────────────────────────┼─────┤
2610 │                                      South American       QNS3A Male  │   21│
2611 │                                                                 Female│   13│
2612 │                                     ╶─────────────────────────────────┼─────┤
2613 │                                      Central American     QNS3A Male  │   27│
2614 │                                                                 Female│   25│
2615 │                                     ╶─────────────────────────────────┼─────┤
2616 │                                      Puerto Rican, OR     QNS3A Male  │   37│
2617 │                                                                 Female│   41│
2618 │                                     ╶─────────────────────────────────┼─────┤
2619 │                                      Something else       QNS3A Male  │   35│
2620 │                                                                 Female│   33│
2621 │                                     ╶─────────────────────────────────┼─────┤
2622 │                                      Multiple - cannot    QNS3A Male  │    2│
2623 │                                      choose one                 Female│    5│
2624 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2625
2626                          Custom Tables
2627 ╭──────────────────────────────────────────────────────┬─────╮
2628 │                                                      │Count│
2629 ├──────────────────────────────────────────────────────┼─────┤
2630 │QND5A Cuban                        S3a. GENDER: Male  │   13│
2631 │                                                Female│    7│
2632 │     ╶────────────────────────────────────────────────┼─────┤
2633 │      Mexican                      S3a. GENDER: Male  │  175│
2634 │                                                Female│  136│
2635 │     ╶────────────────────────────────────────────────┼─────┤
2636 │      Spanish                      S3a. GENDER: Male  │   20│
2637 │                                                Female│   28│
2638 │     ╶────────────────────────────────────────────────┼─────┤
2639 │      South American               S3a. GENDER: Male  │   21│
2640 │                                                Female│   13│
2641 │     ╶────────────────────────────────────────────────┼─────┤
2642 │      Central American             S3a. GENDER: Male  │   27│
2643 │                                                Female│   25│
2644 │     ╶────────────────────────────────────────────────┼─────┤
2645 │      Puerto Rican, OR             S3a. GENDER: Male  │   37│
2646 │                                                Female│   41│
2647 │     ╶────────────────────────────────────────────────┼─────┤
2648 │      Something else               S3a. GENDER: Male  │   35│
2649 │                                                Female│   33│
2650 │     ╶────────────────────────────────────────────────┼─────┤
2651 │      Multiple - cannot choose one S3a. GENDER: Male  │    2│
2652 │                                                Female│    5│
2653 ╰──────────────────────────────────────────────────────┴─────╯
2654
2655                                  Custom Tables
2656 ╭───────────────────────────────────────────────────────────────────────┬─────╮
2657 │                                                                       │Count│
2658 ├───────────────────────────────────────────────────────────────────────┼─────┤
2659 │D5a. What would you say is your primary    Cuban                 Male  │   13│
2660 │ethnic background?                                               Female│    7│
2661 │                                          ╶────────────────────────────┼─────┤
2662 │                                           Mexican               Male  │  175│
2663 │                                                                 Female│  136│
2664 │                                          ╶────────────────────────────┼─────┤
2665 │                                           Spanish               Male  │   20│
2666 │                                                                 Female│   28│
2667 │                                          ╶────────────────────────────┼─────┤
2668 │                                           South American        Male  │   21│
2669 │                                                                 Female│   13│
2670 │                                          ╶────────────────────────────┼─────┤
2671 │                                           Central American      Male  │   27│
2672 │                                                                 Female│   25│
2673 │                                          ╶────────────────────────────┼─────┤
2674 │                                           Puerto Rican, OR      Male  │   37│
2675 │                                                                 Female│   41│
2676 │                                          ╶────────────────────────────┼─────┤
2677 │                                           Something else        Male  │   35│
2678 │                                                                 Female│   33│
2679 │                                          ╶────────────────────────────┼─────┤
2680 │                                           Multiple - cannot     Male  │    2│
2681 │                                           choose one            Female│    5│
2682 ╰───────────────────────────────────────────────────────────────────────┴─────╯
2683
2684                       Custom Tables
2685 ╭────────────────────────────────────────────────┬─────╮
2686 │                                                │Count│
2687 ├────────────────────────────────────────────────┼─────┤
2688 │Cuban                        S3a. GENDER: Male  │   13│
2689 │                                          Female│    7│
2690 ├────────────────────────────────────────────────┼─────┤
2691 │Mexican                      S3a. GENDER: Male  │  175│
2692 │                                          Female│  136│
2693 ├────────────────────────────────────────────────┼─────┤
2694 │Spanish                      S3a. GENDER: Male  │   20│
2695 │                                          Female│   28│
2696 ├────────────────────────────────────────────────┼─────┤
2697 │South American               S3a. GENDER: Male  │   21│
2698 │                                          Female│   13│
2699 ├────────────────────────────────────────────────┼─────┤
2700 │Central American             S3a. GENDER: Male  │   27│
2701 │                                          Female│   25│
2702 ├────────────────────────────────────────────────┼─────┤
2703 │Puerto Rican, OR             S3a. GENDER: Male  │   37│
2704 │                                          Female│   41│
2705 ├────────────────────────────────────────────────┼─────┤
2706 │Something else               S3a. GENDER: Male  │   35│
2707 │                                          Female│   33│
2708 ├────────────────────────────────────────────────┼─────┤
2709 │Multiple - cannot choose one S3a. GENDER: Male  │    2│
2710 │                                          Female│    5│
2711 ╰────────────────────────────────────────────────┴─────╯
2712
2713                Custom Tables
2714 ╭───────────────────────────────────┬─────╮
2715 │                                   │Count│
2716 ├───────────────────────────────────┼─────┤
2717 │Cuban                        Male  │   13│
2718 │                             Female│    7│
2719 ├───────────────────────────────────┼─────┤
2720 │Mexican                      Male  │  175│
2721 │                             Female│  136│
2722 ├───────────────────────────────────┼─────┤
2723 │Spanish                      Male  │   20│
2724 │                             Female│   28│
2725 ├───────────────────────────────────┼─────┤
2726 │South American               Male  │   21│
2727 │                             Female│   13│
2728 ├───────────────────────────────────┼─────┤
2729 │Central American             Male  │   27│
2730 │                             Female│   25│
2731 ├───────────────────────────────────┼─────┤
2732 │Puerto Rican, OR             Male  │   37│
2733 │                             Female│   41│
2734 ├───────────────────────────────────┼─────┤
2735 │Something else               Male  │   35│
2736 │                             Female│   33│
2737 ├───────────────────────────────────┼─────┤
2738 │Multiple - cannot choose one Male  │    2│
2739 │                             Female│    5│
2740 ╰───────────────────────────────────┴─────╯
2741 ])
2742 AT_CLEANUP
2743
2744 AT_SETUP([CTABLES FORMAT EMPTY])
2745 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2746 AT_DATA([ctables.sps],
2747 [[GET 'nhtsa.sav'.
2748 CTABLES /FORMAT EMPTY=ZERO /TABLE qnd5a BY qnd5.
2749 CTABLES /FORMAT EMPTY=BLANK /TABLE qnd5a BY qnd5.
2750 CTABLES /FORMAT EMPTY='n/a' /TABLE qnd5a BY qnd5.
2751 ]])
2752 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2753                                  Custom Tables
2754 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2755 │                                             │   D5. ETHNICITY: Are you of   │
2756 │                                             │  Hispanic or Latino origin or │
2757 │                                             │            descent?           │
2758 │                                             ├───────────────┬───────────────┤
2759 │                                             │      Yes      │       No      │
2760 │                                             ├───────────────┼───────────────┤
2761 │                                             │     Count     │     Count     │
2762 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2763 │D5a. What would you say is   Cuban           │             20│              0│
2764 │your primary ethnic          Mexican         │            311│              0│
2765 │background?                  Spanish         │             48│              0│
2766 │                             South American  │             34│              0│
2767 │                             Central American│             52│              0│
2768 │                             Puerto Rican, OR│             78│              0│
2769 │                             Something else  │             68│              0│
2770 │                             Multiple -      │              7│              0│
2771 │                             cannot choose   │               │               │
2772 │                             one             │               │               │
2773 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2774
2775                                  Custom Tables
2776 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2777 │                                             │   D5. ETHNICITY: Are you of   │
2778 │                                             │  Hispanic or Latino origin or │
2779 │                                             │            descent?           │
2780 │                                             ├───────────────┬───────────────┤
2781 │                                             │      Yes      │       No      │
2782 │                                             ├───────────────┼───────────────┤
2783 │                                             │     Count     │     Count     │
2784 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2785 │D5a. What would you say is   Cuban           │             20│               │
2786 │your primary ethnic          Mexican         │            311│               │
2787 │background?                  Spanish         │             48│               │
2788 │                             South American  │             34│               │
2789 │                             Central American│             52│               │
2790 │                             Puerto Rican, OR│             78│               │
2791 │                             Something else  │             68│               │
2792 │                             Multiple -      │              7│               │
2793 │                             cannot choose   │               │               │
2794 │                             one             │               │               │
2795 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2796
2797                                  Custom Tables
2798 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2799 │                                             │   D5. ETHNICITY: Are you of   │
2800 │                                             │  Hispanic or Latino origin or │
2801 │                                             │            descent?           │
2802 │                                             ├───────────────┬───────────────┤
2803 │                                             │      Yes      │       No      │
2804 │                                             ├───────────────┼───────────────┤
2805 │                                             │     Count     │     Count     │
2806 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2807 │D5a. What would you say is   Cuban           │             20│n/a            │
2808 │your primary ethnic          Mexican         │            311│n/a            │
2809 │background?                  Spanish         │             48│n/a            │
2810 │                             South American  │             34│n/a            │
2811 │                             Central American│             52│n/a            │
2812 │                             Puerto Rican, OR│             78│n/a            │
2813 │                             Something else  │             68│n/a            │
2814 │                             Multiple -      │              7│n/a            │
2815 │                             cannot choose   │               │               │
2816 │                             one             │               │               │
2817 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2818 ])
2819 AT_CLEANUP
2820
2821 AT_SETUP([CTABLES FORMAT MISSING])
2822 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2823 AT_DATA([ctables.sps],
2824 [[GET 'nhtsa.sav'.
2825 CTABLES /FORMAT MISSING='(no data)' /TABLE qnd5a[COLPCT] BY qnd5.
2826 ]])
2827 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2828                                  Custom Tables
2829 ╭─────────────────────────────────────────────┬───────────────────────────────╮
2830 │                                             │   D5. ETHNICITY: Are you of   │
2831 │                                             │  Hispanic or Latino origin or │
2832 │                                             │            descent?           │
2833 │                                             ├───────────────┬───────────────┤
2834 │                                             │      Yes      │       No      │
2835 │                                             ├───────────────┼───────────────┤
2836 │                                             │    Column %   │    Column %   │
2837 ├─────────────────────────────────────────────┼───────────────┼───────────────┤
2838 │D5a. What would you say is   Cuban           │           3.2%│(no data)      │
2839 │your primary ethnic          Mexican         │          50.3%│(no data)      │
2840 │background?                  Spanish         │           7.8%│(no data)      │
2841 │                             South American  │           5.5%│(no data)      │
2842 │                             Central American│           8.4%│(no data)      │
2843 │                             Puerto Rican, OR│          12.6%│(no data)      │
2844 │                             Something else  │          11.0%│(no data)      │
2845 │                             Multiple -      │           1.1%│(no data)      │
2846 │                             cannot choose   │               │               │
2847 │                             one             │               │               │
2848 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
2849 ])
2850 AT_CLEANUP
2851
2852 AT_SETUP([CTABLES HIDESMALLCOUNTS])
2853 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2854 AT_DATA([ctables.sps],
2855 [[GET 'nhtsa.sav'.
2856 CTABLES /TABLE qn38[c][COUNT, COLPCT].
2857 CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
2858 CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
2859 ]])
2860 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2861                                  Custom Tables
2862 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2863 │                                                              │Count│Column %│
2864 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2865 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2866 │occasion?                                        1            │  491│   34.9%│
2867 │                                                 2            │  462│   32.9%│
2868 │                                                 3            │  229│   16.3%│
2869 │                                                 4            │   82│    5.8%│
2870 │                                                 5            │   56│    4.0%│
2871 │                                                 6            │   32│    2.3%│
2872 │                                                 7            │    9│     .6%│
2873 │                                                 8            │    8│     .6%│
2874 │                                                 9            │    4│     .3%│
2875 │                                                 10           │    6│     .4%│
2876 │                                                 11           │    2│     .1%│
2877 │                                                 12           │    5│     .4%│
2878 │                                                 14           │    1│     .1%│
2879 │                                                 15           │    1│     .1%│
2880 │                                                 18           │    1│     .1%│
2881 │                                                 20           │    4│     .3%│
2882 │                                                 25           │    1│     .1%│
2883 │                                                 30           │    3│     .2%│
2884 │                                                 60           │    1│     .1%│
2885 │                                                 99+          │    0│     .0%│
2886 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2887
2888                                  Custom Tables
2889 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2890 │                                                              │Count│Column %│
2891 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2892 │38. How many drinks did you have on that         Less than one│    7│     .5%│
2893 │occasion?                                        1            │  491│   34.9%│
2894 │                                                 2            │  462│   32.9%│
2895 │                                                 3            │  229│   16.3%│
2896 │                                                 4            │   82│    5.8%│
2897 │                                                 5            │   56│    4.0%│
2898 │                                                 6            │   32│    2.3%│
2899 │                                                 7            │    9│     .6%│
2900 │                                                 8            │    8│     .6%│
2901 │                                                 9            │<5   │     .3%│
2902 │                                                 10           │    6│     .4%│
2903 │                                                 11           │<5   │     .1%│
2904 │                                                 12           │    5│     .4%│
2905 │                                                 14           │<5   │     .1%│
2906 │                                                 15           │<5   │     .1%│
2907 │                                                 18           │<5   │     .1%│
2908 │                                                 20           │<5   │     .3%│
2909 │                                                 25           │<5   │     .1%│
2910 │                                                 30           │<5   │     .2%│
2911 │                                                 60           │<5   │     .1%│
2912 │                                                 99+          │<5   │     .0%│
2913 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2914
2915                                  Custom Tables
2916 ╭──────────────────────────────────────────────────────────────┬─────┬────────╮
2917 │                                                              │Count│Column %│
2918 ├──────────────────────────────────────────────────────────────┼─────┼────────┤
2919 │38. How many drinks did you have on that         Less than one│<10  │     .5%│
2920 │occasion?                                        1            │  491│   34.9%│
2921 │                                                 2            │  462│   32.9%│
2922 │                                                 3            │  229│   16.3%│
2923 │                                                 4            │   82│    5.8%│
2924 │                                                 5            │   56│    4.0%│
2925 │                                                 6            │   32│    2.3%│
2926 │                                                 7            │<10  │     .6%│
2927 │                                                 8            │<10  │     .6%│
2928 │                                                 9            │<10  │     .3%│
2929 │                                                 10           │<10  │     .4%│
2930 │                                                 11           │<10  │     .1%│
2931 │                                                 12           │<10  │     .4%│
2932 │                                                 14           │<10  │     .1%│
2933 │                                                 15           │<10  │     .1%│
2934 │                                                 18           │<10  │     .1%│
2935 │                                                 20           │<10  │     .3%│
2936 │                                                 25           │<10  │     .1%│
2937 │                                                 30           │<10  │     .2%│
2938 │                                                 60           │<10  │     .1%│
2939 │                                                 99+          │<10  │     .0%│
2940 ╰──────────────────────────────────────────────────────────────┴─────┴────────╯
2941 ])
2942 AT_CLEANUP
2943
2944 AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
2945 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2946 AT_DATA([ctables.sps],
2947 [[GET 'nhtsa.sav'.
2948 CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
2949 ]])
2950 AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
2951  Custom Tables
2952 ╭────────────╮
2953 │S3a. GENDER:│
2954 ├─────┬──────┤
2955 │ Male│Female│
2956 ├─────┼──────┤
2957 │Count│ Count│
2958 ├─────┼──────┤
2959 │ 3132│  3867│
2960 ╰─────┴──────╯
2961 ])
2962 AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
2963 AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
2964 maximumColumnWidth="192"
2965 minimumColumnWidth="96"
2966 ])
2967 AT_CLEANUP
2968
2969 AT_SETUP([CTABLES special formats])
2970 AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
2971 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2972 AT_DATA([ctables.sps],
2973 [[GET 'nhtsa.sav'.
2974 COMPUTE x = qnd3 - 4.
2975 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].
2976 ]])
2977 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
2978                            Custom Tables
2979 ╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
2980 │ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
2981 ├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
2982 │x│(3.0)  │N=-3.0 │(-3.0) │(-3.0%)│8.0    │N=8.0  │(8.0)  │(8.0%) │
2983 ╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
2984 ])
2985 AT_CLEANUP
2986
2987 AT_SETUP([CTABLES TITLES])
2988 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
2989 AT_DATA([ctables.sps],
2990 [[GET 'nhtsa.sav'.
2991 CTABLES
2992     /VLABELS VARIABLES=qn1 DISPLAY=NONE
2993     /TABLE ((qn1[c][COUNT])) BY qns3a[c] > qnd5
2994     /TITLES TITLE='How often do you drive?'
2995             CAPTION='Generated )TIME on )DATE'
2996             CORNER=')TABLE'.
2997 ]])
2998 AT_CHECK([pspp ctables.sps -O box=unicode | sed 's/..:..:../HH:MM:SS/
2999 s&../../..&MM/DD/YY&'], [0], [dnl
3000                             How often do you drive?
3001 ╭───────────────────────────────────┬─────────────────────────────────────────╮
3002 │                                   │               S3a. GENDER:              │
3003 │                                   ├────────────────────┬────────────────────┤
3004 │                                   │        Male        │       Female       │
3005 │                                   ├────────────────────┼────────────────────┤
3006 │                                   │ D5. ETHNICITY: Are │ D5. ETHNICITY: Are │
3007 │                                   │ you of Hispanic or │ you of Hispanic or │
3008 │                                   │  Latino origin or  │  Latino origin or  │
3009 │( ( 1. How often do you usually    │      descent?      │      descent?      │
3010 │drive a car or other motor         ├─────────┬──────────┼─────────┬──────────┤
3011 │vehicle?) ) BY S3a. GENDER: > D5.  │   Yes   │    No    │   Yes   │    No    │
3012 │ETHNICITY: Are you of Hispanic or  ├─────────┼──────────┼─────────┼──────────┤
3013 │Latino origin or descent?          │  Count  │   Count  │  Count  │   Count  │
3014 ├───────────────────────────────────┼─────────┼──────────┼─────────┼──────────┤
3015 │Every day                          │      218│      2066│      166│      2175│
3016 │Several days a week                │       44│       391│       45│       782│
3017 │Once a week or less                │       16│       109│       12│       223│
3018 │Only certain times a year          │       15│        41│       11│        61│
3019 │Never                              │       39│       150│       56│       278│
3020 ╰───────────────────────────────────┴─────────┴──────────┴─────────┴──────────╯
3021 Generated HH:MM:SS on MM/DD/YY
3022 ])
3023 AT_CLEANUP
3024
3025 AT_SETUP([CTABLES area definitions])
3026 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3027 AT_DATA([ctables.sps],
3028 [[GET 'nhtsa.sav'.
3029 CTABLES
3030     /VLABELS VARIABLES=ALL DISPLAY=NAME
3031     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[TABLE.ID, LAYER.ID, SUBTABLE.ID]
3032     /SLABELS POSITION=ROW
3033     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[ROW.ID, LAYERROW.ID]
3034     /SLABELS POSITION=ROW
3035     /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[COL.ID, LAYERCOL.ID]
3036     /SLABELS POSITION=ROW.
3037 ]])
3038 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=80], [0], [dnl
3039                     Custom Tables
3040 Male
3041 ╭─────────────────────────────┬─────────────┬──────╮
3042 │                             │    QND7A    │ QN64B│
3043 │                             ├──────┬──────┼───┬──┤
3044 │                             │  Yes │  No  │   │  │
3045 │                             ├──────┼──────┤   │  │
3046 │                             │ QN86 │ QN86 │   │  │
3047 │                             ├───┬──┼───┬──┤   │  │
3048 │                             │Yes│No│Yes│No│Yes│No│
3049 ├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
3050 │QN61 Yes QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
3051 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
3052 │                  Subtable ID│  1│ 1│  2│ 2│  3│ 3│
3053 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
3054 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
3055 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
3056 │                  Subtable ID│  1│ 1│  2│ 2│  3│ 3│
3057 │    ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
3058 │     No  QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
3059 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
3060 │                  Subtable ID│  4│ 4│  5│ 5│  6│ 6│
3061 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
3062 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
3063 │                  Layer ID   │  1│ 1│  1│ 1│  2│ 2│
3064 │                  Subtable ID│  4│ 4│  5│ 5│  6│ 6│
3065 ╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
3066
3067                     Custom Tables
3068 Female
3069 ╭─────────────────────────────┬─────────────┬──────╮
3070 │                             │    QND7A    │ QN64B│
3071 │                             ├──────┬──────┼───┬──┤
3072 │                             │  Yes │  No  │   │  │
3073 │                             ├──────┼──────┤   │  │
3074 │                             │ QN86 │ QN86 │   │  │
3075 │                             ├───┬──┼───┬──┤   │  │
3076 │                             │Yes│No│Yes│No│Yes│No│
3077 ├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
3078 │QN61 Yes QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
3079 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
3080 │                  Subtable ID│  7│ 7│  8│ 8│  9│ 9│
3081 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
3082 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
3083 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
3084 │                  Subtable ID│  7│ 7│  8│ 8│  9│ 9│
3085 │    ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
3086 │     No  QN57 Yes Table ID   │  1│ 1│  1│ 1│  2│ 2│
3087 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
3088 │                  Subtable ID│ 10│10│ 11│11│ 12│12│
3089 │             ╶───────────────┼───┼──┼───┼──┼───┼──┤
3090 │              No  Table ID   │  1│ 1│  1│ 1│  2│ 2│
3091 │                  Layer ID   │  3│ 3│  3│ 3│  4│ 4│
3092 │                  Subtable ID│ 10│10│ 11│11│ 12│12│
3093 ╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
3094
3095                     Custom Tables
3096 Male
3097 ╭──────────────────────────────┬─────────────┬──────╮
3098 │                              │    QND7A    │ QN64B│
3099 │                              ├──────┬──────┼───┬──┤
3100 │                              │  Yes │  No  │   │  │
3101 │                              ├──────┼──────┤   │  │
3102 │                              │ QN86 │ QN86 │   │  │
3103 │                              ├───┬──┼───┬──┤   │  │
3104 │                              │Yes│No│Yes│No│Yes│No│
3105 ├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
3106 │QN61 Yes QN57 Yes Row ID      │  1│ 1│  2│ 2│  3│ 3│
3107 │                  Layer Row ID│  1│ 1│  1│ 1│  2│ 2│
3108 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
3109 │              No  Row ID      │  4│ 4│  5│ 5│  6│ 6│
3110 │                  Layer Row ID│  3│ 3│  3│ 3│  4│ 4│
3111 │    ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
3112 │     No  QN57 Yes Row ID      │  7│ 7│  8│ 8│  9│ 9│
3113 │                  Layer Row ID│  5│ 5│  5│ 5│  6│ 6│
3114 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
3115 │              No  Row ID      │ 10│10│ 11│11│ 12│12│
3116 │                  Layer Row ID│  7│ 7│  7│ 7│  8│ 8│
3117 ╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
3118
3119                     Custom Tables
3120 Female
3121 ╭──────────────────────────────┬─────────────┬──────╮
3122 │                              │    QND7A    │ QN64B│
3123 │                              ├──────┬──────┼───┬──┤
3124 │                              │  Yes │  No  │   │  │
3125 │                              ├──────┼──────┤   │  │
3126 │                              │ QN86 │ QN86 │   │  │
3127 │                              ├───┬──┼───┬──┤   │  │
3128 │                              │Yes│No│Yes│No│Yes│No│
3129 ├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
3130 │QN61 Yes QN57 Yes Row ID      │ 13│13│ 14│14│ 15│15│
3131 │                  Layer Row ID│  9│ 9│  9│ 9│ 10│10│
3132 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
3133 │              No  Row ID      │ 16│16│ 17│17│ 18│18│
3134 │                  Layer Row ID│ 11│11│ 11│11│ 12│12│
3135 │    ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
3136 │     No  QN57 Yes Row ID      │ 19│19│ 20│20│ 21│21│
3137 │                  Layer Row ID│ 13│13│ 13│13│ 14│14│
3138 │             ╶────────────────┼───┼──┼───┼──┼───┼──┤
3139 │              No  Row ID      │ 22│22│ 23│23│ 24│24│
3140 │                  Layer Row ID│ 15│15│ 15│15│ 16│16│
3141 ╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
3142
3143                       Custom Tables
3144 Male
3145 ╭─────────────────────────────────┬─────────────┬──────╮
3146 │                                 │    QND7A    │ QN64B│
3147 │                                 ├──────┬──────┼───┬──┤
3148 │                                 │  Yes │  No  │   │  │
3149 │                                 ├──────┼──────┤   │  │
3150 │                                 │ QN86 │ QN86 │   │  │
3151 │                                 ├───┬──┼───┬──┤   │  │
3152 │                                 │Yes│No│Yes│No│Yes│No│
3153 ├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
3154 │QN61 Yes QN57 Yes Column ID      │  1│ 2│  3│ 4│  5│ 6│
3155 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
3156 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
3157 │              No  Column ID      │  1│ 2│  3│ 4│  5│ 6│
3158 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
3159 │    ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
3160 │     No  QN57 Yes Column ID      │  7│ 8│  9│10│ 11│12│
3161 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
3162 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
3163 │              No  Column ID      │  7│ 8│  9│10│ 11│12│
3164 │                  Layer Column ID│  1│ 2│  3│ 4│  5│ 6│
3165 ╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
3166
3167                       Custom Tables
3168 Female
3169 ╭─────────────────────────────────┬─────────────┬──────╮
3170 │                                 │    QND7A    │ QN64B│
3171 │                                 ├──────┬──────┼───┬──┤
3172 │                                 │  Yes │  No  │   │  │
3173 │                                 ├──────┼──────┤   │  │
3174 │                                 │ QN86 │ QN86 │   │  │
3175 │                                 ├───┬──┼───┬──┤   │  │
3176 │                                 │Yes│No│Yes│No│Yes│No│
3177 ├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
3178 │QN61 Yes QN57 Yes Column ID      │ 13│14│ 15│16│ 17│18│
3179 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
3180 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
3181 │              No  Column ID      │ 13│14│ 15│16│ 17│18│
3182 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
3183 │    ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
3184 │     No  QN57 Yes Column ID      │ 19│20│ 21│22│ 23│24│
3185 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
3186 │             ╶───────────────────┼───┼──┼───┼──┼───┼──┤
3187 │              No  Column ID      │ 19│20│ 21│22│ 23│24│
3188 │                  Layer Column ID│  7│ 8│  9│10│ 11│12│
3189 ╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
3190 ])
3191 AT_CLEANUP
3192
3193 AT_SETUP([CTABLES categorical summary functions])
3194 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3195 AT_DATA([ctables.sps],
3196 [[GET 'nhtsa.sav'.
3197 CTABLES
3198     /TABLE region BY qnd5a[COUNT, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTAL[COUNT, VALIDN, TOTALN]]
3199     /CATEGORIES VARIABLES=qnd5a TOTAL=YES MISSING=INCLUDE
3200     /SLABELS POSITION=ROW.
3201 ]])
3202 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
3203                                                       Custom Tables
3204 ╭─────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────╮
3205 │                 │                     D5a. What would you say is your primary ethnic background?                     │
3206 │                 ├─────┬───────┬───────┬──────────┬──────────┬─────────┬──────────┬──────────────┬──────┬───────┬─────┤
3207 │                 │     │       │       │          │          │         │          │  Multiple -  │      │       │     │
3208 │                 │     │       │       │   South  │  Central │  Puerto │ Something│ cannot choose│ Don't│       │     │
3209 │                 │Cuban│Mexican│Spanish│ American │ American │Rican, OR│   else   │      one     │ know │Refused│Total│
3210 ├─────────────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3211 │Region NE Count  │    6│      8│      8│        11│         7│       39│        23│             2│     0│      1│  105│
3212 │          Row %  │ 5.7%│   7.6%│   7.6%│     10.5%│      6.7%│    37.1%│     21.9%│          1.9%│   .0%│   1.0%│     │
3213 │          Row    │ 5.8%│   7.7%│   7.7%│     10.6%│      6.7%│    37.5%│     22.1%│          1.9%│   .0%│    .0%│     │
3214 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3215 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3216 │          Row    │  .4%│    .6%│    .6%│       .8%│       .5%│     2.8%│      1.6%│           .1%│   .0%│    .1%│     │
3217 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3218 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3219 │          Valid N│     │       │       │          │          │         │          │              │      │       │  104│
3220 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1409│
3221 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3222 │       MW Count  │    3│     24│      1│         4│         5│        9│         6│             0│     0│      1│   53│
3223 │          Row %  │ 5.7%│  45.3%│   1.9%│      7.5%│      9.4%│    17.0%│     11.3%│           .0%│   .0%│   1.9%│     │
3224 │          Row    │ 5.8%│  46.2%│   1.9%│      7.7%│      9.6%│    17.3%│     11.5%│           .0%│   .0%│    .0%│     │
3225 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3226 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3227 │          Row    │  .2%│   1.5%│    .1%│       .2%│       .3%│      .5%│       .4%│           .0%│   .0%│    .1%│     │
3228 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3229 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3230 │          Valid N│     │       │       │          │          │         │          │              │      │       │   52│
3231 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1654│
3232 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3233 │       S  Count  │   10│    113│     11│        14│        25│       23│        20│             2│     3│      2│  223│
3234 │          Row %  │ 4.5%│  50.7%│   4.9%│      6.3%│     11.2%│    10.3%│      9.0%│           .9%│  1.3%│    .9%│     │
3235 │          Row    │ 4.6%│  51.8%│   5.0%│      6.4%│     11.5%│    10.6%│      9.2%│           .9%│   .0%│    .0%│     │
3236 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3237 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3238 │          Row    │  .4%│   4.7%│    .5%│       .6%│      1.0%│     1.0%│       .8%│           .1%│   .1%│    .1%│     │
3239 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3240 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3241 │          Valid N│     │       │       │          │          │         │          │              │      │       │  218│
3242 │          Total N│     │       │       │          │          │         │          │              │      │       │ 2390│
3243 │      ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
3244 │       W  Count  │    1│    166│     28│         5│        15│        7│        19│             3│     0│      1│  245│
3245 │          Row %  │  .4%│  67.8%│  11.4%│      2.0%│      6.1%│     2.9%│      7.8%│          1.2%│   .0%│    .4%│     │
3246 │          Row    │  .4%│  68.0%│  11.5%│      2.0%│      6.1%│     2.9%│      7.8%│          1.2%│   .0%│    .0%│     │
3247 │          Valid N│     │       │       │          │          │         │          │              │      │       │     │
3248 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3249 │          Row    │  .1%│  10.7%│   1.8%│       .3%│      1.0%│      .5%│      1.2%│           .2%│   .0%│    .1%│     │
3250 │          Total N│     │       │       │          │          │         │          │              │      │       │     │
3251 │          %      │     │       │       │          │          │         │          │              │      │       │     │
3252 │          Valid N│     │       │       │          │          │         │          │              │      │       │  244│
3253 │          Total N│     │       │       │          │          │         │          │              │      │       │ 1546│
3254 ╰─────────────────┴─────┴───────┴───────┴──────────┴──────────┴─────────┴──────────┴──────────────┴──────┴───────┴─────╯
3255 ])
3256 AT_CLEANUP
3257
3258
3259 AT_SETUP([CTABLES scale summary functions])
3260 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3261 AT_DATA([ctables.sps],
3262 [[GET 'nhtsa.sav'.
3263 SET TVAR=NAME.
3264
3265 * Use SPLIT FILE with FREQUENCIES to generate output equivalent to
3266   CTABLES later, to make the results easier to verify.
3267 SPLIT FILE BY REGION.
3268 FREQUENCIES
3269     qn19a
3270     /STATISTICS=MEAN SEMEAN MEDIAN MODE STDDEV VARIANCE RANGE MINIMUM MAXIMUM SUM
3271     /FORMAT NOTABLE /MISSING=INCLUDE.
3272 SPLIT FILE OFF.
3273
3274 CTABLES
3275     /VLABELS VARIABLE=qn19a DISPLAY=NAME /*XXX NONE yields an assertion failure
3276     /TABLE region BY qn19a[VALIDN, MISSING, MEAN, SEMEAN, MEDIAN, MODE, STDDEV, VARIANCE, RANGE, MINIMUM, MAXIMUM, SUM, COUNT, TOTALN, COLPCT.SUM]
3277     /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
3278     /SLABELS POSITION=ROW.
3279 ]])
3280 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
3281          Statistics
3282 ╭────────────────┬────────╮
3283 │REGION          │  QN19A │
3284 ├────────────────┼────────┤
3285 │NE     N Valid  │     936│
3286 │         Missing│     473│
3287 │      ╶─────────┼────────┤
3288 │       Mean     │   19.33│
3289 │      ╶─────────┼────────┤
3290 │       S.E. Mean│     .14│
3291 │      ╶─────────┼────────┤
3292 │       Median   │   18.00│
3293 │      ╶─────────┼────────┤
3294 │       Mode     │   18.00│
3295 │      ╶─────────┼────────┤
3296 │       Std Dev  │    4.41│
3297 │      ╶─────────┼────────┤
3298 │       Variance │   19.41│
3299 │      ╶─────────┼────────┤
3300 │       Range    │   59.00│
3301 │      ╶─────────┼────────┤
3302 │       Minimum  │     .00│
3303 │      ╶─────────┼────────┤
3304 │       Maximum  │   59.00│
3305 │      ╶─────────┼────────┤
3306 │       Sum      │18092.00│
3307 ├────────────────┼────────┤
3308 │MW     N Valid  │    1019│
3309 │         Missing│     635│
3310 │      ╶─────────┼────────┤
3311 │       Mean     │   19.83│
3312 │      ╶─────────┼────────┤
3313 │       S.E. Mean│     .16│
3314 │      ╶─────────┼────────┤
3315 │       Median   │   19.00│
3316 │      ╶─────────┼────────┤
3317 │       Mode     │   18.00│
3318 │      ╶─────────┼────────┤
3319 │       Std Dev  │    5.15│
3320 │      ╶─────────┼────────┤
3321 │       Variance │   26.47│
3322 │      ╶─────────┼────────┤
3323 │       Range    │   71.00│
3324 │      ╶─────────┼────────┤
3325 │       Minimum  │    4.00│
3326 │      ╶─────────┼────────┤
3327 │       Maximum  │   75.00│
3328 │      ╶─────────┼────────┤
3329 │       Sum      │20206.00│
3330 ├────────────────┼────────┤
3331 │S      N Valid  │    1276│
3332 │         Missing│    1114│
3333 │      ╶─────────┼────────┤
3334 │       Mean     │   20.29│
3335 │      ╶─────────┼────────┤
3336 │       S.E. Mean│     .18│
3337 │      ╶─────────┼────────┤
3338 │       Median   │   19.00│
3339 │      ╶─────────┼────────┤
3340 │       Mode     │   18.00│
3341 │      ╶─────────┼────────┤
3342 │       Std Dev  │    6.44│
3343 │      ╶─────────┼────────┤
3344 │       Variance │   41.43│
3345 │      ╶─────────┼────────┤
3346 │       Range    │   75.00│
3347 │      ╶─────────┼────────┤
3348 │       Minimum  │    4.00│
3349 │      ╶─────────┼────────┤
3350 │       Maximum  │   79.00│
3351 │      ╶─────────┼────────┤
3352 │       Sum      │25886.00│
3353 ├────────────────┼────────┤
3354 │W      N Valid  │     950│
3355 │         Missing│     596│
3356 │      ╶─────────┼────────┤
3357 │       Mean     │   19.87│
3358 │      ╶─────────┼────────┤
3359 │       S.E. Mean│     .17│
3360 │      ╶─────────┼────────┤
3361 │       Median   │   19.00│
3362 │      ╶─────────┼────────┤
3363 │       Mode     │   18.00│
3364 │      ╶─────────┼────────┤
3365 │       Std Dev  │    5.25│
3366 │      ╶─────────┼────────┤
3367 │       Variance │   27.59│
3368 │      ╶─────────┼────────┤
3369 │       Range    │   61.00│
3370 │      ╶─────────┼────────┤
3371 │       Minimum  │    4.00│
3372 │      ╶─────────┼────────┤
3373 │       Maximum  │   65.00│
3374 │      ╶─────────┼────────┤
3375 │       Sum      │18877.00│
3376 ╰────────────────┴────────╯
3377
3378              Custom Tables
3379 ╭───────────────────────────┬────────╮
3380 │                           │  QN19A │
3381 ├───────────────────────────┼────────┤
3382 │REGION NE Valid N          │     936│
3383 │          Missing          │  473.00│
3384 │          Mean             │   19.33│
3385 │          Std Error of Mean│     .14│
3386 │          Median           │   18.00│
3387 │          Mode             │   18.00│
3388 │          Std Deviation    │    4.41│
3389 │          Variance         │   19.41│
3390 │          Range            │   59.00│
3391 │          Minimum          │     .00│
3392 │          Maximum          │   59.00│
3393 │          Sum              │18092.00│
3394 │          Count            │    1409│
3395 │          Total N          │    1409│
3396 │          Column Sum %     │   21.8%│
3397 │      ╶────────────────────┼────────┤
3398 │       MW Valid N          │    1019│
3399 │          Missing          │  635.00│
3400 │          Mean             │   19.83│
3401 │          Std Error of Mean│     .16│
3402 │          Median           │   19.00│
3403 │          Mode             │   18.00│
3404 │          Std Deviation    │    5.15│
3405 │          Variance         │   26.47│
3406 │          Range            │   71.00│
3407 │          Minimum          │    4.00│
3408 │          Maximum          │   75.00│
3409 │          Sum              │20206.00│
3410 │          Count            │    1654│
3411 │          Total N          │    1654│
3412 │          Column Sum %     │   24.3%│
3413 │      ╶────────────────────┼────────┤
3414 │       S  Valid N          │    1276│
3415 │          Missing          │ 1114.00│
3416 │          Mean             │   20.29│
3417 │          Std Error of Mean│     .18│
3418 │          Median           │   19.00│
3419 │          Mode             │   18.00│
3420 │          Std Deviation    │    6.44│
3421 │          Variance         │   41.43│
3422 │          Range            │   75.00│
3423 │          Minimum          │    4.00│
3424 │          Maximum          │   79.00│
3425 │          Sum              │25886.00│
3426 │          Count            │    2390│
3427 │          Total N          │    2390│
3428 │          Column Sum %     │   31.2%│
3429 │      ╶────────────────────┼────────┤
3430 │       W  Valid N          │     950│
3431 │          Missing          │  596.00│
3432 │          Mean             │   19.87│
3433 │          Std Error of Mean│     .17│
3434 │          Median           │   19.00│
3435 │          Mode             │   18.00│
3436 │          Std Deviation    │    5.25│
3437 │          Variance         │   27.59│
3438 │          Range            │   61.00│
3439 │          Minimum          │    4.00│
3440 │          Maximum          │   65.00│
3441 │          Sum              │18877.00│
3442 │          Count            │    1546│
3443 │          Total N          │    1546│
3444 │          Column Sum %     │   22.7%│
3445 ╰───────────────────────────┴────────╯
3446 ])
3447 AT_CLEANUP
3448
3449
3450 AT_SETUP([CTABLES hidden scale VLABELS])
3451 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
3452 AT_DATA([ctables.sps],
3453 [[GET 'nhtsa.sav'.
3454 CTABLES
3455     /TABLE region BY qn19a + qn35
3456     /SLABELS POSITION=ROW.
3457 CTABLES
3458     /VLABELS VARIABLE=qn19a DISPLAY=NONE
3459     /TABLE region BY qn19a + qn35
3460     /SLABELS POSITION=ROW.
3461 CTABLES
3462     /VLABELS VARIABLE=qn35 DISPLAY=NONE
3463     /TABLE region BY qn19a + qn35
3464     /SLABELS POSITION=ROW.
3465
3466 * This one in particular caused a crash because no categories were
3467   created on the column axis, so passing in 0 for the index was still
3468   too big for that number of categories.  It was fixed by creating a
3469   name-only category for each variable despite the "NONE" request,
3470   then hiding the entire dimension's labels if all its labels were
3471   set to "NONE".
3472 CTABLES
3473     /VLABELS VARIABLE=qn19a qn35 DISPLAY=NONE
3474     /TABLE region BY qn19a + qn35
3475     /SLABELS POSITION=ROW.
3476 ]])
3477 AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
3478                                  Custom Tables
3479 ╭──────────────┬────────────────────────────┬─────────────────────────────────╮
3480 │              │ 19a. About how old were you│ 35. In the past thirty days, how│
3481 │              │   when you first starting  │   many times have you driven a  │
3482 │              │    drinking alcohol, not   │  motor vehicle WITHIN TWO HOURS │
3483 │              │  counting small tastes or  │     AFTER drinking alcoholic    │
3484 │              │      sips of alcohol.      │            beverages?           │
3485 ├──────────────┼────────────────────────────┼─────────────────────────────────┤
3486 │Region NE Mean│                       19.33│                                2│
3487 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3488 │       MW Mean│                       19.83│                                2│
3489 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3490 │       S  Mean│                       20.29│                                2│
3491 │      ╶───────┼────────────────────────────┼─────────────────────────────────┤
3492 │       W  Mean│                       19.87│                                2│
3493 ╰──────────────┴────────────────────────────┴─────────────────────────────────╯
3494
3495                                  Custom Tables
3496 ╭──────────────┬─────┬────────────────────────────────────────────────────────╮
3497 │              │     │  35. In the past thirty days, how many times have you  │
3498 │              │     │ driven a motor vehicle WITHIN TWO HOURS AFTER drinking │
3499 │              │QN19A│                  alcoholic beverages?                  │
3500 ├──────────────┼─────┼────────────────────────────────────────────────────────┤
3501 │Region NE Mean│19.33│                                                       2│
3502 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3503 │       MW Mean│19.83│                                                       2│
3504 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3505 │       S  Mean│20.29│                                                       2│
3506 │      ╶───────┼─────┼────────────────────────────────────────────────────────┤
3507 │       W  Mean│19.87│                                                       2│
3508 ╰──────────────┴─────┴────────────────────────────────────────────────────────╯
3509
3510                                  Custom Tables
3511 ╭──────────────┬─────────────────────────────────────────────────────────┬────╮
3512 │              │   19a. About how old were you when you first starting   │    │
3513 │              │  drinking alcohol, not counting small tastes or sips of │    │
3514 │              │                         alcohol.                        │qn35│
3515 ├──────────────┼─────────────────────────────────────────────────────────┼────┤
3516 │Region NE Mean│                                                    19.33│   2│
3517 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3518 │       MW Mean│                                                    19.83│   2│
3519 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3520 │       S  Mean│                                                    20.29│   2│
3521 │      ╶───────┼─────────────────────────────────────────────────────────┼────┤
3522 │       W  Mean│                                                    19.87│   2│
3523 ╰──────────────┴─────────────────────────────────────────────────────────┴────╯
3524
3525       Custom Tables
3526 ╭──────────────┬───────╮
3527 │Region NE Mean│19.33 2│
3528 │      ╶───────┼───────┤
3529 │       MW Mean│19.83 2│
3530 │      ╶───────┼───────┤
3531 │       S  Mean│20.29 2│
3532 │      ╶───────┼───────┤
3533 │       W  Mean│19.87 2│
3534 ╰──────────────┴───────╯
3535 ])
3536 AT_CLEANUP
3537