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