f71a3c572eb5dfb77cab2d24694878b7f3074fb7
[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 - EMPTY=INCLUDE.
31 dnl - TITLES: )DATE, )TIME, )TABLE.
32 dnl - SIGTEST
33 dnl - COMPARETEST
34 dnl - FORMAT:
35 dnl   * MINCOLWIDTH, MAXCOLWIDTH, UNITS.
36 dnl   * EMPTY.
37 dnl   * MISSING.
38 dnl - VLABELS.
39 dnl - SMISSING.
40 dnl - Test WEIGHT and adjustment weights.
41 dnl - PCOMPUTE and PPROPERTIES.
42 dnl - HIDESMALLCOUNTS.
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
195 AT_SETUP([CTABLES simple nesting])
196 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
197 AT_DATA([ctables.sps],
198 [[GET 'nhtsa.sav'.
199 CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
200   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
201 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
202   /CATEGORIES VARIABLES=qns3a TOTAL=YES
203   /CLABELS ROW=OPPOSITE.
204 ]])
205 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
206                                   Custom Tables
207 ╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
208 │                                                                 │     │ Table│
209 │                                                                 │Count│   %  │
210 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
211 │105b. How likely is it that drivers    Almost     S3a.     Male  │  297│    4%│
212 │who have had too much to drink to      certain    GENDER:  Female│  403│    6%│
213 │drive safely will A. Get stopped by                        Total │  700│   10%│
214 │the police?                           ╶──────────────────────────┼─────┼──────┤
215 │                                       Very       S3a.     Male  │  660│   10%│
216 │                                       likely     GENDER:  Female│  842│   12%│
217 │                                                           Total │ 1502│   22%│
218 │                                      ╶──────────────────────────┼─────┼──────┤
219 │                                       Somewhat   S3a.     Male  │ 1174│   17%│
220 │                                       likely     GENDER:  Female│ 1589│   23%│
221 │                                                           Total │ 2763│   40%│
222 │                                      ╶──────────────────────────┼─────┼──────┤
223 │                                       Somewhat   S3a.     Male  │  640│    9%│
224 │                                       unlikely   GENDER:  Female│  667│   10%│
225 │                                                           Total │ 1307│   19%│
226 │                                      ╶──────────────────────────┼─────┼──────┤
227 │                                       Very       S3a.     Male  │  311│    5%│
228 │                                       unlikely   GENDER:  Female│  298│    4%│
229 │                                                           Total │  609│    9%│
230 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
231 │105b. How likely is it that drivers    Almost     S3a.     Male  │  429│    6%│
232 │who have had too much to drink to      certain    GENDER:  Female│  671│   10%│
233 │drive safely will B. Have an accident?                     Total │ 1100│   16%│
234 │                                      ╶──────────────────────────┼─────┼──────┤
235 │                                       Very       S3a.     Male  │ 1104│   16%│
236 │                                       likely     GENDER:  Female│ 1715│   25%│
237 │                                                           Total │ 2819│   41%│
238 │                                      ╶──────────────────────────┼─────┼──────┤
239 │                                       Somewhat   S3a.     Male  │ 1203│   17%│
240 │                                       likely     GENDER:  Female│ 1214│   18%│
241 │                                                           Total │ 2417│   35%│
242 │                                      ╶──────────────────────────┼─────┼──────┤
243 │                                       Somewhat   S3a.     Male  │  262│    4%│
244 │                                       unlikely   GENDER:  Female│  168│    2%│
245 │                                                           Total │  430│    6%│
246 │                                      ╶──────────────────────────┼─────┼──────┤
247 │                                       Very       S3a.     Male  │   81│    1%│
248 │                                       unlikely   GENDER:  Female│   59│    1%│
249 │                                                           Total │  140│    2%│
250 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
251 │105b. How likely is it that drivers    Almost     S3a.     Male  │  539│    8%│
252 │who have had too much to drink to      certain    GENDER:  Female│  610│    9%│
253 │drive safely will C. Be convicted for                      Total │ 1149│   17%│
254 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
255 │                                       Very       S3a.     Male  │  988│   14%│
256 │                                       likely     GENDER:  Female│ 1049│   15%│
257 │                                                           Total │ 2037│   30%│
258 │                                      ╶──────────────────────────┼─────┼──────┤
259 │                                       Somewhat   S3a.     Male  │  822│   12%│
260 │                                       likely     GENDER:  Female│ 1210│   18%│
261 │                                                           Total │ 2032│   30%│
262 │                                      ╶──────────────────────────┼─────┼──────┤
263 │                                       Somewhat   S3a.     Male  │  446│    7%│
264 │                                       unlikely   GENDER:  Female│  548│    8%│
265 │                                                           Total │  994│   15%│
266 │                                      ╶──────────────────────────┼─────┼──────┤
267 │                                       Very       S3a.     Male  │  268│    4%│
268 │                                       unlikely   GENDER:  Female│  354│    5%│
269 │                                                           Total │  622│    9%│
270 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
271 │105b. How likely is it that drivers    Almost     S3a.     Male  │  498│    7%│
272 │who have had too much to drink to      certain    GENDER:  Female│  603│    9%│
273 │drive safely will D. Be arrested for                       Total │ 1101│   16%│
274 │drunk driving?                        ╶──────────────────────────┼─────┼──────┤
275 │                                       Very       S3a.     Male  │  805│   12%│
276 │                                       likely     GENDER:  Female│ 1029│   15%│
277 │                                                           Total │ 1834│   27%│
278 │                                      ╶──────────────────────────┼─────┼──────┤
279 │                                       Somewhat   S3a.     Male  │  975│   14%│
280 │                                       likely     GENDER:  Female│ 1332│   19%│
281 │                                                           Total │ 2307│   34%│
282 │                                      ╶──────────────────────────┼─────┼──────┤
283 │                                       Somewhat   S3a.     Male  │  535│    8%│
284 │                                       unlikely   GENDER:  Female│  560│    8%│
285 │                                                           Total │ 1095│   16%│
286 │                                      ╶──────────────────────────┼─────┼──────┤
287 │                                       Very       S3a.     Male  │  270│    4%│
288 │                                       unlikely   GENDER:  Female│  279│    4%│
289 │                                                           Total │  549│    8%│
290 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
291
292                                   Custom Tables
293 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
294 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
295 │                                 │ certain│likely│  likely │ unlikely│unlikely│
296 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
297 │                                 │        │ Table│         │         │        │
298 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
299 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
300 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
301 │GENDER:        is it that drivers│        │      │         │         │        │
302 │               who have had too  │        │      │         │         │        │
303 │               much to drink to  │        │      │         │         │        │
304 │               drive safely will │        │      │         │         │        │
305 │               A. Get stopped by │        │      │         │         │        │
306 │               the police?       │        │      │         │         │        │
307 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
308 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
309 │               is it that drivers│        │      │         │         │        │
310 │               who have had too  │        │      │         │         │        │
311 │               much to drink to  │        │      │         │         │        │
312 │               drive safely will │        │      │         │         │        │
313 │               A. Get stopped by │        │      │         │         │        │
314 │               the police?       │        │      │         │         │        │
315 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
316 │        Total  105b. How likely  │     10%│   22%│      40%│      19%│      9%│
317 │               is it that drivers│        │      │         │         │        │
318 │               who have had too  │        │      │         │         │        │
319 │               much to drink to  │        │      │         │         │        │
320 │               drive safely will │        │      │         │         │        │
321 │               A. Get stopped by │        │      │         │         │        │
322 │               the police?       │        │      │         │         │        │
323 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
324 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
325 │GENDER:        is it that drivers│        │      │         │         │        │
326 │               who have had too  │        │      │         │         │        │
327 │               much to drink to  │        │      │         │         │        │
328 │               drive safely will │        │      │         │         │        │
329 │               B. Have an        │        │      │         │         │        │
330 │               accident?         │        │      │         │         │        │
331 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
332 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
333 │               is it that drivers│        │      │         │         │        │
334 │               who have had too  │        │      │         │         │        │
335 │               much to drink to  │        │      │         │         │        │
336 │               drive safely will │        │      │         │         │        │
337 │               B. Have an        │        │      │         │         │        │
338 │               accident?         │        │      │         │         │        │
339 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
340 │        Total  105b. How likely  │     16%│   41%│      35%│       6%│      2%│
341 │               is it that drivers│        │      │         │         │        │
342 │               who have had too  │        │      │         │         │        │
343 │               much to drink to  │        │      │         │         │        │
344 │               drive safely will │        │      │         │         │        │
345 │               B. Have an        │        │      │         │         │        │
346 │               accident?         │        │      │         │         │        │
347 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
348 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
349 │GENDER:        is it that drivers│        │      │         │         │        │
350 │               who have had too  │        │      │         │         │        │
351 │               much to drink to  │        │      │         │         │        │
352 │               drive safely will │        │      │         │         │        │
353 │               C. Be convicted   │        │      │         │         │        │
354 │               for drunk driving?│        │      │         │         │        │
355 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
356 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
357 │               is it that drivers│        │      │         │         │        │
358 │               who have had too  │        │      │         │         │        │
359 │               much to drink to  │        │      │         │         │        │
360 │               drive safely will │        │      │         │         │        │
361 │               C. Be convicted   │        │      │         │         │        │
362 │               for drunk driving?│        │      │         │         │        │
363 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
364 │        Total  105b. How likely  │     17%│   30%│      30%│      15%│      9%│
365 │               is it that drivers│        │      │         │         │        │
366 │               who have had too  │        │      │         │         │        │
367 │               much to drink to  │        │      │         │         │        │
368 │               drive safely will │        │      │         │         │        │
369 │               C. Be convicted   │        │      │         │         │        │
370 │               for drunk driving?│        │      │         │         │        │
371 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
372 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
373 │GENDER:        is it that drivers│        │      │         │         │        │
374 │               who have had too  │        │      │         │         │        │
375 │               much to drink to  │        │      │         │         │        │
376 │               drive safely will │        │      │         │         │        │
377 │               D. Be arrested for│        │      │         │         │        │
378 │               drunk driving?    │        │      │         │         │        │
379 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
380 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
381 │               is it that drivers│        │      │         │         │        │
382 │               who have had too  │        │      │         │         │        │
383 │               much to drink to  │        │      │         │         │        │
384 │               drive safely will │        │      │         │         │        │
385 │               D. Be arrested for│        │      │         │         │        │
386 │               drunk driving?    │        │      │         │         │        │
387 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
388 │        Total  105b. How likely  │     16%│   27%│      34%│      16%│      8%│
389 │               is it that drivers│        │      │         │         │        │
390 │               who have had too  │        │      │         │         │        │
391 │               much to drink to  │        │      │         │         │        │
392 │               drive safely will │        │      │         │         │        │
393 │               D. Be arrested for│        │      │         │         │        │
394 │               drunk driving?    │        │      │         │         │        │
395 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
396 ])
397 AT_CLEANUP
398
399 AT_SETUP([CTABLES nesting and scale variables])
400 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
401 AT_DATA([ctables.sps],
402 [[GET 'nhtsa.sav'.
403 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
404 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
405 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1.
406 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
407 ]])
408 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
409                                   Custom Tables
410 ╭─────────────────────────────────────────────────────────────────┬────────────╮
411 │                                                                 │S3a. GENDER:│
412 │                                                                 ├─────┬──────┤
413 │                                                                 │ Male│Female│
414 │                                                                 ├─────┼──────┤
415 │                                                                 │ Mean│ Mean │
416 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
417 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
418 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
419 │                                                  week           │     │      │
420 │                                                  Once a week or │   44│    54│
421 │                                                  less           │     │      │
422 │                                                  Only certain   │   34│    41│
423 │                                                  times a year   │     │      │
424 │                                                  Never          │   39│    55│
425 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
426
427                                   Custom Tables
428 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
429 │                                                         │Minimum│Maximum│Mean│
430 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
431 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
432 │What is  GENDER:         months, has there been a        │       │       │    │
433 │your                     time when you felt you          │       │       │    │
434 │age?                     should cut down on your      No │     16│     86│  46│
435 │                         drinking?                       │       │       │    │
436 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
437 │                  Female 26. During the last 12       Yes│     16│     86│  43│
438 │                         months, has there been a        │       │       │    │
439 │                         time when you felt you          │       │       │    │
440 │                         should cut down on your      No │     16│     86│  48│
441 │                         drinking?                       │       │       │    │
442 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
443 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
444 │What is  GENDER:         months, has there been a        │       │       │    │
445 │your                     time when people criticized  No │     16│     86│  46│
446 │age?                     your drinking?                  │       │       │    │
447 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
448 │                  Female 27. During the last 12       Yes│     17│     69│  37│
449 │                         months, has there been a        │       │       │    │
450 │                         time when people criticized  No │     16│     86│  48│
451 │                         your drinking?                  │       │       │    │
452 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
453
454                                   Custom Tables
455 ╭──────────────────────────────────┬───────────────────────────────────────────╮
456 │                                  │S1. Including yourself, how many members of│
457 │                                  │    this household are age 16 or older?    │
458 │                                  ├──────┬───────┬──────┬──────┬───────┬──────┤
459 │                                  │      │       │      │      │       │ 6 or │
460 │                                  │   1  │   2   │   3  │   4  │   5   │ more │
461 │                                  ├──────┼───────┼──────┼──────┼───────┼──────┤
462 │                                  │Column│ Column│Column│Column│ Column│Column│
463 │                                  │   %  │   %   │   %  │   %  │   %   │   %  │
464 ├──────────────────────────────────┼──────┼───────┼──────┼──────┼───────┼──────┤
465 │Sa1.     RDD 105b. How    Almost  │  9.5%│   8.2%│ 12.4%│  9.9%│  20.0%│ 23.8%│
466 │SAMPLE       likely is it certain │      │       │      │      │       │      │
467 │SOURCE:      that drivers Very    │ 24.9%│  18.5%│ 24.0%│ 26.6%│  25.5%│ 33.3%│
468 │             who have had likely  │      │       │      │      │       │      │
469 │             too much to  Somewhat│ 38.3%│  41.9%│ 38.6%│ 37.5%│  36.4%│ 23.8%│
470 │             drink to     likely  │      │       │      │      │       │      │
471 │             drive safely Somewhat│ 18.1%│  21.7%│ 16.8%│ 16.7%│  10.9%│  9.5%│
472 │             will A. Get  unlikely│      │       │      │      │       │      │
473 │             stopped by   Very    │  9.2%│   9.7%│  8.2%│  9.4%│   7.3%│  9.5%│
474 │             the police?  unlikely│      │       │      │      │       │      │
475 ╰──────────────────────────────────┴──────┴───────┴──────┴──────┴───────┴──────╯
476
477                                   Custom Tables
478 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
479 │                                                              │    │    Std   │
480 │                                                              │Mean│ Deviation│
481 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
482 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
483 │group           typical month did you have one or more        │    │          │
484 │                alcoholic beverages to drink?                 │    │          │
485 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
486 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
487 │                typical month did you have one or more        │    │          │
488 │                alcoholic beverages to drink?                 │    │          │
489 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
490 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
491 │                typical month did you have one or more        │    │          │
492 │                alcoholic beverages to drink?                 │    │          │
493 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
494 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
495 │                typical month did you have one or more        │    │          │
496 │                alcoholic beverages to drink?                 │    │          │
497 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
498 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
499 │                typical month did you have one or more        │    │          │
500 │                alcoholic beverages to drink?                 │    │          │
501 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
502 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
503 │       older    typical month did you have one or more        │    │          │
504 │                alcoholic beverages to drink?                 │    │          │
505 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
506 ])
507 AT_CLEANUP
508
509
510 AT_SETUP([CTABLES SLABELS])
511 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
512 AT_DATA([ctables.sps],
513 [[GET 'nhtsa.sav'.
514 CTABLES /TABLE qn1 [COUNT COLPCT].
515 CTABLES /TABLE qn1 [COUNT COLPCT]
516     /SLABELS POSITION=ROW.
517 CTABLES /TABLE qn1 [COUNT COLPCT]
518     /SLABELS POSITION=ROW VISIBLE=NO.
519 ]])
520 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
521                                   Custom Tables
522 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
523 │                                                                │     │ Column│
524 │                                                                │Count│   %   │
525 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
526 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
527 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
528 │                                             Once a week or less│  361│   5.2%│
529 │                                             Only certain times │  130│   1.9%│
530 │                                             a year             │     │       │
531 │                                             Never              │  540│   7.7%│
532 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
533
534                                   Custom Tables
535 ╭────────────────────────────────────────────────────────────────────────┬─────╮
536 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
537 │other motor vehicle?                                             Column │66.9%│
538 │                                                                 %      │     │
539 │                                            ╶───────────────────────────┼─────┤
540 │                                             Several days a week Count  │ 1274│
541 │                                                                 Column │18.3%│
542 │                                                                 %      │     │
543 │                                            ╶───────────────────────────┼─────┤
544 │                                             Once a week or less Count  │  361│
545 │                                                                 Column │ 5.2%│
546 │                                                                 %      │     │
547 │                                            ╶───────────────────────────┼─────┤
548 │                                             Only certain times  Count  │  130│
549 │                                             a year              Column │ 1.9%│
550 │                                                                 %      │     │
551 │                                            ╶───────────────────────────┼─────┤
552 │                                             Never               Count  │  540│
553 │                                                                 Column │ 7.7%│
554 │                                                                 %      │     │
555 ╰────────────────────────────────────────────────────────────────────────┴─────╯
556
557                                   Custom Tables
558 ╭────────────────────────────────────────────────────────────────────────┬─────╮
559 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
560 │motor vehicle?                                                          │66.9%│
561 │                                                   Several days a week  │ 1274│
562 │                                                                        │18.3%│
563 │                                                   Once a week or less  │  361│
564 │                                                                        │ 5.2%│
565 │                                                   Only certain times a │  130│
566 │                                                   year                 │ 1.9%│
567 │                                                   Never                │  540│
568 │                                                                        │ 7.7%│
569 ╰────────────────────────────────────────────────────────────────────────┴─────╯
570 ])
571 AT_CLEANUP
572
573 AT_SETUP([CTABLES simple totals])
574 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
575 AT_DATA([ctables.sps],
576 [[GET 'nhtsa.sav'.
577 CTABLES /TABLE=qn17
578     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
579 CTABLES /TABLE=region > qn18 [MEAN, COUNT]
580     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
581 ]])
582 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
583                                   Custom Tables
584 ╭────────────────────────────────────────────────────────────────────────┬─────╮
585 │                                                                        │Count│
586 ├────────────────────────────────────────────────────────────────────────┼─────┤
587 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
588 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
589 │                                                      Light beer        │  620│
590 │                                                      Wine              │ 1418│
591 │                                                      Wine coolers      │  137│
592 │                                                      Hard liquor or    │  888│
593 │                                                      mixed drinks      │     │
594 │                                                      Flavored malt     │   83│
595 │                                                      drinks            │     │
596 │                                                      Number responding │ 4221│
597 ╰────────────────────────────────────────────────────────────────────────┴─────╯
598
599                                   Custom Tables
600 ╭───────────────────────────────────────────────────────────────────┬────┬─────╮
601 │                                                                   │Mean│Count│
602 ├───────────────────────────────────────────────────────────────────┼────┼─────┤
603 │Region NE       18. When you drink ANSWERFROM(QN17R1), about how   │4.36│  949│
604 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
605 │                sitting?                                           │    │     │
606 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
607 │       MW       18. When you drink ANSWERFROM(QN17R1), about how   │4.67│ 1027│
608 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
609 │                sitting?                                           │    │     │
610 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
611 │       S        18. When you drink ANSWERFROM(QN17R1), about how   │4.71│ 1287│
612 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
613 │                sitting?                                           │    │     │
614 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
615 │       W        18. When you drink ANSWERFROM(QN17R1), about how   │4.69│  955│
616 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
617 │                sitting?                                           │    │     │
618 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
619 │       All      18. When you drink ANSWERFROM(QN17R1), about how   │4.62│ 4218│
620 │       regions  many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
621 │                sitting?                                           │    │     │
622 ╰───────────────────────────────────────────────────────────────────┴────┴─────╯
623 ])
624 AT_CLEANUP
625
626 AT_SETUP([CTABLES subtotals])
627 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
628 AT_DATA([ctables.sps],
629 [[GET 'nhtsa.sav'.
630 CTABLES /TABLE=qn105ba BY qns1
631     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
632 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
633     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
634 CTABLES /TABLE=qn105ba BY qns1
635     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
636     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
637 ]])
638 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
639                                                       Custom Tables
640 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
641 │                                                         │ S1. Including yourself, how many members of this household │
642 │                                                         │                    are age 16 or older?                    │
643 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
644 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
645 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
646 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
647 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
648 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
649 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
650 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
651 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
652 │                                              likely     │       │       │         │       │        │      │          │
653 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
654 │                                              unlikely   │       │       │         │       │        │      │          │
655 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
656 │                                              unlikely   │       │       │         │       │        │      │          │
657 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
658
659                                                       Custom Tables
660 ╭────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────╮
661 │                                                            │     S1. Including yourself, how many members of this    │
662 │                                                            │              household are age 16 or older?             │
663 │                                                            ├─────────┬────────┬─────────┬────────┬─────────┬─────────┤
664 │                                                            │    1    │    2   │    3    │    4   │    5    │6 or more│
665 │                                                            ├─────────┼────────┼─────────┼────────┼─────────┼─────────┤
666 │                                                            │ Column %│Column %│ Column %│Column %│ Column %│ Column %│
667 ├────────────────────────────────────────────────────────────┼─────────┼────────┼─────────┼────────┼─────────┼─────────┤
668 │105b. How likely is it that drivers who have had Almost     │     9.5%│    8.2%│    12.4%│    9.9%│    20.0%│    23.8%│
669 │too much to drink to drive safely will A. Get    certain    │         │        │         │        │         │         │
670 │stopped by the police?                           Very likely│    24.9%│   18.5%│    24.0%│   26.6%│    25.5%│    33.3%│
671 │                                                 Somewhat   │    38.3%│   41.9%│    38.6%│   37.5%│    36.4%│    23.8%│
672 │                                                 likely     │         │        │         │        │         │         │
673 │                                                 Subtotal   │    72.8%│   68.6%│    75.0%│   74.0%│    81.8%│    81.0%│
674 │                                                 Somewhat   │    18.1%│   21.7%│    16.8%│   16.7%│    10.9%│     9.5%│
675 │                                                 unlikely   │         │        │         │        │         │         │
676 │                                                 Very       │     9.2%│    9.7%│     8.2%│    9.4%│     7.3%│     9.5%│
677 │                                                 unlikely   │         │        │         │        │         │         │
678 │                                                 Subtotal   │    27.2%│   31.4%│    25.0%│   26.0%│    18.2%│    19.0%│
679 ╰────────────────────────────────────────────────────────────┴─────────┴────────┴─────────┴────────┴─────────┴─────────╯
680
681                                                       Custom Tables
682 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
683 │                                                         │ S1. Including yourself, how many members of this household │
684 │                                                         │                    are age 16 or older?                    │
685 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
686 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
687 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
688 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
689 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
690 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
691 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
692 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
693 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
694 │                                              likely     │       │       │         │       │        │      │          │
695 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
696 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
697 │                                              unlikely   │       │       │         │       │        │      │          │
698 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
699 │                                              unlikely   │       │       │         │       │        │      │          │
700 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
701 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
702 ])
703 AT_CLEANUP