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