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