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