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