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