work
[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 - Parsing (positive and negative)
6 dnl - String variables and values
7 dnl - Testing details of missing value handling in summaries.
8 dnl - test CLABELS ROWLABELS=LAYER.
9 dnl - Test VLABELS.
10 dnl - Test WEIGHT and adjustment weights.
11 dnl - EMPTY=INCLUDE For string ranges.
12 dnl - Summary functions:
13 dnl   * Separate summary functions for totals and subtotals.
14 dnl   * )CILEVEL in summary label specification
15 dnl Category sorting:
16 dnl   * VALUE
17 dnl   * LABEL
18 dnl   * ascending/descending
19 dnl - CATEGORIES:
20 dnl   * String values
21 dnl   * Date values
22 dnl   * THRU (numeric ranges)
23 dnl   * THRU (string ranges)
24 dnl   * OTHERNM
25 dnl - FORMAT:
26 dnl   * MINCOLWIDTH, MAXCOLWIDTH, UNITS.
27 dnl   * EMPTY.
28 dnl   * MISSING.
29 dnl - HIDESMALLCOUNTS.
30 dnl - Date/time variables and values
31 dnl - Special formats for summary functions: NEGPAREN, NEQUAL, PAREN, PCTPAREN.
32 dnl - TITLES: )DATE, )TIME, )TABLE.
33 dnl - Test PCOMPUTE:
34 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
35 dnl   * MISSING, OTHERNM
36 dnl   * strings and string ranges
37 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
38 dnl   * dates
39 dnl - PPROPERTIES:
40 dnl   * )LABEL[N].
41 dnl - Summary functions:
42 dnl   * U-prefix for unweighted summaries.
43 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
44 dnl - SPLIT FILE with SEPARATE splits
45 dnl - Definition of columns/rows when labels are rotated from one axis to another.
46 dnl
47 dnl Not for v1:
48 dnl - Multiple response sets
49 dnl - MRSETS subcommand.
50 dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
51 dnl - SIGTEST
52 dnl - COMPARETEST
53 dnl - Summary functions:
54 dnl   * .LCL and .UCL suffixes.
55 dnl   * .SE suffixes.
56 dnl - CATEGORIES:
57 dnl   * Data-dependent sorting.
58 dnl
59 dnl
60 dnl Bug:
61 dnl     CTABLES /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a.
62 dnl produces a bad median:
63 dnl                     Custom Tables
64 dnl +--------------------------+-----------------------+
65 dnl |                          |      S3a. GENDER:     |
66 dnl |                          +-----------+-----------+
67 dnl |                          |    Male   |   Female  |
68 dnl |                          +----+------+----+------+
69 dnl |                          |Mean|Median|Mean|Median|
70 dnl +--------------------------+----+------+----+------+
71 dnl |D1. AGE: What is your age?|  46|   999|  50|   999|
72 dnl +--------------------------+----+------+----+------+
73
74
75
76 # AT_SETUP([CTABLES parsing])
77 # AT_DATA([ctables.sps],
78 # [[DATA LIST LIST NOTABLE /x y z.
79 # CTABLES /TABLE=(x + y) > z.
80 # CTABLES /TABLE=(x[c] + y[c]) > z.
81 # CTABLES /TABLE=(x + y) > z[c].
82 # CTABLES /TABLE=x BY y BY z.
83 # CTABLES /TABLE=x[c] [ROWPCT.COUNT] > y[c].
84 # CTABLES /TABLE=x[c] > y[c] [ROWPCT.COUNT].
85 # ]])
86 # AT_CHECK([pspp ctables.sps])
87 # AT_CLEANUP
88
89 AT_SETUP([CTABLES one categorical variable])
90 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
91 AT_DATA([ctables.sps],
92 [[GET 'nhtsa.sav'.
93 CTABLES /TABLE qn1.
94 CTABLES /TABLE BY qn1.
95 CTABLES /TABLE BY BY qn1.
96 ]])
97 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
98                                   Custom Tables
99 ╭────────────────────────────────────────────────────────────────────────┬─────╮
100 │                                                                        │Count│
101 ├────────────────────────────────────────────────────────────────────────┼─────┤
102 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
103 │motor vehicle?                                     Several days a week  │ 1274│
104 │                                                   Once a week or less  │  361│
105 │                                                   Only certain times a │  130│
106 │                                                   year                 │     │
107 │                                                   Never                │  540│
108 ╰────────────────────────────────────────────────────────────────────────┴─────╯
109
110                                   Custom Tables
111 ╭──────────────────────────────────────────────────────────────────────────────╮
112 │        1. How often do you usually drive a car or other motor vehicle?       │
113 ├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
114 │         │  Several days a  │  Once a week or  │  Only certain times a  │     │
115 │Every day│       week       │       less       │          year          │Never│
116 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
117 │  Count  │       Count      │       Count      │          Count         │Count│
118 ├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
119 │     4667│              1274│               361│                     130│  540│
120 ╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
121
122 Custom Tables
123 Every day
124 ╭─────╮
125 │Count│
126 ├─────┤
127 │ 4667│
128 ╰─────╯
129 ])
130 AT_CLEANUP
131
132 AT_SETUP([CTABLES one scale variable])
133 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
134 AT_DATA([ctables.sps],
135 [[GET 'nhtsa.sav'.
136 CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
137 CTABLES /TABLE BY qnd1.
138 CTABLES /TABLE BY BY qnd1.
139 ]])
140 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
141                                   Custom Tables
142 ╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
143 │                      │     │       │       │    │     Std    │       │       │
144 │                      │Count│Valid N│Total N│Mean│  Deviation │Minimum│Maximum│
145 ├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
146 │D1. AGE: What is your │ 6999│   6930│   6999│  48│          19│     16│     86│
147 │age?                  │     │       │       │    │            │       │       │
148 ╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
149
150         Custom Tables
151 ╭──────────────────────────╮
152 │D1. AGE: What is your age?│
153 ├──────────────────────────┤
154 │           Mean           │
155 ├──────────────────────────┤
156 │                        48│
157 ╰──────────────────────────╯
158
159 Custom Tables
160 D1. AGE: What is your age?
161 ╭────╮
162 │Mean│
163 ├────┤
164 │  48│
165 ╰────╯
166 ])
167 AT_CLEANUP
168
169 AT_SETUP([CTABLES simple stacking])
170 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
171 AT_DATA([ctables.sps],
172 [[GET 'nhtsa.sav'.
173 CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
174 ]])
175 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
176                                   Custom Tables
177 ╭───────────────────────────────────────────────────────────────┬──────────────╮
178 │                                                               │ S3a. GENDER: │
179 │                                                               ├──────┬───────┤
180 │                                                               │ Male │ Female│
181 │                                                               ├──────┼───────┤
182 │                                                               │Column│ Column│
183 │                                                               │   %  │   %   │
184 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
185 │105b. How likely is it that drivers who have had   Almost      │   10%│    11%│
186 │too much to drink to drive safely will A. Get      certain     │      │       │
187 │stopped by the police?                             Very likely │   21%│    22%│
188 │                                                   Somewhat    │   38%│    42%│
189 │                                                   likely      │      │       │
190 │                                                   Somewhat    │   21%│    18%│
191 │                                                   unlikely    │      │       │
192 │                                                   Very        │   10%│     8%│
193 │                                                   unlikely    │      │       │
194 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
195 │105b. How likely is it that drivers who have had   Almost      │   14%│    18%│
196 │too much to drink to drive safely will B. Have an  certain     │      │       │
197 │accident?                                          Very likely │   36%│    45%│
198 │                                                   Somewhat    │   39%│    32%│
199 │                                                   likely      │      │       │
200 │                                                   Somewhat    │    9%│     4%│
201 │                                                   unlikely    │      │       │
202 │                                                   Very        │    3%│     2%│
203 │                                                   unlikely    │      │       │
204 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
205 │105b. How likely is it that drivers who have had   Almost      │   18%│    16%│
206 │too much to drink to drive safely will C. Be       certain     │      │       │
207 │convicted for drunk driving?                       Very likely │   32%│    28%│
208 │                                                   Somewhat    │   27%│    32%│
209 │                                                   likely      │      │       │
210 │                                                   Somewhat    │   15%│    15%│
211 │                                                   unlikely    │      │       │
212 │                                                   Very        │    9%│     9%│
213 │                                                   unlikely    │      │       │
214 ├───────────────────────────────────────────────────────────────┼──────┼───────┤
215 │105b. How likely is it that drivers who have had   Almost      │   16%│    16%│
216 │too much to drink to drive safely will D. Be       certain     │      │       │
217 │arrested for drunk driving?                        Very likely │   26%│    27%│
218 │                                                   Somewhat    │   32%│    35%│
219 │                                                   likely      │      │       │
220 │                                                   Somewhat    │   17%│    15%│
221 │                                                   unlikely    │      │       │
222 │                                                   Very        │    9%│     7%│
223 │                                                   unlikely    │      │       │
224 ╰───────────────────────────────────────────────────────────────┴──────┴───────╯
225 ])
226 AT_CLEANUP
227
228 AT_SETUP([CTABLES show or hide empty categories])
229 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
230 AT_DATA([ctables.sps],
231 [[GET 'nhtsa.sav'.
232 IF (qn105ba = 2) qn105ba = 1.
233 IF (qns3a = 1) qns3a = 2.
234 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
235 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
236     /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
237 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
238     /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
239 CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
240     /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
241 ]])
242 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
243                                   Custom Tables
244 ╭──────────────────────────────────────────────────────────────┬───────────────╮
245 │                                                              │  S3a. GENDER: │
246 │                                                              ├───────┬───────┤
247 │                                                              │  Male │ Female│
248 │                                                              ├───────┼───────┤
249 │                                                              │ Column│ Column│
250 │                                                              │   %   │   %   │
251 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
252 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
253 │too much to drink to drive safely will A. Get      certain    │       │       │
254 │stopped by the police?                             Very likely│      .│     0%│
255 │                                                   Somewhat   │      .│    40%│
256 │                                                   likely     │       │       │
257 │                                                   Somewhat   │      .│    19%│
258 │                                                   unlikely   │       │       │
259 │                                                   Very       │      .│     9%│
260 │                                                   unlikely   │       │       │
261 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
262
263                                   Custom Tables
264 ╭──────────────────────────────────────────────────────────────┬───────────────╮
265 │                                                              │  S3a. GENDER: │
266 │                                                              ├───────┬───────┤
267 │                                                              │  Male │ Female│
268 │                                                              ├───────┼───────┤
269 │                                                              │ Column│ Column│
270 │                                                              │   %   │   %   │
271 ├──────────────────────────────────────────────────────────────┼───────┼───────┤
272 │105b. How likely is it that drivers who have had   Almost     │      .│    32%│
273 │too much to drink to drive safely will A. Get      certain    │       │       │
274 │stopped by the police?                             Somewhat   │      .│    40%│
275 │                                                   likely     │       │       │
276 │                                                   Somewhat   │      .│    19%│
277 │                                                   unlikely   │       │       │
278 │                                                   Very       │      .│     9%│
279 │                                                   unlikely   │       │       │
280 ╰──────────────────────────────────────────────────────────────┴───────┴───────╯
281
282                                   Custom Tables
283 ╭────────────────────────────────────────────────────────────────────┬─────────╮
284 │                                                                    │   S3a.  │
285 │                                                                    │ GENDER: │
286 │                                                                    ├─────────┤
287 │                                                                    │  Female │
288 │                                                                    ├─────────┤
289 │                                                                    │ Column %│
290 ├────────────────────────────────────────────────────────────────────┼─────────┤
291 │105b. How likely is it that drivers who have had too    Almost      │      32%│
292 │much to drink to drive safely will A. Get stopped by    certain     │         │
293 │the police?                                             Very likely │       0%│
294 │                                                        Somewhat    │      40%│
295 │                                                        likely      │         │
296 │                                                        Somewhat    │      19%│
297 │                                                        unlikely    │         │
298 │                                                        Very        │       9%│
299 │                                                        unlikely    │         │
300 ╰────────────────────────────────────────────────────────────────────┴─────────╯
301
302                                   Custom Tables
303 ╭────────────────────────────────────────────────────────────────────┬─────────╮
304 │                                                                    │   S3a.  │
305 │                                                                    │ GENDER: │
306 │                                                                    ├─────────┤
307 │                                                                    │  Female │
308 │                                                                    ├─────────┤
309 │                                                                    │ Column %│
310 ├────────────────────────────────────────────────────────────────────┼─────────┤
311 │105b. How likely is it that drivers who have had too    Almost      │      32%│
312 │much to drink to drive safely will A. Get stopped by    certain     │         │
313 │the police?                                             Somewhat    │      40%│
314 │                                                        likely      │         │
315 │                                                        Somewhat    │      19%│
316 │                                                        unlikely    │         │
317 │                                                        Very        │       9%│
318 │                                                        unlikely    │         │
319 ╰────────────────────────────────────────────────────────────────────┴─────────╯
320 ])
321 AT_CLEANUP
322
323 AT_SETUP([CTABLES simple nesting])
324 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
325 AT_DATA([ctables.sps],
326 [[GET 'nhtsa.sav'.
327 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
328   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
329 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
330   /CATEGORIES VARIABLES=qns3a TOTAL=YES
331   /CLABELS ROW=OPPOSITE.
332 ]])
333 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
334                                   Custom Tables
335 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
336 │                                                                 │     │ Table│
337 │                                                                 │Count│   %  │
338 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
339 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
340 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
341 │drive safely will A. Get stopped by                        Total │  700│   10%│
342 │the police?                           ╶──────────────────────────┼─────┼──────┤
343 │                                       Very       S3a.     Male  │  660│   10%│
344 │                                       likely     GENDER:  Female│  842│   12%│
345 │                                                           Total │ 1502│   22%│
346 │                                      ╶──────────────────────────┼─────┼──────┤
347 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
348 │                                       likely     GENDER:  Female│ 1589│   23%│
349 │                                                           Total │ 2763│   40%│
350 │                                      ╶──────────────────────────┼─────┼──────┤
351 │                                       Somewhat   S3a.     Male  │  640│    9%│
352 │                                       unlikely   GENDER:  Female│  667│   10%│
353 │                                                           Total │ 1307│   19%│
354 │                                      ╶──────────────────────────┼─────┼──────┤
355 │                                       Very       S3a.     Male  │  311│    5%│
356 │                                       unlikely   GENDER:  Female│  298│    4%│
357 │                                                           Total │  609│    9%│
358 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
359 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
360 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
361 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
362 │                                      ╶──────────────────────────┼─────┼──────┤
363 │                                       Very       S3a.     Male  │ 1104│   16%│
364 │                                       likely     GENDER:  Female│ 1715│   25%│
365 │                                                           Total │ 2819│   41%│
366 │                                      ╶──────────────────────────┼─────┼──────┤
367 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
368 │                                       likely     GENDER:  Female│ 1214│   18%│
369 │                                                           Total │ 2417│   35%│
370 │                                      ╶──────────────────────────┼─────┼──────┤
371 │                                       Somewhat   S3a.     Male  │  262│    4%│
372 │                                       unlikely   GENDER:  Female│  168│    2%│
373 │                                                           Total │  430│    6%│
374 │                                      ╶──────────────────────────┼─────┼──────┤
375 │                                       Very       S3a.     Male  │   81│    1%│
376 │                                       unlikely   GENDER:  Female│   59│    1%│
377 │                                                           Total │  140│    2%│
378 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
379 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
380 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
381 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
382 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
383 │                                       Very       S3a.     Male  │  988│   14%│
384 │                                       likely     GENDER:  Female│ 1049│   15%│
385 │                                                           Total │ 2037│   30%│
386 │                                      ╶──────────────────────────┼─────┼──────┤
387 │                                       Somewhat   S3a.     Male  │  822│   12%│
388 │                                       likely     GENDER:  Female│ 1210│   18%│
389 │                                                           Total │ 2032│   30%│
390 │                                      ╶──────────────────────────┼─────┼──────┤
391 │                                       Somewhat   S3a.     Male  │  446│    7%│
392 │                                       unlikely   GENDER:  Female│  548│    8%│
393 │                                                           Total │  994│   15%│
394 │                                      ╶──────────────────────────┼─────┼──────┤
395 │                                       Very       S3a.     Male  │  268│    4%│
396 │                                       unlikely   GENDER:  Female│  354│    5%│
397 │                                                           Total │  622│    9%│
398 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
399 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
400 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
401 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
402 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
403 │                                       Very       S3a.     Male  │  805│   12%│
404 │                                       likely     GENDER:  Female│ 1029│   15%│
405 │                                                           Total │ 1834│   27%│
406 │                                      ╶──────────────────────────┼─────┼──────┤
407 │                                       Somewhat   S3a.     Male  │  975│   14%│
408 │                                       likely     GENDER:  Female│ 1332│   19%│
409 │                                                           Total │ 2307│   34%│
410 │                                      ╶──────────────────────────┼─────┼──────┤
411 │                                       Somewhat   S3a.     Male  │  535│    8%│
412 │                                       unlikely   GENDER:  Female│  560│    8%│
413 │                                                           Total │ 1095│   16%│
414 │                                      ╶──────────────────────────┼─────┼──────┤
415 │                                       Very       S3a.     Male  │  270│    4%│
416 │                                       unlikely   GENDER:  Female│  279│    4%│
417 │                                                           Total │  549│    8%│
418 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
419
420                                   Custom Tables
421 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
422 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
423 │                                 │ certain│likely│  likely │ unlikely│unlikely│
424 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
425 │                                 │        │ Table│         │         │        │
426 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
427 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
428 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
429 │GENDER:        is it that drivers│        │      │         │         │        │
430 │               who have had too  │        │      │         │         │        │
431 │               much to drink to  │        │      │         │         │        │
432 │               drive safely will │        │      │         │         │        │
433 │               A. Get stopped by │        │      │         │         │        │
434 │               the police?       │        │      │         │         │        │
435 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
436 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
437 │               is it that drivers│        │      │         │         │        │
438 │               who have had too  │        │      │         │         │        │
439 │               much to drink to  │        │      │         │         │        │
440 │               drive safely will │        │      │         │         │        │
441 │               A. Get stopped by │        │      │         │         │        │
442 │               the police?       │        │      │         │         │        │
443 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
444 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
445 │               is it that drivers│        │      │         │         │        │
446 │               who have had too  │        │      │         │         │        │
447 │               much to drink to  │        │      │         │         │        │
448 │               drive safely will │        │      │         │         │        │
449 │               A. Get stopped by │        │      │         │         │        │
450 │               the police?       │        │      │         │         │        │
451 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
452 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
453 │GENDER:        is it that drivers│        │      │         │         │        │
454 │               who have had too  │        │      │         │         │        │
455 │               much to drink to  │        │      │         │         │        │
456 │               drive safely will │        │      │         │         │        │
457 │               B. Have an        │        │      │         │         │        │
458 │               accident?         │        │      │         │         │        │
459 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
460 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
461 │               is it that drivers│        │      │         │         │        │
462 │               who have had too  │        │      │         │         │        │
463 │               much to drink to  │        │      │         │         │        │
464 │               drive safely will │        │      │         │         │        │
465 │               B. Have an        │        │      │         │         │        │
466 │               accident?         │        │      │         │         │        │
467 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
468 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
469 │               is it that drivers│        │      │         │         │        │
470 │               who have had too  │        │      │         │         │        │
471 │               much to drink to  │        │      │         │         │        │
472 │               drive safely will │        │      │         │         │        │
473 │               B. Have an        │        │      │         │         │        │
474 │               accident?         │        │      │         │         │        │
475 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
476 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
477 │GENDER:        is it that drivers│        │      │         │         │        │
478 │               who have had too  │        │      │         │         │        │
479 │               much to drink to  │        │      │         │         │        │
480 │               drive safely will │        │      │         │         │        │
481 │               C. Be convicted   │        │      │         │         │        │
482 │               for drunk driving?│        │      │         │         │        │
483 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
484 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
485 │               is it that drivers│        │      │         │         │        │
486 │               who have had too  │        │      │         │         │        │
487 │               much to drink to  │        │      │         │         │        │
488 │               drive safely will │        │      │         │         │        │
489 │               C. Be convicted   │        │      │         │         │        │
490 │               for drunk driving?│        │      │         │         │        │
491 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
492 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
493 │               is it that drivers│        │      │         │         │        │
494 │               who have had too  │        │      │         │         │        │
495 │               much to drink to  │        │      │         │         │        │
496 │               drive safely will │        │      │         │         │        │
497 │               C. Be convicted   │        │      │         │         │        │
498 │               for drunk driving?│        │      │         │         │        │
499 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
500 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
501 │GENDER:        is it that drivers│        │      │         │         │        │
502 │               who have had too  │        │      │         │         │        │
503 │               much to drink to  │        │      │         │         │        │
504 │               drive safely will │        │      │         │         │        │
505 │               D. Be arrested for│        │      │         │         │        │
506 │               drunk driving?    │        │      │         │         │        │
507 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
508 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
509 │               is it that drivers│        │      │         │         │        │
510 │               who have had too  │        │      │         │         │        │
511 │               much to drink to  │        │      │         │         │        │
512 │               drive safely will │        │      │         │         │        │
513 │               D. Be arrested for│        │      │         │         │        │
514 │               drunk driving?    │        │      │         │         │        │
515 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
516 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
517 │               is it that drivers│        │      │         │         │        │
518 │               who have had too  │        │      │         │         │        │
519 │               much to drink to  │        │      │         │         │        │
520 │               drive safely will │        │      │         │         │        │
521 │               D. Be arrested for│        │      │         │         │        │
522 │               drunk driving?    │        │      │         │         │        │
523 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
524 ])
525 AT_CLEANUP
526
527 AT_SETUP([CTABLES nesting and scale variables])
528 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
529 AT_DATA([ctables.sps],
530 [[GET 'nhtsa.sav'.
531 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
532 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
533 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
534   /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
535 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
536 ]])
537 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
538                                   Custom Tables
539 ╭─────────────────────────────────────────────────────────────────┬────────────╮
540 │                                                                 │S3a. GENDER:│
541 │                                                                 ├─────┬──────┤
542 │                                                                 │ Male│Female│
543 │                                                                 ├─────┼──────┤
544 │                                                                 │ Mean│ Mean │
545 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
546 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
547 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
548 │                                                  week           │     │      │
549 │                                                  Once a week or │   44│    54│
550 │                                                  less           │     │      │
551 │                                                  Only certain   │   34│    41│
552 │                                                  times a year   │     │      │
553 │                                                  Never          │   39│    55│
554 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
555
556                                   Custom Tables
557 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
558 │                                                         │Minimum│Maximum│Mean│
559 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
560 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
561 │What is  GENDER:         months, has there been a        │       │       │    │
562 │your                     time when you felt you          │       │       │    │
563 │age?                     should cut down on your      No │     16│     86│  46│
564 │                         drinking?                       │       │       │    │
565 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
566 │                  Female 26. During the last 12       Yes│     16│     86│  43│
567 │                         months, has there been a        │       │       │    │
568 │                         time when you felt you          │       │       │    │
569 │                         should cut down on your      No │     16│     86│  48│
570 │                         drinking?                       │       │       │    │
571 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
572 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
573 │What is  GENDER:         months, has there been a        │       │       │    │
574 │your                     time when people criticized  No │     16│     86│  46│
575 │age?                     your drinking?                  │       │       │    │
576 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
577 │                  Female 27. During the last 12       Yes│     17│     69│  37│
578 │                         months, has there been a        │       │       │    │
579 │                         time when people criticized  No │     16│     86│  48│
580 │                         your drinking?                  │       │       │    │
581 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
582
583                                   Custom Tables
584 ╭─────────────────────────────┬────────────────────────────────────────────────╮
585 │                             │S1. Including yourself, how many members of this│
586 │                             │         household are age 16 or older?         │
587 │                             ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
588 │                             │      │      │      │      │      │      │ 6 or │
589 │                             │ None │   1  │   2  │   3  │   4  │   5  │ more │
590 │                             ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
591 │                             │Column│Column│Column│Column│Column│Column│Column│
592 │                             │   %  │   %  │   %  │   %  │   %  │   %  │   %  │
593 ├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
594 │Sa1.    RDD 105b.    Almost  │     .│  9.5%│  8.2%│ 12.4%│  9.9%│ 20.0%│ 23.8%│
595 │SAMPLE      How      certain │      │      │      │      │      │      │      │
596 │SOURCE:     likely           │      │      │      │      │      │      │      │
597 │            is it    Very    │     .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
598 │            that     likely  │      │      │      │      │      │      │      │
599 │            drivers          │      │      │      │      │      │      │      │
600 │            who have         │      │      │      │      │      │      │      │
601 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
602 │            much to  likely  │      │      │      │      │      │      │      │
603 │            drink to         │      │      │      │      │      │      │      │
604 │            drive            │      │      │      │      │      │      │      │
605 │            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%│
606 │            will A.  unlikely│      │      │      │      │      │      │      │
607 │            Get              │      │      │      │      │      │      │      │
608 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
609 │            by the   unlikely│      │      │      │      │      │      │      │
610 │            police?          │      │      │      │      │      │      │      │
611 ╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
612
613                                   Custom Tables
614 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
615 │                                                              │    │    Std   │
616 │                                                              │Mean│ Deviation│
617 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
618 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
619 │group           typical month did you have one or more        │    │          │
620 │                alcoholic beverages to drink?                 │    │          │
621 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
622 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
623 │                typical month did you have one or more        │    │          │
624 │                alcoholic beverages to drink?                 │    │          │
625 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
626 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
627 │                typical month did you have one or more        │    │          │
628 │                alcoholic beverages to drink?                 │    │          │
629 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
630 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
631 │                typical month did you have one or more        │    │          │
632 │                alcoholic beverages to drink?                 │    │          │
633 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
634 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
635 │                typical month did you have one or more        │    │          │
636 │                alcoholic beverages to drink?                 │    │          │
637 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
638 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
639 │       older    typical month did you have one or more        │    │          │
640 │                alcoholic beverages to drink?                 │    │          │
641 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
642 ])
643 AT_CLEANUP
644
645
646 AT_SETUP([CTABLES SLABELS])
647 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
648 AT_DATA([ctables.sps],
649 [[GET 'nhtsa.sav'.
650 CTABLES /TABLE qn1 [COUNT COLPCT].
651 CTABLES /TABLE qn1 [COUNT COLPCT]
652     /SLABELS POSITION=ROW.
653 CTABLES /TABLE qn1 [COUNT COLPCT]
654     /SLABELS POSITION=ROW VISIBLE=NO.
655 ]])
656 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
657                                   Custom Tables
658 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
659 │                                                                │     │ Column│
660 │                                                                │Count│   %   │
661 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
662 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
663 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
664 │                                             Once a week or less│  361│   5.2%│
665 │                                             Only certain times │  130│   1.9%│
666 │                                             a year             │     │       │
667 │                                             Never              │  540│   7.7%│
668 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
669
670                                   Custom Tables
671 ╭────────────────────────────────────────────────────────────────────────┬─────╮
672 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
673 │other motor vehicle?                                             Column │66.9%│
674 │                                                                 %      │     │
675 │                                            ╶───────────────────────────┼─────┤
676 │                                             Several days a week Count  │ 1274│
677 │                                                                 Column │18.3%│
678 │                                                                 %      │     │
679 │                                            ╶───────────────────────────┼─────┤
680 │                                             Once a week or less Count  │  361│
681 │                                                                 Column │ 5.2%│
682 │                                                                 %      │     │
683 │                                            ╶───────────────────────────┼─────┤
684 │                                             Only certain times  Count  │  130│
685 │                                             a year              Column │ 1.9%│
686 │                                                                 %      │     │
687 │                                            ╶───────────────────────────┼─────┤
688 │                                             Never               Count  │  540│
689 │                                                                 Column │ 7.7%│
690 │                                                                 %      │     │
691 ╰────────────────────────────────────────────────────────────────────────┴─────╯
692
693                                   Custom Tables
694 ╭────────────────────────────────────────────────────────────────────────┬─────╮
695 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
696 │motor vehicle?                                                          │66.9%│
697 │                                                   Several days a week  │ 1274│
698 │                                                                        │18.3%│
699 │                                                   Once a week or less  │  361│
700 │                                                                        │ 5.2%│
701 │                                                   Only certain times a │  130│
702 │                                                   year                 │ 1.9%│
703 │                                                   Never                │  540│
704 │                                                                        │ 7.7%│
705 ╰────────────────────────────────────────────────────────────────────────┴─────╯
706 ])
707 AT_CLEANUP
708
709 AT_SETUP([CTABLES simple totals])
710 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
711 AT_DATA([ctables.sps],
712 [[GET 'nhtsa.sav'.
713 CTABLES /TABLE=qn17
714     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
715 DESCRIPTIVES qn18/STATISTICS=MEAN.
716 CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
717     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
718 ]])
719 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
720                                   Custom Tables
721 ╭────────────────────────────────────────────────────────────────────────┬─────╮
722 │                                                                        │Count│
723 ├────────────────────────────────────────────────────────────────────────┼─────┤
724 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
725 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
726 │                                                      Light beer        │  620│
727 │                                                      Wine              │ 1418│
728 │                                                      Wine coolers      │  137│
729 │                                                      Hard liquor or    │  888│
730 │                                                      mixed drinks      │     │
731 │                                                      Flavored malt     │   83│
732 │                                                      drinks            │     │
733 │                                                      Number responding │ 4221│
734 ╰────────────────────────────────────────────────────────────────────────┴─────╯
735
736                              Descriptive Statistics
737 ╭────────────────────────────────────────────────────────────────────┬────┬────╮
738 │                                                                    │  N │Mean│
739 ├────────────────────────────────────────────────────────────────────┼────┼────┤
740 │18. When you drink ANSWERFROM(QN17R1), about how many               │4218│4.62│
741 │ANSWERFROM(QN17R2) do you usually drink per sitting?                │    │    │
742 │Valid N (listwise)                                                  │6999│    │
743 │Missing N (listwise)                                                │2781│    │
744 ╰────────────────────────────────────────────────────────────────────┴────┴────╯
745
746                                   Custom Tables
747 ╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
748 │                                                      │    │     │ Valid│Total│
749 │                                                      │Mean│Count│   N  │  N  │
750 ├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
751 │Region NE       18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│   949│ 1409│
752 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
753 │                you usually drink per sitting?        │    │     │      │     │
754 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
755 │       MW       18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│  1027│ 1654│
756 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
757 │                you usually drink per sitting?        │    │     │      │     │
758 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
759 │       S        18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│  1287│ 2390│
760 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
761 │                you usually drink per sitting?        │    │     │      │     │
762 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
763 │       W        18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│   955│ 1546│
764 │                about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
765 │                you usually drink per sitting?        │    │     │      │     │
766 │      ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
767 │       All      18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│  4218│ 6999│
768 │       regions  about how many ANSWERFROM(QN17R2) do  │    │     │      │     │
769 │                you usually drink per sitting?        │    │     │      │     │
770 ╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
771 ])
772 AT_CLEANUP
773
774 AT_SETUP([CTABLES subtotals])
775 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
776 AT_DATA([ctables.sps],
777 [[GET 'nhtsa.sav'.
778 CTABLES /TABLE=qn105ba BY qns1
779     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
780 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
781     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
782 CTABLES /TABLE=qn105ba BY qns1
783     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
784     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
785 ]])
786 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
787                                                       Custom Tables
788 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
789 │                                                         │ S1. Including yourself, how many members of this household │
790 │                                                         │                    are age 16 or older?                    │
791 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
792 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
793 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
794 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
795 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
796 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
797 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
798 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
799 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
800 │                                              likely     │       │       │         │       │        │      │          │
801 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
802 │                                              unlikely   │       │       │         │       │        │      │          │
803 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
804 │                                              unlikely   │       │       │         │       │        │      │          │
805 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
806
807                                                       Custom Tables
808 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
809 │                                                        │  S1. Including yourself, how many members of this household │
810 │                                                        │                     are age 16 or older?                    │
811 │                                                        ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
812 │                                                        │        │        │        │        │       │        │  6 or  │
813 │                                                        │  None  │    1   │    2   │    3   │   4   │    5   │  more  │
814 │                                                        ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
815 │                                                        │        │        │        │        │ Column│        │        │
816 │                                                        │Column %│Column %│Column %│Column %│   %   │Column %│Column %│
817 ├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
818 │105b. How likely is it that drivers who have Almost     │       .│    9.5%│    8.2%│   12.4%│   9.9%│   20.0%│   23.8%│
819 │had too much to drink to drive safely will   certain    │        │        │        │        │       │        │        │
820 │A. Get stopped by the police?                Very likely│       .│   24.9%│   18.5%│   24.0%│  26.6%│   25.5%│   33.3%│
821 │                                             Somewhat   │       .│   38.3%│   41.9%│   38.6%│  37.5%│   36.4%│   23.8%│
822 │                                             likely     │        │        │        │        │       │        │        │
823 │                                             Subtotal   │        │   72.8%│   68.6%│   75.0%│  74.0%│   81.8%│   81.0%│
824 │                                             Somewhat   │       .│   18.1%│   21.7%│   16.8%│  16.7%│   10.9%│    9.5%│
825 │                                             unlikely   │        │        │        │        │       │        │        │
826 │                                             Very       │       .│    9.2%│    9.7%│    8.2%│   9.4%│    7.3%│    9.5%│
827 │                                             unlikely   │        │        │        │        │       │        │        │
828 │                                             Subtotal   │        │   27.2%│   31.4%│   25.0%│  26.0%│   18.2%│   19.0%│
829 ╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
830
831                                                       Custom Tables
832 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
833 │                                                         │ S1. Including yourself, how many members of this household │
834 │                                                         │                    are age 16 or older?                    │
835 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
836 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
837 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
838 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
839 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
840 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
841 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
842 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
843 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
844 │                                              likely     │       │       │         │       │        │      │          │
845 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
846 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
847 │                                              unlikely   │       │       │         │       │        │      │          │
848 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
849 │                                              unlikely   │       │       │         │       │        │      │          │
850 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
851 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
852 ])
853 AT_CLEANUP
854
855 AT_SETUP([CTABLES PCOMPUTE])
856 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
857 AT_DATA([ctables.sps],
858 [[GET 'nhtsa.sav'.
859 CTABLES
860     /PCOMPUTE &x=EXPR([3] + [4])
861     /PCOMPUTE &y=EXPR([4] + [5])
862     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
863     /PPROPERTIES &y LABEL='4+5'
864     /TABLE=qn105ba BY qns1
865     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
866 ]])
867 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
868                                                       Custom Tables
869 ╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
870 │                                                        │  S1. Including yourself, how many members of this household │
871 │                                                        │                     are age 16 or older?                    │
872 │                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
873 │                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
874 │                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
875 │                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
876 ├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
877 │105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
878 │had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
879 │A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
880 │                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
881 │                                             likely     │       │       │          │       │        │      │          │
882 │                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
883 │                                             unlikely   │       │       │          │       │        │      │          │
884 │                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
885 │                                             unlikely   │       │       │          │       │        │      │          │
886 ╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
887 ])
888 AT_CLEANUP
889
890 AT_SETUP([CTABLES CLABELS])
891 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
892 AT_DATA([ctables.sps],
893 [[GET 'nhtsa.sav'.
894 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
895 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
896 ]])
897 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
898                                                       Custom Tables
899 ╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
900 │       │                                                 S3a. GENDER:                                                 │
901 │       ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
902 │       │                         Male                         │                         Female                        │
903 │       ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
904 │       │  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 │
905 │       │ younger │   25  │  35  │  45  │  55  │   65  │ older │  younger │  25  │   35  │  45  │  55  │  65  │  older │
906 │       ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
907 │       │  Count  │ Count │ Count│ Count│ Count│ Count │ Count │   Count  │ Count│ Count │ Count│ Count│ Count│  Count │
908 ├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
909 │Age    │        0│    594│   476│   489│   526│    516│    531│         0│   505│    491│   548│   649│   731│     943│
910 │group  │         │       │      │      │      │       │       │          │      │       │      │      │      │        │
911 ╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
912
913                 Custom Tables
914 ╭──────────────────────────────┬────────────╮
915 │                              │S3a. GENDER:│
916 │                              ├────────────┤
917 │                              │    Count   │
918 ├──────────────────────────────┼────────────┤
919 │Age group 15 or younger Male  │           0│
920 │                        Female│           0│
921 │         ╶────────────────────┼────────────┤
922 │          16 to 25      Male  │         594│
923 │                        Female│         505│
924 │         ╶────────────────────┼────────────┤
925 │          26 to 35      Male  │         476│
926 │                        Female│         491│
927 │         ╶────────────────────┼────────────┤
928 │          36 to 45      Male  │         489│
929 │                        Female│         548│
930 │         ╶────────────────────┼────────────┤
931 │          46 to 55      Male  │         526│
932 │                        Female│         649│
933 │         ╶────────────────────┼────────────┤
934 │          56 to 65      Male  │         516│
935 │                        Female│         731│
936 │         ╶────────────────────┼────────────┤
937 │          66 or older   Male  │         531│
938 │                        Female│         943│
939 ╰──────────────────────────────┴────────────╯
940 ])
941 AT_CLEANUP
942
943 AT_SETUP([CTABLES missing values])
944 AT_DATA([ctables.sps],
945 [[DATA LIST LIST NOTABLE/x y.
946 BEGIN DATA.
947 1 1
948 1 2
949 1 3
950 1 4
951 1 5
952 1 .
953 2 1
954 2 2
955 2 3
956 2 4
957 2 5
958 2 .
959 3 1
960 3 2
961 3 3
962 3 4
963 3 5
964 3 .
965 4 1
966 4 2
967 4 3
968 4 4
969 4 5
970 4 .
971 5 1
972 5 2
973 5 3
974 5 4
975 5 5
976 5 .
977 . 1
978 . 2
979 . 3
980 . 4
981 . 5
982 . .
983 END DATA.
984 MISSING VALUES x (1, 2) y (2, 3).
985 VARIABLE LEVEL ALL (NOMINAL).
986
987 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
988     /CATEGORIES VARIABLES=ALL TOTAL=YES.
989 CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
990     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
991 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
992     /CATEGORIES VARIABLES=ALL TOTAL=YES
993     /SLABELS POSITION=ROW.
994 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
995     /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
996     /SLABELS POSITION=ROW.
997 CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
998     /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES 
999     /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES 
1000     /SLABELS POSITION=ROW.
1001 ]])
1002 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1003                                Custom Tables
1004 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1005 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1006 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1007 │x 3.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1008 │  4.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1009 │  5.00 │    6│   33.3%│           33.3%│           16.7%│       │       │
1010 │  Total│   18│  100.0%│          100.0%│          100.0%│     18│     36│
1011 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1012 dnl Note that Column Total N % doesn't add up to 100 because missing
1013 dnl values are included in the total but not shown as a category and this
1014 dnl is expected behavior.
1015
1016                                Custom Tables
1017 ╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
1018 │       │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
1019 ├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
1020 │x 1.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1021 │  2.00 │    6│   20.0%│             .0%│           16.7%│       │       │
1022 │  3.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1023 │  4.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1024 │  5.00 │    6│   20.0%│           33.3%│           16.7%│       │       │
1025 │  Total│   30│  100.0%│          100.0%│          100.0%│     18│     36│
1026 ╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
1027 dnl Note that Column Total N % doesn't add up to 100 because system-missing
1028 dnl values are included in the total but not shown as a category and this
1029 dnl is expected behavior.
1030
1031                      Custom Tables
1032 ╭────────────────────────┬───────────────────────────╮
1033 │                        │             y             │
1034 │                        ├──────┬──────┬──────┬──────┤
1035 │                        │ 1.00 │ 4.00 │ 5.00 │ Total│
1036 ├────────────────────────┼──────┼──────┼──────┼──────┤
1037 │x 3.00  Count           │     1│     1│     1│     3│
1038 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1039 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1040 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1041 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1042 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1043 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1044 │        Valid N         │      │      │      │     3│
1045 │        Total N         │      │      │      │     6│
1046 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1047 │  4.00  Count           │     1│     1│     1│     3│
1048 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1049 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1050 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1051 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1052 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1053 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1054 │        Valid N         │      │      │      │     3│
1055 │        Total N         │      │      │      │     6│
1056 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1057 │  5.00  Count           │     1│     1│     1│     3│
1058 │        Column %        │ 33.3%│ 33.3%│ 33.3%│     .│
1059 │        Column Valid N %│ 33.3%│ 33.3%│ 33.3%│     .│
1060 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│     .│
1061 │        Row %           │ 33.3%│ 33.3%│ 33.3%│100.0%│
1062 │        Row Valid N %   │ 33.3%│ 33.3%│ 33.3%│100.0%│
1063 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│100.0%│
1064 │        Valid N         │      │      │      │     3│
1065 │        Total N         │      │      │      │     6│
1066 │ ╶──────────────────────┼──────┼──────┼──────┼──────┤
1067 │  Total Count           │     3│     3│     3│     9│
1068 │        Column %        │100.0%│100.0%│100.0%│     .│
1069 │        Column Valid N %│100.0%│100.0%│100.0%│     .│
1070 │        Column Total N %│100.0%│100.0%│100.0%│     .│
1071 │        Row %           │     .│     .│     .│     .│
1072 │        Row Valid N %   │     .│     .│     .│     .│
1073 │        Row Total N %   │     .│     .│     .│     .│
1074 │        Valid N         │     3│     3│     3│     9│
1075 │        Total N         │     6│     6│     6│    36│
1076 ╰────────────────────────┴──────┴──────┴──────┴──────╯
1077
1078                             Custom Tables
1079 ╭────────────────────────┬─────────────────────────────────────────╮
1080 │                        │                    y                    │
1081 │                        ├──────┬──────┬──────┬──────┬──────┬──────┤
1082 │                        │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1083 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1084 │x 1.00  Count           │     1│     1│     1│     1│     1│     5│
1085 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1086 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1087 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1088 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1089 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1090 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1091 │        Valid N         │      │      │      │      │      │     0│
1092 │        Total N         │      │      │      │      │      │     6│
1093 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1094 │  2.00  Count           │     1│     1│     1│     1│     1│     5│
1095 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1096 │        Column Valid N %│   .0%│     .│     .│   .0%│   .0%│     .│
1097 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1098 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1099 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1100 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1101 │        Valid N         │      │      │      │      │      │     0│
1102 │        Total N         │      │      │      │      │      │     6│
1103 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1104 │  3.00  Count           │     1│     1│     1│     1│     1│     5│
1105 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1106 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1107 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1108 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1109 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1110 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1111 │        Valid N         │      │      │      │      │      │     3│
1112 │        Total N         │      │      │      │      │      │     6│
1113 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1114 │  4.00  Count           │     1│     1│     1│     1│     1│     5│
1115 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1116 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1117 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1118 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1119 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1120 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1121 │        Valid N         │      │      │      │      │      │     3│
1122 │        Total N         │      │      │      │      │      │     6│
1123 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1124 │  5.00  Count           │     1│     1│     1│     1│     1│     5│
1125 │        Column %        │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1126 │        Column Valid N %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
1127 │        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
1128 │        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
1129 │        Row Valid N %   │ 33.3%│   .0%│   .0%│ 33.3%│ 33.3%│100.0%│
1130 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1131 │        Valid N         │      │      │      │      │      │     3│
1132 │        Total N         │      │      │      │      │      │     6│
1133 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
1134 │  Total Count           │     5│     5│     5│     5│     5│    25│
1135 │        Column %        │100.0%│100.0%│100.0%│100.0%│100.0%│     .│
1136 │        Column Valid N %│100.0%│     .│     .│100.0%│100.0%│     .│
1137 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│     .│
1138 │        Row %           │     .│     .│     .│     .│     .│     .│
1139 │        Row Valid N %   │     .│     .│     .│     .│     .│     .│
1140 │        Row Total N %   │     .│     .│     .│     .│     .│     .│
1141 │        Valid N         │     3│     0│     0│     3│     3│     9│
1142 │        Total N         │     6│     6│     6│     6│     6│    36│
1143 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
1144
1145                         Custom Tables
1146 ╭────────────────────────┬──────────────────────────────────╮
1147 │                        │                 y                │
1148 │                        ├──────┬──────┬──────┬──────┬──────┤
1149 │                        │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
1150 ├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
1151 │x 1.00  Count           │     1│     1│     1│     1│     4│
1152 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1153 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
1154 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1155 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1156 │        Row Valid N %   │     .│     .│     .│     .│     .│
1157 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1158 │        Valid N         │      │      │      │      │     0│
1159 │        Total N         │      │      │      │      │     6│
1160 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1161 │  2.00  Count           │     1│     1│     1│     1│     4│
1162 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1163 │        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
1164 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1165 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1166 │        Row Valid N %   │     .│     .│     .│     .│     .│
1167 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1168 │        Valid N         │      │      │      │      │     0│
1169 │        Total N         │      │      │      │      │     6│
1170 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1171 │  3.00  Count           │     1│     1│     1│     1│     4│
1172 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1173 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
1174 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1175 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1176 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
1177 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1178 │        Valid N         │      │      │      │      │     3│
1179 │        Total N         │      │      │      │      │     6│
1180 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1181 │  4.00  Count           │     1│     1│     1│     1│     4│
1182 │        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
1183 │        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
1184 │        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
1185 │        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
1186 │        Row Valid N %   │ 33.3%│   .0%│ 33.3%│ 33.3%│100.0%│
1187 │        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
1188 │        Valid N         │      │      │      │      │     3│
1189 │        Total N         │      │      │      │      │     6│
1190 │ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
1191 │  Total Count           │     4│     4│     4│     4│    16│
1192 │        Column %        │100.0%│100.0%│100.0%│100.0%│     .│
1193 │        Column Valid N %│100.0%│     .│100.0%│100.0%│     .│
1194 │        Column Total N %│100.0%│100.0%│100.0%│100.0%│     .│
1195 │        Row %           │     .│     .│     .│     .│     .│
1196 │        Row Valid N %   │     .│     .│     .│     .│     .│
1197 │        Row Total N %   │     .│     .│     .│     .│     .│
1198 │        Valid N         │     2│     0│     2│     2│     6│
1199 │        Total N         │     5│     5│     5│     5│    30│
1200 ╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
1201 ])
1202 AT_CLEANUP
1203
1204 AT_SETUP([CTABLES SMISSING=LISTWISE])
1205 AT_KEYWORDS([SMISSING LISTWISE])
1206 AT_DATA([ctables.sps],
1207 [[DATA LIST LIST NOTABLE/x y z.
1208 BEGIN DATA.
1209 1  . 40
1210 1 10 50
1211 1 20 60
1212 1  .  .
1213 1 30  .
1214 END DATA.
1215 VARIABLE LEVEL x (NOMINAL).
1216
1217 CTABLES /TABLE (y + z) > x.
1218 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
1219
1220 * The following doesn't come out as listwise because the tables are
1221 separate, not linked by an > operator.
1222 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
1223 ]])
1224 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
1225   Custom Tables
1226 ╭────────┬─────╮
1227 │        │ Mean│
1228 ├────────┼─────┤
1229 │y x 1.00│20.00│
1230 ├────────┼─────┤
1231 │z x 1.00│50.00│
1232 ╰────────┴─────╯
1233
1234   Custom Tables
1235 ╭────────┬─────╮
1236 │        │ Mean│
1237 ├────────┼─────┤
1238 │y x 1.00│15.00│
1239 ├────────┼─────┤
1240 │z x 1.00│55.00│
1241 ╰────────┴─────╯
1242
1243   Custom Tables
1244 ╭────────┬─────╮
1245 │        │ Mean│
1246 ├────────┼─────┤
1247 │y x 1.00│20.00│
1248 ├────────┼─────┤
1249 │z x 1.00│50.00│
1250 ╰────────┴─────╯
1251 ])
1252 AT_CLEANUP