2-d subtotals work
[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 [TABLEPCT PCT8.0]
159   /CATEGORIES VARIABLES=qns3a TOTAL=NO.
160 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
161   /CATEGORIES VARIABLES=qns3a TOTAL=NO
162   /CLABELS ROW=OPPOSITE.
163 ]])
164 dnl XXX With TOTAL=YES above, the totals get included in the denominator so that
165 dnl the percentages are about half of the correct values.
166 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
167                                   Custom Tables
168 ╭───────────────────────────────────────────────────────────────────────┬──────╮
169 │                                                                       │ Table│
170 │                                                                       │   %  │
171 ├───────────────────────────────────────────────────────────────────────┼──────┤
172 │105b. How likely is it that drivers who     Almost      S3a.     Male  │    4%│
173 │have had too much to drink to drive safely  certain     GENDER:  Female│    6%│
174 │will A. Get stopped by the police?         ╶───────────────────────────┼──────┤
175 │                                            Very likely S3a.     Male  │   10%│
176 │                                                        GENDER:  Female│   12%│
177 │                                           ╶───────────────────────────┼──────┤
178 │                                            Somewhat    S3a.     Male  │   17%│
179 │                                            likely      GENDER:  Female│   23%│
180 │                                           ╶───────────────────────────┼──────┤
181 │                                            Somewhat    S3a.     Male  │    9%│
182 │                                            unlikely    GENDER:  Female│   10%│
183 │                                           ╶───────────────────────────┼──────┤
184 │                                            Very        S3a.     Male  │    5%│
185 │                                            unlikely    GENDER:  Female│    4%│
186 ├───────────────────────────────────────────────────────────────────────┼──────┤
187 │105b. How likely is it that drivers who     Almost      S3a.     Male  │    6%│
188 │have had too much to drink to drive safely  certain     GENDER:  Female│   10%│
189 │will B. Have an accident?                  ╶───────────────────────────┼──────┤
190 │                                            Very likely S3a.     Male  │   16%│
191 │                                                        GENDER:  Female│   25%│
192 │                                           ╶───────────────────────────┼──────┤
193 │                                            Somewhat    S3a.     Male  │   17%│
194 │                                            likely      GENDER:  Female│   18%│
195 │                                           ╶───────────────────────────┼──────┤
196 │                                            Somewhat    S3a.     Male  │    4%│
197 │                                            unlikely    GENDER:  Female│    2%│
198 │                                           ╶───────────────────────────┼──────┤
199 │                                            Very        S3a.     Male  │    1%│
200 │                                            unlikely    GENDER:  Female│    1%│
201 ├───────────────────────────────────────────────────────────────────────┼──────┤
202 │105b. How likely is it that drivers who     Almost      S3a.     Male  │    8%│
203 │have had too much to drink to drive safely  certain     GENDER:  Female│    9%│
204 │will C. Be convicted for drunk driving?    ╶───────────────────────────┼──────┤
205 │                                            Very likely S3a.     Male  │   14%│
206 │                                                        GENDER:  Female│   15%│
207 │                                           ╶───────────────────────────┼──────┤
208 │                                            Somewhat    S3a.     Male  │   12%│
209 │                                            likely      GENDER:  Female│   18%│
210 │                                           ╶───────────────────────────┼──────┤
211 │                                            Somewhat    S3a.     Male  │    7%│
212 │                                            unlikely    GENDER:  Female│    8%│
213 │                                           ╶───────────────────────────┼──────┤
214 │                                            Very        S3a.     Male  │    4%│
215 │                                            unlikely    GENDER:  Female│    5%│
216 ├───────────────────────────────────────────────────────────────────────┼──────┤
217 │105b. How likely is it that drivers who     Almost      S3a.     Male  │    7%│
218 │have had too much to drink to drive safely  certain     GENDER:  Female│    9%│
219 │will D. Be arrested for drunk driving?     ╶───────────────────────────┼──────┤
220 │                                            Very likely S3a.     Male  │   12%│
221 │                                                        GENDER:  Female│   15%│
222 │                                           ╶───────────────────────────┼──────┤
223 │                                            Somewhat    S3a.     Male  │   14%│
224 │                                            likely      GENDER:  Female│   19%│
225 │                                           ╶───────────────────────────┼──────┤
226 │                                            Somewhat    S3a.     Male  │    8%│
227 │                                            unlikely    GENDER:  Female│    8%│
228 │                                           ╶───────────────────────────┼──────┤
229 │                                            Very        S3a.     Male  │    4%│
230 │                                            unlikely    GENDER:  Female│    4%│
231 ╰───────────────────────────────────────────────────────────────────────┴──────╯
232
233                                   Custom Tables
234 ╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
235 │                                 │ Almost │ Very │ Somewhat│ Somewhat│  Very  │
236 │                                 │ certain│likely│  likely │ unlikely│unlikely│
237 │                                 ├────────┼──────┼─────────┼─────────┼────────┤
238 │                                 │        │ Table│         │         │        │
239 │                                 │ Table %│   %  │ Table % │ Table % │ Table %│
240 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
241 │S3a.    Male   105b. How likely  │      4%│   10%│      17%│       9%│      5%│
242 │GENDER:        is it that drivers│        │      │         │         │        │
243 │               who have had too  │        │      │         │         │        │
244 │               much to drink to  │        │      │         │         │        │
245 │               drive safely will │        │      │         │         │        │
246 │               A. Get stopped by │        │      │         │         │        │
247 │               the police?       │        │      │         │         │        │
248 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
249 │        Female 105b. How likely  │      6%│   12%│      23%│      10%│      4%│
250 │               is it that drivers│        │      │         │         │        │
251 │               who have had too  │        │      │         │         │        │
252 │               much to drink to  │        │      │         │         │        │
253 │               drive safely will │        │      │         │         │        │
254 │               A. Get stopped by │        │      │         │         │        │
255 │               the police?       │        │      │         │         │        │
256 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
257 │S3a.    Male   105b. How likely  │      6%│   16%│      17%│       4%│      1%│
258 │GENDER:        is it that drivers│        │      │         │         │        │
259 │               who have had too  │        │      │         │         │        │
260 │               much to drink to  │        │      │         │         │        │
261 │               drive safely will │        │      │         │         │        │
262 │               B. Have an        │        │      │         │         │        │
263 │               accident?         │        │      │         │         │        │
264 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
265 │        Female 105b. How likely  │     10%│   25%│      18%│       2%│      1%│
266 │               is it that drivers│        │      │         │         │        │
267 │               who have had too  │        │      │         │         │        │
268 │               much to drink to  │        │      │         │         │        │
269 │               drive safely will │        │      │         │         │        │
270 │               B. Have an        │        │      │         │         │        │
271 │               accident?         │        │      │         │         │        │
272 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
273 │S3a.    Male   105b. How likely  │      8%│   14%│      12%│       7%│      4%│
274 │GENDER:        is it that drivers│        │      │         │         │        │
275 │               who have had too  │        │      │         │         │        │
276 │               much to drink to  │        │      │         │         │        │
277 │               drive safely will │        │      │         │         │        │
278 │               C. Be convicted   │        │      │         │         │        │
279 │               for drunk driving?│        │      │         │         │        │
280 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
281 │        Female 105b. How likely  │      9%│   15%│      18%│       8%│      5%│
282 │               is it that drivers│        │      │         │         │        │
283 │               who have had too  │        │      │         │         │        │
284 │               much to drink to  │        │      │         │         │        │
285 │               drive safely will │        │      │         │         │        │
286 │               C. Be convicted   │        │      │         │         │        │
287 │               for drunk driving?│        │      │         │         │        │
288 ├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
289 │S3a.    Male   105b. How likely  │      7%│   12%│      14%│       8%│      4%│
290 │GENDER:        is it that drivers│        │      │         │         │        │
291 │               who have had too  │        │      │         │         │        │
292 │               much to drink to  │        │      │         │         │        │
293 │               drive safely will │        │      │         │         │        │
294 │               D. Be arrested for│        │      │         │         │        │
295 │               drunk driving?    │        │      │         │         │        │
296 │       ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
297 │        Female 105b. How likely  │      9%│   15%│      19%│       8%│      4%│
298 │               is it that drivers│        │      │         │         │        │
299 │               who have had too  │        │      │         │         │        │
300 │               much to drink to  │        │      │         │         │        │
301 │               drive safely will │        │      │         │         │        │
302 │               D. Be arrested for│        │      │         │         │        │
303 │               drunk driving?    │        │      │         │         │        │
304 ╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
305 ])
306 AT_CLEANUP
307
308 AT_SETUP([CTABLES nesting and scale variables])
309 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
310 AT_DATA([ctables.sps],
311 [[GET 'nhtsa.sav'.
312 CTABLES /TABLE=qnd1 > qn1 BY qns3a.
313 CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
314 CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1.
315 CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
316 ]])
317 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
318                                   Custom Tables
319 ╭─────────────────────────────────────────────────────────────────┬────────────╮
320 │                                                                 │S3a. GENDER:│
321 │                                                                 ├─────┬──────┤
322 │                                                                 │ Male│Female│
323 │                                                                 ├─────┼──────┤
324 │                                                                 │ Mean│ Mean │
325 ├─────────────────────────────────────────────────────────────────┼─────┼──────┤
326 │D1. AGE: What   1. How often do you usually drive Every day      │   46│    46│
327 │is your age?   a car or other motor vehicle?      Several days a │   51│    59│
328 │                                                  week           │     │      │
329 │                                                  Once a week or │   44│    54│
330 │                                                  less           │     │      │
331 │                                                  Only certain   │   34│    41│
332 │                                                  times a year   │     │      │
333 │                                                  Never          │   39│    55│
334 ╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
335
336                                   Custom Tables
337 ╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
338 │                                                         │Minimum│Maximum│Mean│
339 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
340 │D1. AGE: S3a.     Male   26. During the last 12       Yes│     16│     86│  42│
341 │What is  GENDER:         months, has there been a        │       │       │    │
342 │your                     time when you felt you          │       │       │    │
343 │age?                     should cut down on your      No │     16│     86│  46│
344 │                         drinking?                       │       │       │    │
345 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
346 │                  Female 26. During the last 12       Yes│     16│     86│  43│
347 │                         months, has there been a        │       │       │    │
348 │                         time when you felt you          │       │       │    │
349 │                         should cut down on your      No │     16│     86│  48│
350 │                         drinking?                       │       │       │    │
351 ├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
352 │D1. AGE: S3a.     Male   27. During the last 12       Yes│     16│     86│  38│
353 │What is  GENDER:         months, has there been a        │       │       │    │
354 │your                     time when people criticized  No │     16│     86│  46│
355 │age?                     your drinking?                  │       │       │    │
356 │                 ╶───────────────────────────────────────┼───────┼───────┼────┤
357 │                  Female 27. During the last 12       Yes│     17│     69│  37│
358 │                         months, has there been a        │       │       │    │
359 │                         time when people criticized  No │     16│     86│  48│
360 │                         your drinking?                  │       │       │    │
361 ╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
362
363                                   Custom Tables
364 ╭──────────────────────────────────┬───────────────────────────────────────────╮
365 │                                  │S1. Including yourself, how many members of│
366 │                                  │    this household are age 16 or older?    │
367 │                                  ├──────┬───────┬──────┬──────┬───────┬──────┤
368 │                                  │      │       │      │      │       │ 6 or │
369 │                                  │   1  │   2   │   3  │   4  │   5   │ more │
370 │                                  ├──────┼───────┼──────┼──────┼───────┼──────┤
371 │                                  │Column│ Column│Column│Column│ Column│Column│
372 │                                  │   %  │   %   │   %  │   %  │   %   │   %  │
373 ├──────────────────────────────────┼──────┼───────┼──────┼──────┼───────┼──────┤
374 │Sa1.     RDD 105b. How    Almost  │  9.5%│   8.2%│ 12.4%│  9.9%│  20.0%│ 23.8%│
375 │SAMPLE       likely is it certain │      │       │      │      │       │      │
376 │SOURCE:      that drivers Very    │ 24.9%│  18.5%│ 24.0%│ 26.6%│  25.5%│ 33.3%│
377 │             who have had likely  │      │       │      │      │       │      │
378 │             too much to  Somewhat│ 38.3%│  41.9%│ 38.6%│ 37.5%│  36.4%│ 23.8%│
379 │             drink to     likely  │      │       │      │      │       │      │
380 │             drive safely Somewhat│ 18.1%│  21.7%│ 16.8%│ 16.7%│  10.9%│  9.5%│
381 │             will A. Get  unlikely│      │       │      │      │       │      │
382 │             stopped by   Very    │  9.2%│   9.7%│  8.2%│  9.4%│   7.3%│  9.5%│
383 │             the police?  unlikely│      │       │      │      │       │      │
384 ╰──────────────────────────────────┴──────┴───────┴──────┴──────┴───────┴──────╯
385
386                                   Custom Tables
387 ╭──────────────────────────────────────────────────────────────┬────┬──────────╮
388 │                                                              │    │    Std   │
389 │                                                              │Mean│ Deviation│
390 ├──────────────────────────────────────────────────────────────┼────┼──────────┤
391 │Age    16 to 25 20. On how many of the thirty days in this    │ 5.2│       6.0│
392 │group           typical month did you have one or more        │    │          │
393 │                alcoholic beverages to drink?                 │    │          │
394 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
395 │       26 to 35 20. On how many of the thirty days in this    │ 4.7│       5.9│
396 │                typical month did you have one or more        │    │          │
397 │                alcoholic beverages to drink?                 │    │          │
398 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
399 │       36 to 45 20. On how many of the thirty days in this    │ 5.5│       6.8│
400 │                typical month did you have one or more        │    │          │
401 │                alcoholic beverages to drink?                 │    │          │
402 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
403 │       46 to 55 20. On how many of the thirty days in this    │ 5.8│       7.7│
404 │                typical month did you have one or more        │    │          │
405 │                alcoholic beverages to drink?                 │    │          │
406 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
407 │       56 to 65 20. On how many of the thirty days in this    │ 6.3│       8.2│
408 │                typical month did you have one or more        │    │          │
409 │                alcoholic beverages to drink?                 │    │          │
410 │      ╶───────────────────────────────────────────────────────┼────┼──────────┤
411 │       66 or    20. On how many of the thirty days in this    │ 7.1│       9.2│
412 │       older    typical month did you have one or more        │    │          │
413 │                alcoholic beverages to drink?                 │    │          │
414 ╰──────────────────────────────────────────────────────────────┴────┴──────────╯
415 ])
416 AT_CLEANUP
417
418
419 AT_SETUP([CTABLES SLABELS])
420 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
421 AT_DATA([ctables.sps],
422 [[GET 'nhtsa.sav'.
423 CTABLES /TABLE qn1 [COUNT COLPCT].
424 CTABLES /TABLE qn1 [COUNT COLPCT]
425     /SLABELS POSITION=ROW.
426 CTABLES /TABLE qn1 [COUNT COLPCT]
427     /SLABELS POSITION=ROW VISIBLE=NO.
428 ]])
429 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
430                                   Custom Tables
431 ╭────────────────────────────────────────────────────────────────┬─────┬───────╮
432 │                                                                │     │ Column│
433 │                                                                │Count│   %   │
434 ├────────────────────────────────────────────────────────────────┼─────┼───────┤
435 │ 1. How often do you usually drive a car or  Every day          │ 4667│  66.9%│
436 │other motor vehicle?                         Several days a week│ 1274│  18.3%│
437 │                                             Once a week or less│  361│   5.2%│
438 │                                             Only certain times │  130│   1.9%│
439 │                                             a year             │     │       │
440 │                                             Never              │  540│   7.7%│
441 ╰────────────────────────────────────────────────────────────────┴─────┴───────╯
442
443                                   Custom Tables
444 ╭────────────────────────────────────────────────────────────────────────┬─────╮
445 │ 1. How often do you usually drive a car or  Every day           Count  │ 4667│
446 │other motor vehicle?                                             Column │66.9%│
447 │                                                                 %      │     │
448 │                                            ╶───────────────────────────┼─────┤
449 │                                             Several days a week Count  │ 1274│
450 │                                                                 Column │18.3%│
451 │                                                                 %      │     │
452 │                                            ╶───────────────────────────┼─────┤
453 │                                             Once a week or less Count  │  361│
454 │                                                                 Column │ 5.2%│
455 │                                                                 %      │     │
456 │                                            ╶───────────────────────────┼─────┤
457 │                                             Only certain times  Count  │  130│
458 │                                             a year              Column │ 1.9%│
459 │                                                                 %      │     │
460 │                                            ╶───────────────────────────┼─────┤
461 │                                             Never               Count  │  540│
462 │                                                                 Column │ 7.7%│
463 │                                                                 %      │     │
464 ╰────────────────────────────────────────────────────────────────────────┴─────╯
465
466                                   Custom Tables
467 ╭────────────────────────────────────────────────────────────────────────┬─────╮
468 │ 1. How often do you usually drive a car or other  Every day            │ 4667│
469 │motor vehicle?                                                          │66.9%│
470 │                                                   Several days a week  │ 1274│
471 │                                                                        │18.3%│
472 │                                                   Once a week or less  │  361│
473 │                                                                        │ 5.2%│
474 │                                                   Only certain times a │  130│
475 │                                                   year                 │ 1.9%│
476 │                                                   Never                │  540│
477 │                                                                        │ 7.7%│
478 ╰────────────────────────────────────────────────────────────────────────┴─────╯
479 ])
480 AT_CLEANUP
481
482 AT_SETUP([CTABLES simple totals])
483 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
484 AT_DATA([ctables.sps],
485 [[GET 'nhtsa.sav'.
486 CTABLES /TABLE=qn17
487     /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
488 CTABLES /TABLE=region > qn18 [MEAN, COUNT]
489     /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
490 ]])
491 AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
492                                   Custom Tables
493 ╭────────────────────────────────────────────────────────────────────────┬─────╮
494 │                                                                        │Count│
495 ├────────────────────────────────────────────────────────────────────────┼─────┤
496 │17. When you drink alcoholic beverages, which ONE of  OR, something else│    2│
497 │the following beverages do you drink MOST OFTEN?      Beer              │ 1073│
498 │                                                      Light beer        │  620│
499 │                                                      Wine              │ 1418│
500 │                                                      Wine coolers      │  137│
501 │                                                      Hard liquor or    │  888│
502 │                                                      mixed drinks      │     │
503 │                                                      Flavored malt     │   83│
504 │                                                      drinks            │     │
505 │                                                      Number responding │ 4221│
506 ╰────────────────────────────────────────────────────────────────────────┴─────╯
507
508                                   Custom Tables
509 ╭───────────────────────────────────────────────────────────────────┬────┬─────╮
510 │                                                                   │Mean│Count│
511 ├───────────────────────────────────────────────────────────────────┼────┼─────┤
512 │Region NE       18. When you drink ANSWERFROM(QN17R1), about how   │4.36│  949│
513 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
514 │                sitting?                                           │    │     │
515 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
516 │       MW       18. When you drink ANSWERFROM(QN17R1), about how   │4.67│ 1027│
517 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
518 │                sitting?                                           │    │     │
519 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
520 │       S        18. When you drink ANSWERFROM(QN17R1), about how   │4.71│ 1287│
521 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
522 │                sitting?                                           │    │     │
523 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
524 │       W        18. When you drink ANSWERFROM(QN17R1), about how   │4.69│  955│
525 │                many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
526 │                sitting?                                           │    │     │
527 │      ╶────────────────────────────────────────────────────────────┼────┼─────┤
528 │       All      18. When you drink ANSWERFROM(QN17R1), about how   │4.62│ 4218│
529 │       regions  many ANSWERFROM(QN17R2) do you usually drink per   │    │     │
530 │                sitting?                                           │    │     │
531 ╰───────────────────────────────────────────────────────────────────┴────┴─────╯
532 ])
533 AT_CLEANUP
534
535 AT_SETUP([CTABLES subtotals])
536 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
537 AT_DATA([ctables.sps],
538 [[GET 'nhtsa.sav'.
539 CTABLES /TABLE=qn105ba BY qns1
540     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
541 CTABLES /TABLE=qn105ba [COLPCT] BY qns1
542     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
543 CTABLES /TABLE=qn105ba BY qns1
544     /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
545     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
546 ]])
547 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
548                                                       Custom Tables
549 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
550 │                                                         │ S1. Including yourself, how many members of this household │
551 │                                                         │                    are age 16 or older?                    │
552 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
553 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
554 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
555 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
556 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
557 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
558 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
559 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
560 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
561 │                                              likely     │       │       │         │       │        │      │          │
562 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
563 │                                              unlikely   │       │       │         │       │        │      │          │
564 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
565 │                                              unlikely   │       │       │         │       │        │      │          │
566 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
567
568                                                       Custom Tables
569 ╭────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────╮
570 │                                                            │     S1. Including yourself, how many members of this    │
571 │                                                            │              household are age 16 or older?             │
572 │                                                            ├─────────┬────────┬─────────┬────────┬─────────┬─────────┤
573 │                                                            │    1    │    2   │    3    │    4   │    5    │6 or more│
574 │                                                            ├─────────┼────────┼─────────┼────────┼─────────┼─────────┤
575 │                                                            │ Column %│Column %│ Column %│Column %│ Column %│ Column %│
576 ├────────────────────────────────────────────────────────────┼─────────┼────────┼─────────┼────────┼─────────┼─────────┤
577 │105b. How likely is it that drivers who have had Almost     │     4.8%│    4.1%│     6.2%│    4.9%│    10.0%│    11.9%│
578 │too much to drink to drive safely will A. Get    certain    │         │        │         │        │         │         │
579 │stopped by the police?                           Very likely│    12.5%│    9.2%│    12.0%│   13.3%│    12.7%│    16.7%│
580 │                                                 Somewhat   │    19.2%│   20.9%│    19.3%│   18.8%│    18.2%│    11.9%│
581 │                                                 likely     │         │        │         │        │         │         │
582 │                                                 Subtotal   │    36.4%│   34.3%│    37.5%│   37.0%│    40.9%│    40.5%│
583 │                                                 Somewhat   │     9.0%│   10.8%│     8.4%│    8.3%│     5.5%│     4.8%│
584 │                                                 unlikely   │         │        │         │        │         │         │
585 │                                                 Very       │     4.6%│    4.9%│     4.1%│    4.7%│     3.6%│     4.8%│
586 │                                                 unlikely   │         │        │         │        │         │         │
587 │                                                 Subtotal   │    13.6%│   15.7%│    12.5%│   13.0%│     9.1%│     9.5%│
588 ╰────────────────────────────────────────────────────────────┴─────────┴────────┴─────────┴────────┴─────────┴─────────╯
589
590                                                       Custom Tables
591 ╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
592 │                                                         │ S1. Including yourself, how many members of this household │
593 │                                                         │                    are age 16 or older?                    │
594 │                                                         ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
595 │                                                         │   1   │   2   │ Subtotal│   3   │    4   │   5  │ Subtotal │
596 │                                                         ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
597 │                                                         │ Count │ Count │  Count  │ Count │  Count │ Count│   Count  │
598 ├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
599 │105b. How likely is it that drivers who have  Almost     │    147│    246│      393│     62│      19│    11│        92│
600 │had too much to drink to drive safely will A. certain    │       │       │         │       │        │      │          │
601 │Get stopped by the police?                    Very likely│    384│    552│      936│    120│      51│    14│       185│
602 │                                              Somewhat   │    590│   1249│     1839│    193│      72│    20│       285│
603 │                                              likely     │       │       │         │       │        │      │          │
604 │                                              Subtotal   │   1121│   2047│     3168│    375│     142│    45│       562│
605 │                                              Somewhat   │    278│    647│      925│     84│      32│     6│       122│
606 │                                              unlikely   │       │       │         │       │        │      │          │
607 │                                              Very       │    141│    290│      431│     41│      18│     4│        63│
608 │                                              unlikely   │       │       │         │       │        │      │          │
609 │                                              Subtotal   │    419│    937│     1356│    125│      50│    10│       185│
610 ╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
611 ])
612 AT_CLEANUP