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