+AT_BANNER([CTABLES])
+
+dnl Known bugs:
+dnl TOTAL interaction with PCOMPUTE, e.g. the following
+dnl CTABLES
+dnl /PCOMPUTE &all_drivers=EXPR([1 THRU 2] + [3 THRU 4])
+dnl /PPROPERTIES &all_drivers LABEL='All Drivers'
+dnl /PCOMPUTE &pct_not_drivers=EXPR([5] / ([1 THRU 2] + [3 THRU 4] + [5]) * 100)
+dnl /PPROPERTIES &pct_not_drivers LABEL='% Not Drivers' FORMAT=COUNT PCT40.1
+dnl /TABLE=qn1 BY qns3a
+dnl /CATEGORIES VARIABLES=qns3a TOTAL=YES
+dnl /CATEGORIES VARIABLES=qn1 [1 THRU 2, SUBTOTAL='Frequent Drivers',
+dnl 3 THRU 4, SUBTOTAL='Infrequent Drivers',
+dnl &all_drivers, 5, &pct_not_drivers,
+dnl MISSING, SUBTOTAL='Not Drivers or Missing'].
+dnl yields gaps in the Total column:
+dnl ╭─────────────────────────────────────────────────────────────────────────┬──────────────────╮
+dnl │ │ S3a. GENDER: │
+dnl │ ├─────┬──────┬─────┤
+dnl │ │ Male│Female│Total│
+dnl │ ├─────┼──────┼─────┤
+dnl │ │Count│ Count│Count│
+dnl ├─────────────────────────────────────────────────────────────────────────┼─────┼──────┼─────┤
+dnl │ 1. How often do you usually drive a car or other Every day │ 2305│ 2362│ 4667│
+dnl │motor vehicle? Several days a week │ 440│ 834│ 1274│
+dnl │ Frequent Drivers │ 2745│ 3196│ │
+dnl │ Once a week or less │ 125│ 236│ 361│
+dnl │ Only certain times a │ 58│ 72│ 130│
+dnl │ year │ │ │ │
+dnl │ Infrequent Drivers │ 183│ 308│ │
+dnl │ All Drivers │ 2928│ 3504│ │
+dnl │ Never │ 192│ 348│ 540│
+dnl │ % Not Drivers │ 6.2%│ 9.0%│ │
+dnl │ Don't know │ 3│ 5│ 8│
+dnl │ Refused │ 9│ 10│ 19│
+dnl │ Not Drivers or │ 204│ 363│ │
+dnl │ Missing │ │ │ │
+dnl ╰─────────────────────────────────────────────────────────────────────────┴─────┴──────┴─────╯
+dnl Features not yet implemented:
+dnl - Multiple response sets
+dnl - MRSETS subcommand.
+dnl - CATEGORIES: Special case for explicit category specifications and multiple dichotomy sets.
+dnl - SIGTEST
+dnl - COMPARETEST
+dnl - Summary functions:
+dnl * .LCL and .UCL suffixes.
+dnl * .SE suffixes.
+dnl - CATEGORIES:
+dnl * Data-dependent sorting.
+
+AT_SETUP([CTABLES parsing])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /FORMAT MINCOLWIDTH=10 MAXCOLWIDTH=20 UNITS=POINTS EMPTY=ZERO MISSING="x"
+ /FORMAT MINCOLWIDTH=DEFAULT MAXCOLWIDTH=DEFAULT UNITS=INCHES EMPTY=BLANK MISSING="."
+ /FORMAT UNITS=CM EMPTY="(-)"
+ /VLABELS VARIABLES=qn1 DISPLAY=DEFAULT
+ /VLABELS VARIABLES=qn17 DISPLAY=NAME
+ /VLABELS VARIABLES=qns3a DISPLAY=LABEL
+ /VLABELS VARIABLES=qnd1 DISPLAY=BOTH
+ /VLABELS VARIABLES=qn20 DISPLAY=NONE
+ /MRSETS COUNTDUPLICATES=NO
+ /MRSETS COUNTDUPLICATES=YES
+ /SMISSING VARIABLE
+ /SMISSING LISTWISE
+ /WEIGHT VARIABLE=qns3a
+ /HIDESMALLCOUNTS
+ /HIDESMALLCOUNTS COUNT=10
+ /TABLE qnsa1
+ /SLABELS POSITION=COLUMN VISIBLE=YES
+ /SLABELS VISIBLE=NO POSITION=ROW
+ /SLABELS POSITION=LAYER
+ /CLABELS AUTO
+ /CLABELS ROWLABELS=OPPOSITE
+ /CRITERIA CILEVEL=50
+ /CATEGORIES VARIABLES=qn1 qn17
+ ORDER=A KEY=VALUE MISSING=INCLUDE TOTAL=YES LABEL="xyzzy"
+ POSITION=BEFORE EMPTY=INCLUDE.
+CTABLES /TABLE qnsa1 /CLABELS ROWLABELS=LAYER.
+CTABLES /TABLE qnsa1 /CLABELS COLLABELS=OPPOSITE.
+CTABLES /TABLE qnsa1 /CLABELS COLLABELS=LAYER.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+Count
+╭───────────────────┬────┬────╮
+│ │ RDD│CELL│
+├───────────────────┼────┼────┤
+│Sa1. SAMPLE SOURCE:│5392│1607│
+╰───────────────────┴────┴────╯
+
+ Custom Tables
+RDD
+╭───────────────────┬─────╮
+│ │Count│
+├───────────────────┼─────┤
+│Sa1. SAMPLE SOURCE:│ 5392│
+╰───────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────┬─────╮
+│ │Count│
+├────────────────────────┼─────┤
+│Sa1. SAMPLE SOURCE: RDD │ 5392│
+│ CELL│ 1607│
+╰────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────┬─────╮
+│ │Count│
+├────────────────────────┼─────┤
+│Sa1. SAMPLE SOURCE: RDD │ 5392│
+│ CELL│ 1607│
+╰────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES parsing - negative])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES.
+CTABLES /FORMAT MINCOLWIDTH='foo'.
+CTABLES /TABLE qn1 [**].
+CTABLES /TABLE qn1 [NOTAFUNCTION].
+CTABLES /TABLE (qn1.
+CTABLES /TABLE **.
+CTABLES /TABLE NOTAVAR.
+STRING string(A8).
+CTABLES /TABLE string[S].
+CTABLES /TABLE qn1 [PTILE 101].
+CTABLES /TABLE qn1 [MEAN F0.1].
+CTABLES /TABLE qn1 [MEAN NEGPAREN1.2].
+CTABLES /TABLE qn1 [MEAN NEGPAREN3.4].
+CTABLES /TABLE qn1 [MEAN TOTALS].
+CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [SUBTOTAL=x].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO **].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [LO THRU x].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1 THRU **].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['x' THRU **].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&**].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 101).
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=MEAN.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 MISSING=**.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 TOTAL=**.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 LABEL=**.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 POSITION=**.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 EMPTY=**.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 **.
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [1,2,3] **.
+CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[0]).
+CTABLES /PCOMPUTE &k=EXPR(SUBTOTAL[1**]).
+CTABLES /PCOMPUTE &k=EXPR([LO **]).
+CTABLES /PCOMPUTE &k=EXPR([LO THRU **]).
+CTABLES /PCOMPUTE &k=EXPR([1 THRU **]).
+CTABLES /PCOMPUTE &k=EXPR([1**]).
+CTABLES /PCOMPUTE &k=EXPR((1x)).
+CTABLES /PCOMPUTE **k.
+CTABLES /PCOMPUTE &1.
+CTABLES /PCOMPUTE &k**.
+CTABLES /PCOMPUTE &k=**.
+CTABLES /PCOMPUTE &k=EXPR**.
+CTABLES /PCOMPUTE &k=EXPR(1x).
+CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
+CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=NOTAFUNCTION.
+CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k FORMAT=PTILE **.
+CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k LABEL=**.
+CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k HIDESOURCECATS=**.
+CTABLES /PCOMPUTE &k=EXPR(1) /PPROPERTIES &k **.
+CTABLES /FORMAT EMPTY=**.
+CTABLES /FORMAT MISSING=**.
+CTABLES /FORMAT **.
+CTABLES /FORMAT MINCOLWIDTH=20 MAXCOLWIDTH=10/.
+CTABLES /VLABELS **.
+CTABLES /VLABELS VARIABLES=NOTAVAR.
+CTABLES /VLABELS VARIABLES=qn1 **.
+CTABLES /VLABELS VARIABLES=qn1 DISPLAY=**.
+CTABLES /MRSETS **.
+CTABLES /MRSETS COUNTDUPLICATES=**.
+CTABLES /SMISSING **.
+CTABLES /WEIGHT **.
+CTABLES /WEIGHT VARIABLE=NOTAVAR.
+CTABLES /HIDESMALLCOUNTS COUNT=1.
+CTABLES /QUUX.
+CTABLES /HIDESMALLCOUNTS COUNT=2.
+CTABLES /TABLE qn1**.
+CTABLES /TABLE qn1 /SLABELS POSITION=**.
+CTABLES /TABLE qn1 /SLABELS VISIBLE=**.
+CTABLES /TABLE qn1 /SLABELS **.
+CTABLES /TABLE qn1 /CLABELS ROWLABELS=**.
+CTABLES /TABLE qn1 /CLABELS COLLABELS=**.
+CTABLES /TABLE qn1 /CLABELS **.
+CTABLES /TABLE qn1 /CRITERIA **.
+CTABLES /TABLE qn1 /CRITERIA CILEVEL=101.
+CTABLES /TABLE qn1 /TITLES **.
+CTABLES /TABLE qn1 /SIGTEST TYPE=**.
+CTABLES /TABLE qn1 /SIGTEST ALPHA=**.
+CTABLES /TABLE qn1 /SIGTEST INCLUDEMRSETS=**.
+CTABLES /TABLE qn1 /SIGTEST CATEGORIES=**.
+CTABLES /TABLE qn1 /SIGTEST **.
+CTABLES /TABLE qn1 /COMPARETEST TYPE=**.
+CTABLES /TABLE qn1 /COMPARETEST ALPHA=**.
+CTABLES /TABLE qn1 /COMPARETEST ALPHA=0,5.
+CTABLES /TABLE qn1 /COMPARETEST ADJUST=**.
+CTABLES /TABLE qn1 /COMPARETEST INCLUDEMRSETS=**.
+CTABLES /TABLE qn1 /COMPARETEST MEANSVARIANCE=**.
+CTABLES /TABLE qn1 /COMPARETEST CATEGORIES=**.
+CTABLES /TABLE qn1 /COMPARETEST MERGE=**.
+CTABLES /TABLE qn1 /COMPARETEST STYLE=**.
+CTABLES /TABLE qn1 /COMPARETEST SHOWSIG=**.
+CTABLES /TABLE qn1 /COMPARETEST **.
+CTABLES /TABLE qn1 / **.
+CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CLABELS COLLABELS=OPPOSITE.
+CTABLES /TABLE qn20 > qnd1.
+CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
+NUMERIC datetime (DATETIME17.0).
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
+[[ctables.sps:2.8: error: CTABLES: Syntax error at end of command: expecting `/'.
+
+ctables.sps:3.29-3.33: error: CTABLES: Syntax error at `'foo'': Expected non-
+negative number for MINCOLWIDTH.
+
+ctables.sps:4.21-4.22: error: CTABLES: Syntax error at `**': expecting
+identifier.
+
+ctables.sps:5.21-5.32: error: CTABLES: Syntax error at `NOTAFUNCTION': Expecting
+summary function name.
+
+ctables.sps:6.20: error: CTABLES: Syntax error at end of command: expecting `@:}@'.
+
+ctables.sps:7.16-7.17: error: CTABLES: Syntax error at `**': expecting
+identifier.
+
+ctables.sps:8: error: CTABLES: NOTAVAR is not a variable name.
+
+ctables.sps:10.16-10.24: error: CTABLES: Cannot use string variable string as a
+scale variable.
+ 10 | CTABLES /TABLE string[S].
+ | ^~~~~~~~~
+
+ctables.sps:11.27-11.29: error: CTABLES: Syntax error at `101': Expected number
+between 0 and 100 for PTILE.
+
+ctables.sps:12: error: CTABLES: Output format F0.1 specifies width 0, but F
+requires a width between 1 and 40.
+
+ctables.sps:13.26-13.36: error: CTABLES: Syntax error at `NEGPAREN1.2': Output
+format NEGPAREN requires width 2 or greater.
+
+ctables.sps:14.26-14.36: error: CTABLES: Syntax error at `NEGPAREN3.4': Output
+format NEGPAREN requires width greater than decimals.
+
+ctables.sps:15.21-15.24: error: CTABLES: Summary function MEAN applies only to
+scale variables.
+ 15 | CTABLES /TABLE qn1 [MEAN TOTALS].
+ | ^~~~
+
+ctables.sps:15.16-15.18: note: CTABLES: 'QN1' is not a scale variable.
+ 15 | CTABLES /TABLE qn1 [MEAN TOTALS].
+ | ^~~
+
+ctables.sps:15.32: error: CTABLES: Syntax error at `@:>@': expecting `@<:@'.
+
+ctables.sps:16.21-16.24: error: CTABLES: Summary function MEAN applies only to
+scale variables.
+ 16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
+ | ^~~~
+
+ctables.sps:16.16-16.18: note: CTABLES: 'QN1' is not a scale variable.
+ 16 | CTABLES /TABLE qn1 [MEAN TOTALS[STDDEV]%].
+ | ^~~
+
+ctables.sps:16.40: error: CTABLES: Syntax error at `%': expecting `@:>@'.
+
+ctables.sps:17.56: error: CTABLES: Syntax error at `x': expecting string.
+
+ctables.sps:18.50-18.51: error: CTABLES: Syntax error at `**': expecting THRU.
+
+ctables.sps:19.55: error: CTABLES: Syntax error at `x': expecting number.
+
+ctables.sps:20.54-20.55: error: CTABLES: Syntax error at `**': expecting number.
+
+ctables.sps:21.56-21.57: error: CTABLES: Syntax error at `**': expecting string.
+
+ctables.sps:22.48-22.49: error: CTABLES: Syntax error at `**': expecting
+identifier.
+
+ctables.sps:23.47-23.48: error: CTABLES: Unknown postcompute &x.
+ 23 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&x].
+ | ^~
+
+ctables.sps:24.61-24.63: error: CTABLES: Syntax error at `101': Expected number
+between 0 and 100 for PTILE.
+
+ctables.sps:25.58: error: CTABLES: Syntax error at end of command: expecting
+`@:}@'.
+
+ctables.sps:26.54: error: CTABLES: Syntax error at end of command: expecting
+`@{:@'.
+
+ctables.sps:27.54-27.55: error: CTABLES: Syntax error at `**': expecting INCLUDE
+or EXCLUDE.
+
+ctables.sps:28.52-28.53: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:29.52-29.53: error: CTABLES: Syntax error at `**': expecting string.
+
+ctables.sps:30.55-30.56: error: CTABLES: Syntax error at `**': expecting BEFORE
+or AFTER.
+
+ctables.sps:31.52-31.53: error: CTABLES: Syntax error at `**': expecting INCLUDE
+or EXCLUDE.
+
+ctables.sps:32.46-32.47: error: CTABLES: Syntax error at `**': expecting ORDER,
+KEY, MISSING, TOTAL, LABEL, POSITION, or EMPTY.
+
+ctables.sps:33.54-33.55: error: CTABLES: Syntax error at `**': expecting TOTAL,
+LABEL, POSITION, or EMPTY.
+
+ctables.sps:34.36: error: CTABLES: Syntax error at `0': Expected positive
+integer for SUBTOTAL.
+
+ctables.sps:35.37-35.38: error: CTABLES: Syntax error at `**': expecting `@:>@'.
+
+ctables.sps:36.31-36.32: error: CTABLES: Syntax error at `**': expecting THRU.
+
+ctables.sps:37.36-37.37: error: CTABLES: Syntax error at `**': expecting number.
+
+ctables.sps:38.35-38.36: error: CTABLES: Syntax error at `**': expecting number.
+
+ctables.sps:39.29-39.30: error: CTABLES: Syntax error at `**': expecting `@:>@'.
+
+ctables.sps:40.29: error: CTABLES: Syntax error at `x': expecting `@:}@'.
+
+ctables.sps:41.19-41.20: error: CTABLES: Syntax error at `**': expecting &.
+
+ctables.sps:42.20: error: CTABLES: Syntax error at `1': expecting identifier.
+
+ctables.sps:43.21-43.22: error: CTABLES: Syntax error at `**': expecting `='.
+
+ctables.sps:44.22-44.23: error: CTABLES: Syntax error at `**': expecting EXPR.
+
+ctables.sps:45.26-45.27: error: CTABLES: Syntax error at `**': expecting `('.
+
+ctables.sps:46.28: error: CTABLES: Syntax error at `x': expecting `)'.
+
+ctables.sps:47.31-47.49: warning: CTABLES: New definition of &k will override
+the previous definition.
+ 47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
+ | ^~~~~~~~~~~~~~~~~~~
+
+ctables.sps:47.10-47.28: note: CTABLES: This is the previous definition.
+ 47 | CTABLES /PCOMPUTE &k=EXPR(1) /PCOMPUTE &k=EXPR(2).
+ | ^~~~~~~~~~~~~~~~~~~
+
+ctables.sps:47.50: error: CTABLES: Syntax error at end of command: expecting
+`/'.
+
+ctables.sps:48.53-48.64: error: CTABLES: Syntax error at `NOTAFUNCTION':
+Expecting summary function name.
+
+ctables.sps:49.59-49.60: error: CTABLES: Syntax error at `**': Expected number
+between 0 and 100 for PTILE.
+
+ctables.sps:50.52-50.53: error: CTABLES: Syntax error at `**': expecting string.
+
+ctables.sps:51.61-51.62: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:52.46-52.47: error: CTABLES: Syntax error at `**': expecting LABEL,
+FORMAT, or HIDESOURCECATS.
+
+ctables.sps:53.23-53.24: error: CTABLES: Syntax error at `**': expecting string.
+
+ctables.sps:54.25-54.26: error: CTABLES: Syntax error at `**': expecting string.
+
+ctables.sps:55.17-55.18: error: CTABLES: Syntax error at `**': expecting
+MINCOLWIDTH, MAXCOLWIDTH, UNITS, EMPTY, or MISSING.
+
+ctables.sps:56: error: CTABLES: MINCOLWIDTH must not be greater than
+MAXCOLWIDTH.
+
+ctables.sps:57.18-57.19: error: CTABLES: Syntax error at `**': expecting
+VARIABLES.
+
+ctables.sps:58: error: CTABLES: NOTAVAR is not a variable name.
+
+ctables.sps:59.32-59.33: error: CTABLES: Syntax error at `**': expecting
+DISPLAY.
+
+ctables.sps:60.40-60.41: error: CTABLES: Syntax error at `**': expecting
+DEFAULT, NAME, LABEL, BOTH, or NONE.
+
+ctables.sps:61.17-61.18: error: CTABLES: Syntax error at `**': expecting
+COUNTDUPLICATES.
+
+ctables.sps:62.33-62.34: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:63.19-63.20: error: CTABLES: Syntax error at `**': expecting
+VARIABLE or LISTWISE.
+
+ctables.sps:64.17-64.18: error: CTABLES: Syntax error at `**': expecting
+VARIABLE.
+
+ctables.sps:65: error: CTABLES: NOTAVAR is not a variable name.
+
+ctables.sps:66.32: error: CTABLES: Syntax error at `1': Expected integer 2 or
+greater for HIDESMALLCOUNTS COUNT.
+
+ctables.sps:67.10-67.13: error: CTABLES: Syntax error at `QUUX': expecting one
+of the following: FORMAT, VLABELS, MRSETS, SMISSING, PCOMPUTE, PPROPERTIES,
+WEIGHT, HIDESMALLCOUNTS, TABLE.
+
+ctables.sps:68.33: error: CTABLES: Syntax error at end of command: expecting
+`/'.
+
+ctables.sps:69.19-69.20: error: CTABLES: Syntax error at `**': expecting `/'.
+
+ctables.sps:70.38-70.39: error: CTABLES: Syntax error at `**': expecting COLUMN,
+ROW, or LAYER.
+
+ctables.sps:71.37-71.38: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:72.29-72.30: error: CTABLES: Syntax error at `**': expecting
+POSITION or VISIBLE.
+
+ctables.sps:73.39-73.40: error: CTABLES: Syntax error at `**': expecting
+OPPOSITE or LAYER.
+
+ctables.sps:74.39-74.40: error: CTABLES: Syntax error at `**': expecting
+OPPOSITE or LAYER.
+
+ctables.sps:75.29-75.30: error: CTABLES: Syntax error at `**': expecting AUTO,
+ROWLABELS, or COLLABELS.
+
+ctables.sps:76.30-76.31: error: CTABLES: Syntax error at `**': expecting
+CILEVEL.
+
+ctables.sps:77.38-77.40: error: CTABLES: Syntax error at `101': Expected number
+in @<:@0,100@:}@ for CILEVEL.
+
+ctables.sps:78.28-78.29: error: CTABLES: Syntax error at `**': expecting
+CAPTION, CORNER, or TITLE.
+
+ctables.sps:79.34-79.35: error: CTABLES: Syntax error at `**': expecting
+CHISQUARE.
+
+ctables.sps:80.35-80.36: error: CTABLES: Syntax error at `**': Expected number
+in @<:@0,1@:}@ for ALPHA.
+
+ctables.sps:81.43-81.44: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:82.40-82.41: error: CTABLES: Syntax error at `**': expecting
+ALLVISIBLE or SUBTOTALS.
+
+ctables.sps:83.29-83.30: error: CTABLES: Syntax error at `**': expecting TYPE,
+ALPHA, INCLUDEMRSETS, or CATEGORIES.
+
+ctables.sps:84.38-84.39: error: CTABLES: Syntax error at `**': expecting PROP or
+MEAN.
+
+ctables.sps:85.39-85.40: error: CTABLES: Syntax error at `**': Expected number
+in (0,1) for ALPHA.
+
+ctables.sps:86.39: error: CTABLES: Syntax error at `0': Expected number in (0,1)
+for ALPHA.
+
+ctables.sps:87.40-87.41: error: CTABLES: Syntax error at `**': expecting
+BONFERRONI, BH, or NONE.
+
+ctables.sps:88.47-88.48: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:89.47-89.48: error: CTABLES: Syntax error at `**': expecting ALLCATS
+or TESTEDCATS.
+
+ctables.sps:90.44-90.45: error: CTABLES: Syntax error at `**': expecting
+ALLVISIBLE or SUBTOTALS.
+
+ctables.sps:91.39-91.40: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:92.39-92.40: error: CTABLES: Syntax error at `**': expecting APA or
+SIMPLE.
+
+ctables.sps:93.41-93.42: error: CTABLES: Syntax error at `**': expecting YES or
+NO.
+
+ctables.sps:94.33-94.34: error: CTABLES: Syntax error at `**': expecting one of
+the following: TYPE, ALPHA, ADJUST, INCLUDEMRSETS, MEANSVARIANCE, CATEGORIES,
+MERGE, STYLE, SHOWSIG.
+
+ctables.sps:95.22-95.23: error: CTABLES: Syntax error at `**': expecting TABLE,
+SLABELS, CLABELS, CRITERIA, CATEGORIES, TITLES, SIGTEST, or COMPARETEST.
+
+ctables.sps:96: error: CTABLES: ROWLABELS and COLLABELS may not both be
+specified.
+
+ctables.sps:97.16-97.26: error: CTABLES: Cannot nest scale variables.
+ 97 | CTABLES /TABLE qn20 > qnd1.
+ | ^~~~~~~~~~~
+
+ctables.sps:97.16-97.19: note: CTABLES: This is an outer scale variable.
+ 97 | CTABLES /TABLE qn20 > qnd1.
+ | ^~~~
+
+ctables.sps:97.23-97.26: note: CTABLES: This is an inner scale variable.
+ 97 | CTABLES /TABLE qn20 > qnd1.
+ | ^~~~
+
+ctables.sps:98.16-98.35: error: CTABLES: Summaries may only be requested for
+categorical variables at the innermost nesting level.
+ 98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
+ | ^~~~~~~~~~~~~~~~~~~~
+
+ctables.sps:98.16-98.18: note: CTABLES: This outer categorical variable has a
+summary.
+ 98 | CTABLES /TABLE qn1 [ROWPCT] > qnsa1.
+ | ^~~
+
+ctables.sps:100.52-100.56: error: CTABLES: Failed to parse category
+specification as format DATETIME: Day (123) must be between 1 and 31..
+ 100 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=datetime ['123'].
+ | ^~~~~
+]])
+AT_CLEANUP
+
+AT_SETUP([CTABLES parsing - more negative])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
+CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc].
+CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
+
+STRING string(A8).
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
+CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
+
+CTABLES /TABLE qn1 /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn1 KEY=MEAN(qn1).
+
+CTABLES /TABLE qnd1 /CLABELS ROWLABELS=OPPOSITE.
+CTABLES /TABLE qn1 + string /CLABELS ROWLABELS=OPPOSITE.
+CTABLES /TABLE qn1 + qnsa1 /CLABELS ROWLABELS=OPPOSITE.
+CTABLES /TABLE qn105ba + qn105bb /CLABELS ROWLABELS=OPPOSITE /CATEGORIES VARIABLES=qn105ba [1,2,3].
+
+CTABLES /PCOMPUTE &x=EXPR(1**2**3).
+CTABLES /PCOMPUTE &x=EXPR([**]).
+CTABLES /PCOMPUTE &x=EXPR(**).
+
+CTABLES /TABLE.
+
+CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+
+CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 KEY=PTILE(qn1, 50).
+
+CTABLES /TABLE $mrset.
+
+CTABLES /TABLE qn113 /SIGTEST TYPE=CHISQUARE.
+CTABLES /TABLE qn113 /COMPARETEST TYPE=PROP.
+
+CTABLES /TABLE qn113 [COUNT.UCL].
+
+CTABLES /TABLE qn1 /CATEGORIES **.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [1],
+[[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a
+category not included in the category list.
+ 2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
+VARIABLES=qn1 [&pc].
+ |
+^~~
+
+ctables.sps:2.28-2.35: note: CTABLES: This is the missing category.
+ 2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
+VARIABLES=qn1 [&pc].
+ | ^~~~~~~~
+
+ctables.sps:2.76-2.79: note: CTABLES: To fix the problem, add subtotals to the
+list of categories here.
+ 2 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
+VARIABLES=qn1 [&pc].
+ |
+^~~~
+
+ctables.sps:3.73-3.75: error: CTABLES: Computed category &pc references a
+category not included in the category list.
+ 3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
+[&pc].
+ |
+^~~
+
+ctables.sps:3.28-3.32: note: CTABLES: This is the missing category.
+ 3 | CTABLES /PCOMPUTE &pc=EXPR(TOTAL) /TABLE qn1 /CATEGORIES VARIABLES=qn1
+[&pc].
+ | ^~~~~
+
+ctables.sps:3: note: CTABLES: To fix the problem, add TOTAL=YES to the
+variable's CATEGORIES specification.
+
+ctables.sps:4.76-4.99: error: CTABLES: These categories include 2 instances of
+SUBTOTAL or HSUBTOTAL, so references from computed categories must refer to
+subtotals by position, e.g. SUBTOTAL[1].
+ 4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
+VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
+ |
+^~~~~~~~~~~~~~~~~~~~~~~~
+
+ctables.sps:4.28-4.35: note: CTABLES: This is the reference that lacks a
+position.
+ 4 | CTABLES /PCOMPUTE &pc=EXPR(SUBTOTAL) /TABLE qn1 /CATEGORIES
+VARIABLES=qn1 [&pc, SUBTOTAL, SUBTOTAL].
+ | ^~~~~~~~
+
+ctables.sps:7.47-7.54: error: CTABLES: This category specification may be
+applied only to string variables, but this subcommand tries to apply it to
+numeric variable QN1.
+ 7 | CTABLES /TABLE qn1 /CATEGORIES VARIABLES=qn1 ['string'].
+ | ^~~~~~~~
+
+ctables.sps:8.53: error: CTABLES: This category specification may be applied
+only to numeric variables, but this subcommand tries to apply it to string
+variable string.
+ 8 | CTABLES /TABLE string /CATEGORIES VARIABLES=string [1].
+ | ^
+
+ctables.sps:10.74-10.86: error: CTABLES: Syntax error at `KEY=MEAN(qn1)': Data-
+dependent sorting is not implemented.
+
+ctables.sps:12: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
+moved to be categorical, but qnd1 is a scale variable.
+
+ctables.sps:13: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
+moved to have the same width, but QN1 has width 0 and string has width 8.
+
+ctables.sps:14: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
+moved to have the same value labels, but QN1 and QNSA1 have different value
+labels.
+
+ctables.sps:15: error: CTABLES: ROWLABELS=OPPOSITE requires the variables to be
+moved to have the same category specifications, but QN105BA and QN105BB have
+different category specifications.
+
+ctables.sps:17.27-17.33: warning: CTABLES: The exponentiation operator (`**') is
+left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'. To disable
+this warning, insert parentheses.
+ 17 | CTABLES /PCOMPUTE &x=EXPR(1**2**3).
+ | ^~~~~~~
+
+ctables.sps:17.35: error: CTABLES: Syntax error at end of command: expecting
+`/'.
+
+ctables.sps:18.28-18.29: error: CTABLES: Syntax error at `**'.
+
+ctables.sps:19.27-19.28: error: CTABLES: Syntax error at `**'.
+
+ctables.sps:21.15: error: CTABLES: Syntax error at end of command: At least one
+variable must be specified.
+
+ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
+
+ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
+summary.
+ 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+ | ^~~~~
+
+ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
+summary.
+ 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+ | ^~~~~
+
+ctables.sps:23.33-23.37: note: CTABLES: This variable on the columns axis has a
+summary.
+ 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+ | ^~~~~
+
+ctables.sps:23.33-23.37: note: CTABLES: This is a scale variable, so it always
+has a summary even if the syntax does not explicitly specify one.
+ 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+ | ^~~~~
+
+ctables.sps:25.46-25.63: error: CTABLES: Syntax error at `KEY=PTILE(qn1, 50)':
+Data-dependent sorting is not implemented.
+
+ctables.sps:27.16-27.21: error: CTABLES: Syntax error at `$mrset': Multiple
+response set support not implemented.
+
+ctables.sps:29.23-29.44: error: CTABLES: Syntax error at `SIGTEST
+TYPE=CHISQUARE': Support for SIGTEST not yet implemented.
+
+ctables.sps:30.35-30.43: error: CTABLES: Syntax error at `TYPE=PROP': Support
+for COMPARETEST not yet implemented.
+
+ctables.sps:32.23-32.31: error: CTABLES: Syntax error at `COUNT.UCL': Support
+for LCL, UCL, and SE summary functions is not yet implemented.
+
+ctables.sps:34.32-34.33: error: CTABLES: Syntax error at `**': expecting
+VARIABLES.
+]])
+AT_CLEANUP
+
+AT_SETUP([CTABLES one categorical variable])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE qn1.
+CTABLES /TABLE BY qn1.
+CTABLES /TABLE BY BY qn1.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│ 1. How often do you usually drive a car or other Every day │ 4667│
+│motor vehicle? Several days a week │ 1274│
+│ Once a week or less │ 361│
+│ Only certain times a │ 130│
+│ year │ │
+│ Never │ 540│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────────────────────────────╮
+│ 1. How often do you usually drive a car or other motor vehicle? │
+├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤
+│ │ Several days a │ Once a week or │ Only certain times a │ │
+│Every day│ week │ less │ year │Never│
+├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
+│ Count │ Count │ Count │ Count │Count│
+├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤
+│ 4667│ 1274│ 361│ 130│ 540│
+╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯
+
+Custom Tables
+Every day
+╭─────╮
+│Count│
+├─────┤
+│ 4667│
+╰─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES one string variable])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+STRING licensed(A8).
+MISSING VALUES licensed('DontKnow', 'Refused').
+RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
+CTABLES /TABLE licensed.
+CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
+* Notice that the string matching is case-sensitive.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
+CTABLES
+ /PCOMPUTE ¬yes=EXPR(['No']+['DontKnow']+['Refused'])
+ /PPROPERTIES ¬yes LABEL='Not Yes' HIDESOURCECATS=YES
+ /TABLE licensed
+ /CATEGORIES VARIABLES=licensed ['Yes', ¬yes, 'No', 'DontKnow', 'Refused'].
+CTABLES
+ /PCOMPUTE ¬yes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
+ /PPROPERTIES ¬yes LABEL='Not Yes' HIDESOURCECATS=YES
+ /TABLE licensed
+ /CATEGORIES VARIABLES=licensed ['Yes', ¬yes, 'DontKnow' THRU 'No', 'Refused'].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────┬─────╮
+│ │Count│
+├────────────┼─────┤
+│licensed No │ 572│
+│ Yes│ 6379│
+╰────────────┴─────╯
+
+ Custom Tables
+╭─────────────────┬─────┬───────╮
+│ │Count│Valid N│
+├─────────────────┼─────┼───────┤
+│licensed DontKnow│ 4│ │
+│ No │ 572│ │
+│ Refused │ 44│ │
+│ Yes │ 6379│ │
+│ Total │ 6999│ 6951│
+╰─────────────────┴─────┴───────╯
+
+ Custom Tables
+╭──────────────┬─────╮
+│ │Count│
+├──────────────┼─────┤
+│licensed Yes │ 6379│
+│ No │ 572│
+│ Total│ 6951│
+╰──────────────┴─────╯
+
+ Custom Tables
+╭──────────────┬─────╮
+│ │Count│
+├──────────────┼─────┤
+│licensed Yes │ 6379│
+│ no │ 0│
+│ Total│ 6379│
+╰──────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed No │ 572│
+│ Refused│ 44│
+│ Yes │ 6379│
+│ Total │ 6995│
+╰────────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed Yes │ 6379│
+│ Not Yes│ 620│
+╰────────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed Yes │ 6379│
+│ Not Yes│ 620│
+╰────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES one scale variable])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+DESCRIPTIVES qnd1.
+CTABLES /TABLE qnd1[COUNT, VALIDN, TOTALN, MEAN, STDDEV, MINIMUM, MAXIMUM].
+CTABLES /TABLE BY qnd1.
+CTABLES /TABLE BY BY qnd1.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Descriptive Statistics
+╭──────────────────────────┬────┬─────┬───────┬───────┬───────────╮
+│ │ N │ Mean│Std Dev│Minimum│ Maximum │
+├──────────────────────────┼────┼─────┼───────┼───────┼───────────┤
+│D1. AGE: What is your age?│6930│48.26│ 19.01│ 16│86 or older│
+│Valid N (listwise) │6999│ │ │ │ │
+│Missing N (listwise) │ 69│ │ │ │ │
+╰──────────────────────────┴────┴─────┴───────┴───────┴───────────╯
+
+ Custom Tables
+╭──────────────────────┬─────┬───────┬───────┬────┬────────────┬───────┬───────╮
+│ │ │ │ │ │ Std │ │ │
+│ │Count│Valid N│Total N│Mean│ Deviation │Minimum│Maximum│
+├──────────────────────┼─────┼───────┼───────┼────┼────────────┼───────┼───────┤
+│D1. AGE: What is your │ 6999│ 6930│ 6999│ 48│ 19│ 16│ 86│
+│age? │ │ │ │ │ │ │ │
+╰──────────────────────┴─────┴───────┴───────┴────┴────────────┴───────┴───────╯
+
+ Custom Tables
+╭──────────────────────────╮
+│D1. AGE: What is your age?│
+├──────────────────────────┤
+│ Mean │
+├──────────────────────────┤
+│ 48│
+╰──────────────────────────╯
+
+Custom Tables
+D1. AGE: What is your age?
+╭────╮
+│Mean│
+├────┤
+│ 48│
+╰────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES simple stacking])
+AT_KEYWORDS([stack stacked])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE qn105ba + qn105bb + qn105bc + qn105bd BY qns3a [COLPCT PCT8.0].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭───────────────────────────────────────────────────────────────┬──────────────╮
+│ │ S3a. GENDER: │
+│ ├──────┬───────┤
+│ │ Male │ Female│
+│ ├──────┼───────┤
+│ │Column│ Column│
+│ │ % │ % │
+├───────────────────────────────────────────────────────────────┼──────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ 10%│ 11%│
+│too much to drink to drive safely will A. Get certain │ │ │
+│stopped by the police? Very likely │ 21%│ 22%│
+│ Somewhat │ 38%│ 42%│
+│ likely │ │ │
+│ Somewhat │ 21%│ 18%│
+│ unlikely │ │ │
+│ Very │ 10%│ 8%│
+│ unlikely │ │ │
+├───────────────────────────────────────────────────────────────┼──────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ 14%│ 18%│
+│too much to drink to drive safely will B. Have an certain │ │ │
+│accident? Very likely │ 36%│ 45%│
+│ Somewhat │ 39%│ 32%│
+│ likely │ │ │
+│ Somewhat │ 9%│ 4%│
+│ unlikely │ │ │
+│ Very │ 3%│ 2%│
+│ unlikely │ │ │
+├───────────────────────────────────────────────────────────────┼──────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ 18%│ 16%│
+│too much to drink to drive safely will C. Be certain │ │ │
+│convicted for drunk driving? Very likely │ 32%│ 28%│
+│ Somewhat │ 27%│ 32%│
+│ likely │ │ │
+│ Somewhat │ 15%│ 15%│
+│ unlikely │ │ │
+│ Very │ 9%│ 9%│
+│ unlikely │ │ │
+├───────────────────────────────────────────────────────────────┼──────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ 16%│ 16%│
+│too much to drink to drive safely will D. Be certain │ │ │
+│arrested for drunk driving? Very likely │ 26%│ 27%│
+│ Somewhat │ 32%│ 35%│
+│ likely │ │ │
+│ Somewhat │ 17%│ 15%│
+│ unlikely │ │ │
+│ Very │ 9%│ 7%│
+│ unlikely │ │ │
+╰───────────────────────────────────────────────────────────────┴──────┴───────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES show or hide empty categories])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+IF (qn105ba = 2) qn105ba = 1.
+IF (qns3a = 1) qns3a = 2.
+CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0].
+CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
+ /CATEGORIES VAR=qn105ba EMPTY=EXCLUDE.
+CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
+ /CATEGORIES VAR=qns3a EMPTY=EXCLUDE.
+CTABLES /TABLE qn105ba BY qns3a [COLPCT PCT8.0]
+ /CATEGORIES VAR=ALL EMPTY=EXCLUDE.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬───────────────╮
+│ │ S3a. GENDER: │
+│ ├───────┬───────┤
+│ │ Male │ Female│
+│ ├───────┼───────┤
+│ │ Column│ Column│
+│ │ % │ % │
+├──────────────────────────────────────────────────────────────┼───────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ .│ 32%│
+│too much to drink to drive safely will A. Get certain │ │ │
+│stopped by the police? Very likely│ .│ 0%│
+│ Somewhat │ .│ 40%│
+│ likely │ │ │
+│ Somewhat │ .│ 19%│
+│ unlikely │ │ │
+│ Very │ .│ 9%│
+│ unlikely │ │ │
+╰──────────────────────────────────────────────────────────────┴───────┴───────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬───────────────╮
+│ │ S3a. GENDER: │
+│ ├───────┬───────┤
+│ │ Male │ Female│
+│ ├───────┼───────┤
+│ │ Column│ Column│
+│ │ % │ % │
+├──────────────────────────────────────────────────────────────┼───────┼───────┤
+│105b. How likely is it that drivers who have had Almost │ .│ 32%│
+│too much to drink to drive safely will A. Get certain │ │ │
+│stopped by the police? Somewhat │ .│ 40%│
+│ likely │ │ │
+│ Somewhat │ .│ 19%│
+│ unlikely │ │ │
+│ Very │ .│ 9%│
+│ unlikely │ │ │
+╰──────────────────────────────────────────────────────────────┴───────┴───────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────┬─────────╮
+│ │ S3a. │
+│ │ GENDER: │
+│ ├─────────┤
+│ │ Female │
+│ ├─────────┤
+│ │ Column %│
+├────────────────────────────────────────────────────────────────────┼─────────┤
+│105b. How likely is it that drivers who have had too Almost │ 32%│
+│much to drink to drive safely will A. Get stopped by certain │ │
+│the police? Very likely │ 0%│
+│ Somewhat │ 40%│
+│ likely │ │
+│ Somewhat │ 19%│
+│ unlikely │ │
+│ Very │ 9%│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────┴─────────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────┬─────────╮
+│ │ S3a. │
+│ │ GENDER: │
+│ ├─────────┤
+│ │ Female │
+│ ├─────────┤
+│ │ Column %│
+├────────────────────────────────────────────────────────────────────┼─────────┤
+│105b. How likely is it that drivers who have had too Almost │ 32%│
+│much to drink to drive safely will A. Get stopped by certain │ │
+│the police? Somewhat │ 40%│
+│ likely │ │
+│ Somewhat │ 19%│
+│ unlikely │ │
+│ Very │ 9%│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────┴─────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES sorting categories])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+IF (QND5A=6) QND5A=-1.
+IF (QND5A=5) QND5A=-2.
+CTABLES /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=A
+ /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=D
+ /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=A
+ /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=D.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic -2.00 │ 52│
+│background? -1.00 │ 78│
+│ Cuban │ 20│
+│ Mexican │ 311│
+│ Spanish │ 48│
+│ South American │ 34│
+│ Central American │ 0│
+│ Puerto Rican, OR │ 0│
+│ Something else │ 68│
+│ Multiple - cannot choose│ 7│
+│ one │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic Multiple - cannot choose│ 7│
+│background? one │ │
+│ Something else │ 68│
+│ Puerto Rican, OR │ 0│
+│ Central American │ 0│
+│ South American │ 34│
+│ Spanish │ 48│
+│ Mexican │ 311│
+│ Cuban │ 20│
+│ -1.00 │ 78│
+│ -2.00 │ 52│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic Central American │ 0│
+│background? Cuban │ 20│
+│ Mexican │ 311│
+│ Multiple - cannot choose│ 7│
+│ one │ │
+│ Puerto Rican, OR │ 0│
+│ Something else │ 68│
+│ South American │ 34│
+│ Spanish │ 48│
+│ -2.00 │ 52│
+│ -1.00 │ 78│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic Spanish │ 48│
+│background? South American │ 34│
+│ Something else │ 68│
+│ Puerto Rican, OR │ 0│
+│ Multiple - cannot choose│ 7│
+│ one │ │
+│ Mexican │ 311│
+│ Cuban │ 20│
+│ Central American │ 0│
+│ -1.00 │ 78│
+│ -2.00 │ 52│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES simple nesting])
+AT_KEYWORDS([nest nested])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
+ /CATEGORIES VARIABLES=qns3a TOTAL=YES.
+CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
+ /CATEGORIES VARIABLES=qns3a TOTAL=YES
+ /CLABELS ROW=OPPOSITE.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭─────────────────────────────────────────────────────────────────┬─────┬──────╮
+│ │ │ Table│
+│ │Count│ % │
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│105b. How likely is it that drivers Almost S3a. Male │ 297│ 4%│
+│who have had too much to drink to certain GENDER: Female│ 403│ 6%│
+│drive safely will A. Get stopped by Total │ 700│ 10%│
+│the police? ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 660│ 10%│
+│ likely GENDER: Female│ 842│ 12%│
+│ Total │ 1502│ 22%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 1174│ 17%│
+│ likely GENDER: Female│ 1589│ 23%│
+│ Total │ 2763│ 40%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 640│ 9%│
+│ unlikely GENDER: Female│ 667│ 10%│
+│ Total │ 1307│ 19%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 311│ 5%│
+│ unlikely GENDER: Female│ 298│ 4%│
+│ Total │ 609│ 9%│
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│105b. How likely is it that drivers Almost S3a. Male │ 429│ 6%│
+│who have had too much to drink to certain GENDER: Female│ 671│ 10%│
+│drive safely will B. Have an accident? Total │ 1100│ 16%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 1104│ 16%│
+│ likely GENDER: Female│ 1715│ 25%│
+│ Total │ 2819│ 41%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 1203│ 17%│
+│ likely GENDER: Female│ 1214│ 18%│
+│ Total │ 2417│ 35%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 262│ 4%│
+│ unlikely GENDER: Female│ 168│ 2%│
+│ Total │ 430│ 6%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 81│ 1%│
+│ unlikely GENDER: Female│ 59│ 1%│
+│ Total │ 140│ 2%│
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│105b. How likely is it that drivers Almost S3a. Male │ 539│ 8%│
+│who have had too much to drink to certain GENDER: Female│ 610│ 9%│
+│drive safely will C. Be convicted for Total │ 1149│ 17%│
+│drunk driving? ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 988│ 14%│
+│ likely GENDER: Female│ 1049│ 15%│
+│ Total │ 2037│ 30%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 822│ 12%│
+│ likely GENDER: Female│ 1210│ 18%│
+│ Total │ 2032│ 30%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 446│ 7%│
+│ unlikely GENDER: Female│ 548│ 8%│
+│ Total │ 994│ 15%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 268│ 4%│
+│ unlikely GENDER: Female│ 354│ 5%│
+│ Total │ 622│ 9%│
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│105b. How likely is it that drivers Almost S3a. Male │ 498│ 7%│
+│who have had too much to drink to certain GENDER: Female│ 603│ 9%│
+│drive safely will D. Be arrested for Total │ 1101│ 16%│
+│drunk driving? ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 805│ 12%│
+│ likely GENDER: Female│ 1029│ 15%│
+│ Total │ 1834│ 27%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 975│ 14%│
+│ likely GENDER: Female│ 1332│ 19%│
+│ Total │ 2307│ 34%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Somewhat S3a. Male │ 535│ 8%│
+│ unlikely GENDER: Female│ 560│ 8%│
+│ Total │ 1095│ 16%│
+│ ╶──────────────────────────┼─────┼──────┤
+│ Very S3a. Male │ 270│ 4%│
+│ unlikely GENDER: Female│ 279│ 4%│
+│ Total │ 549│ 8%│
+╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭─────────────────────────────────┬────────┬──────┬─────────┬─────────┬────────╮
+│ │ Almost │ Very │ Somewhat│ Somewhat│ Very │
+│ │ certain│likely│ likely │ unlikely│unlikely│
+│ ├────────┼──────┼─────────┼─────────┼────────┤
+│ │ │ Table│ │ │ │
+│ │ Table %│ % │ Table % │ Table % │ Table %│
+├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│S3a. Male 105b. How likely │ 4%│ 10%│ 17%│ 9%│ 5%│
+│GENDER: is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ A. Get stopped by │ │ │ │ │ │
+│ the police? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Female 105b. How likely │ 6%│ 12%│ 23%│ 10%│ 4%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ A. Get stopped by │ │ │ │ │ │
+│ the police? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Total 105b. How likely │ 10%│ 22%│ 40%│ 19%│ 9%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ A. Get stopped by │ │ │ │ │ │
+│ the police? │ │ │ │ │ │
+├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│S3a. Male 105b. How likely │ 6%│ 16%│ 17%│ 4%│ 1%│
+│GENDER: is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ B. Have an │ │ │ │ │ │
+│ accident? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Female 105b. How likely │ 10%│ 25%│ 18%│ 2%│ 1%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ B. Have an │ │ │ │ │ │
+│ accident? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Total 105b. How likely │ 16%│ 41%│ 35%│ 6%│ 2%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ B. Have an │ │ │ │ │ │
+│ accident? │ │ │ │ │ │
+├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│S3a. Male 105b. How likely │ 8%│ 14%│ 12%│ 7%│ 4%│
+│GENDER: is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ C. Be convicted │ │ │ │ │ │
+│ for drunk driving?│ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Female 105b. How likely │ 9%│ 15%│ 18%│ 8%│ 5%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ C. Be convicted │ │ │ │ │ │
+│ for drunk driving?│ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Total 105b. How likely │ 17%│ 30%│ 30%│ 15%│ 9%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ C. Be convicted │ │ │ │ │ │
+│ for drunk driving?│ │ │ │ │ │
+├─────────────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│S3a. Male 105b. How likely │ 7%│ 12%│ 14%│ 8%│ 4%│
+│GENDER: is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ D. Be arrested for│ │ │ │ │ │
+│ drunk driving? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Female 105b. How likely │ 9%│ 15%│ 19%│ 8%│ 4%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ D. Be arrested for│ │ │ │ │ │
+│ drunk driving? │ │ │ │ │ │
+│ ╶─────────────────────────┼────────┼──────┼─────────┼─────────┼────────┤
+│ Total 105b. How likely │ 16%│ 27%│ 34%│ 16%│ 8%│
+│ is it that drivers│ │ │ │ │ │
+│ who have had too │ │ │ │ │ │
+│ much to drink to │ │ │ │ │ │
+│ drive safely will │ │ │ │ │ │
+│ D. Be arrested for│ │ │ │ │ │
+│ drunk driving? │ │ │ │ │ │
+╰─────────────────────────────────┴────────┴──────┴─────────┴─────────┴────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES nesting and scale variables])
+AT_KEYWORDS([nest nested])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE=qnd1 > qn1 BY qns3a.
+CTABLES /TABLE=qnd1 [MINIMUM, MAXIMUM, MEAN] > qns3a > (qn26 + qn27).
+CTABLES /TABLE=qnsa1 > qn105ba [COLPCT] BY qns1
+ /CATEGORIES VAR=qnsa1 EMPTY=EXCLUDE.
+CTABLES /TABLE=AgeGroup > qn20 [MEAN F8.1, STDDEV F8.1].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭─────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │ Mean│ Mean │
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│D1. AGE: What 1. How often do you usually drive Every day │ 46│ 46│
+│is your age? a car or other motor vehicle? Several days a │ 51│ 59│
+│ week │ │ │
+│ Once a week or │ 44│ 54│
+│ less │ │ │
+│ Only certain │ 34│ 41│
+│ times a year │ │ │
+│ Never │ 39│ 55│
+╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭─────────────────────────────────────────────────────────┬───────┬───────┬────╮
+│ │Minimum│Maximum│Mean│
+├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
+│D1. AGE: S3a. Male 26. During the last 12 Yes│ 16│ 86│ 42│
+│What is GENDER: months, has there been a │ │ │ │
+│your time when you felt you │ │ │ │
+│age? should cut down on your No │ 16│ 86│ 46│
+│ drinking? │ │ │ │
+│ ╶───────────────────────────────────────┼───────┼───────┼────┤
+│ Female 26. During the last 12 Yes│ 16│ 86│ 43│
+│ months, has there been a │ │ │ │
+│ time when you felt you │ │ │ │
+│ should cut down on your No │ 16│ 86│ 48│
+│ drinking? │ │ │ │
+├─────────────────────────────────────────────────────────┼───────┼───────┼────┤
+│D1. AGE: S3a. Male 27. During the last 12 Yes│ 16│ 86│ 38│
+│What is GENDER: months, has there been a │ │ │ │
+│your time when people criticized No │ 16│ 86│ 46│
+│age? your drinking? │ │ │ │
+│ ╶───────────────────────────────────────┼───────┼───────┼────┤
+│ Female 27. During the last 12 Yes│ 17│ 69│ 37│
+│ months, has there been a │ │ │ │
+│ time when people criticized No │ 16│ 86│ 48│
+│ your drinking? │ │ │ │
+╰─────────────────────────────────────────────────────────┴───────┴───────┴────╯
+
+ Custom Tables
+╭─────────────────────────────┬────────────────────────────────────────────────╮
+│ │S1. Including yourself, how many members of this│
+│ │ household are age 16 or older? │
+│ ├──────┬──────┬──────┬──────┬──────┬──────┬──────┤
+│ │ │ │ │ │ │ │ 6 or │
+│ │ None │ 1 │ 2 │ 3 │ 4 │ 5 │ more │
+│ ├──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ │Column│Column│Column│Column│Column│Column│Column│
+│ │ % │ % │ % │ % │ % │ % │ % │
+├─────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Sa1. RDD 105b. Almost │ .│ 9.5%│ 8.2%│ 12.4%│ 9.9%│ 20.0%│ 23.8%│
+│SAMPLE How certain │ │ │ │ │ │ │ │
+│SOURCE: likely │ │ │ │ │ │ │ │
+│ is it Very │ .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
+│ that likely │ │ │ │ │ │ │ │
+│ drivers │ │ │ │ │ │ │ │
+│ who have │ │ │ │ │ │ │ │
+│ had too Somewhat│ .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
+│ much to likely │ │ │ │ │ │ │ │
+│ drink to │ │ │ │ │ │ │ │
+│ drive │ │ │ │ │ │ │ │
+│ safely Somewhat│ .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│ 9.5%│
+│ will A. unlikely│ │ │ │ │ │ │ │
+│ Get │ │ │ │ │ │ │ │
+│ stopped Very │ .│ 9.2%│ 9.7%│ 8.2%│ 9.4%│ 7.3%│ 9.5%│
+│ by the unlikely│ │ │ │ │ │ │ │
+│ police? │ │ │ │ │ │ │ │
+╰─────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬────┬──────────╮
+│ │ │ Std │
+│ │Mean│ Deviation│
+├──────────────────────────────────────────────────────────────┼────┼──────────┤
+│Age 16 to 25 20. On how many of the thirty days in this │ 5.2│ 6.0│
+│group typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+│ ╶───────────────────────────────────────────────────────┼────┼──────────┤
+│ 26 to 35 20. On how many of the thirty days in this │ 4.7│ 5.9│
+│ typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+│ ╶───────────────────────────────────────────────────────┼────┼──────────┤
+│ 36 to 45 20. On how many of the thirty days in this │ 5.5│ 6.8│
+│ typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+│ ╶───────────────────────────────────────────────────────┼────┼──────────┤
+│ 46 to 55 20. On how many of the thirty days in this │ 5.8│ 7.7│
+│ typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+│ ╶───────────────────────────────────────────────────────┼────┼──────────┤
+│ 56 to 65 20. On how many of the thirty days in this │ 6.3│ 8.2│
+│ typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+│ ╶───────────────────────────────────────────────────────┼────┼──────────┤
+│ 66 or 20. On how many of the thirty days in this │ 7.1│ 9.2│
+│ older typical month did you have one or more │ │ │
+│ alcoholic beverages to drink? │ │ │
+╰──────────────────────────────────────────────────────────────┴────┴──────────╯
+])
+AT_CLEANUP
+
+
+AT_SETUP([CTABLES SLABELS])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE qn1 [COUNT COLPCT].
+CTABLES /TABLE qn1 [COUNT COLPCT]
+ /SLABELS POSITION=ROW.
+CTABLES /TABLE qn1 [COUNT COLPCT]
+ /SLABELS POSITION=ROW VISIBLE=NO.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────┬─────┬───────╮
+│ │ │ Column│
+│ │Count│ % │
+├────────────────────────────────────────────────────────────────┼─────┼───────┤
+│ 1. How often do you usually drive a car or Every day │ 4667│ 66.9%│
+│other motor vehicle? Several days a week│ 1274│ 18.3%│
+│ Once a week or less│ 361│ 5.2%│
+│ Only certain times │ 130│ 1.9%│
+│ a year │ │ │
+│ Never │ 540│ 7.7%│
+╰────────────────────────────────────────────────────────────────┴─────┴───────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ 1. How often do you usually drive a car or Every day Count │ 4667│
+│other motor vehicle? Column │66.9%│
+│ % │ │
+│ ╶───────────────────────────┼─────┤
+│ Several days a week Count │ 1274│
+│ Column │18.3%│
+│ % │ │
+│ ╶───────────────────────────┼─────┤
+│ Once a week or less Count │ 361│
+│ Column │ 5.2%│
+│ % │ │
+│ ╶───────────────────────────┼─────┤
+│ Only certain times Count │ 130│
+│ a year Column │ 1.9%│
+│ % │ │
+│ ╶───────────────────────────┼─────┤
+│ Never Count │ 540│
+│ Column │ 7.7%│
+│ % │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ 1. How often do you usually drive a car or other Every day │ 4667│
+│motor vehicle? │66.9%│
+│ Several days a week │ 1274│
+│ │18.3%│
+│ Once a week or less │ 361│
+│ │ 5.2%│
+│ Only certain times a │ 130│
+│ year │ 1.9%│
+│ Never │ 540│
+│ │ 7.7%│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES simple totals])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE=qn17
+ /CATEGORIES VARIABLES=qn17 TOTAL=YES LABEL='Number responding'.
+DESCRIPTIVES qn18/STATISTICS=MEAN.
+CTABLES /TABLE=region > qn18 [MEAN, COUNT, VALIDN, TOTALN]
+ /CATEGORIES VARIABLES=region TOTAL=YES LABEL='All regions'.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│17. When you drink alcoholic beverages, which ONE of OR, something else│ 2│
+│the following beverages do you drink MOST OFTEN? Beer │ 1073│
+│ Light beer │ 620│
+│ Wine │ 1418│
+│ Wine coolers │ 137│
+│ Hard liquor or │ 888│
+│ mixed drinks │ │
+│ Flavored malt │ 83│
+│ drinks │ │
+│ Number responding │ 4221│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Descriptive Statistics
+╭────────────────────────────────────────────────────────────────────┬────┬────╮
+│ │ N │Mean│
+├────────────────────────────────────────────────────────────────────┼────┼────┤
+│18. When you drink ANSWERFROM(QN17R1), about how many │4218│4.62│
+│ANSWERFROM(QN17R2) do you usually drink per sitting? │ │ │
+│Valid N (listwise) │6999│ │
+│Missing N (listwise) │2781│ │
+╰────────────────────────────────────────────────────────────────────┴────┴────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────┬────┬─────┬──────┬─────╮
+│ │ │ │ Valid│Total│
+│ │Mean│Count│ N │ N │
+├──────────────────────────────────────────────────────┼────┼─────┼──────┼─────┤
+│Region NE 18. When you drink ANSWERFROM(QN17R1),│4.36│ 1409│ 949│ 1409│
+│ about how many ANSWERFROM(QN17R2) do │ │ │ │ │
+│ you usually drink per sitting? │ │ │ │ │
+│ ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
+│ MW 18. When you drink ANSWERFROM(QN17R1),│4.67│ 1654│ 1027│ 1654│
+│ about how many ANSWERFROM(QN17R2) do │ │ │ │ │
+│ you usually drink per sitting? │ │ │ │ │
+│ ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
+│ S 18. When you drink ANSWERFROM(QN17R1),│4.71│ 2390│ 1287│ 2390│
+│ about how many ANSWERFROM(QN17R2) do │ │ │ │ │
+│ you usually drink per sitting? │ │ │ │ │
+│ ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
+│ W 18. When you drink ANSWERFROM(QN17R1),│4.69│ 1546│ 955│ 1546│
+│ about how many ANSWERFROM(QN17R2) do │ │ │ │ │
+│ you usually drink per sitting? │ │ │ │ │
+│ ╶───────────────────────────────────────────────┼────┼─────┼──────┼─────┤
+│ All 18. When you drink ANSWERFROM(QN17R1),│4.62│ 6999│ 4218│ 6999│
+│ regions about how many ANSWERFROM(QN17R2) do │ │ │ │ │
+│ you usually drink per sitting? │ │ │ │ │
+╰──────────────────────────────────────────────────────┴────┴─────┴──────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES subtotals])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE=qn105ba BY qns1
+ /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
+CTABLES /TABLE=qn105ba [COLPCT] BY qns1
+ /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL].
+CTABLES /TABLE=qn105ba BY qns1
+ /CATEGORIES VARIABLES=qn105ba [1, 2, 3, SUBTOTAL, 4, 5, SUBTOTAL]
+ /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, SUBTOTAL].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
+│ │ S1. Including yourself, how many members of this household │
+│ │ are age 16 or older? │
+│ ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
+│ │ 1 │ 2 │ Subtotal│ 3 │ 4 │ 5 │ Subtotal │
+│ ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│ │ Count │ Count │ Count │ Count │ Count │ Count│ Count │
+├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│105b. How likely is it that drivers who have Almost │ 147│ 246│ 393│ 62│ 19│ 11│ 92│
+│had too much to drink to drive safely will A. certain │ │ │ │ │ │ │ │
+│Get stopped by the police? Very likely│ 384│ 552│ 936│ 120│ 51│ 14│ 185│
+│ Somewhat │ 590│ 1249│ 1839│ 193│ 72│ 20│ 285│
+│ likely │ │ │ │ │ │ │ │
+│ Somewhat │ 278│ 647│ 925│ 84│ 32│ 6│ 122│
+│ unlikely │ │ │ │ │ │ │ │
+│ Very │ 141│ 290│ 431│ 41│ 18│ 4│ 63│
+│ unlikely │ │ │ │ │ │ │ │
+╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
+│ │ S1. Including yourself, how many members of this household │
+│ │ are age 16 or older? │
+│ ├────────┬────────┬────────┬────────┬───────┬────────┬────────┤
+│ │ │ │ │ │ │ │ 6 or │
+│ │ None │ 1 │ 2 │ 3 │ 4 │ 5 │ more │
+│ ├────────┼────────┼────────┼────────┼───────┼────────┼────────┤
+│ │ │ │ │ │ Column│ │ │
+│ │Column %│Column %│Column %│Column %│ % │Column %│Column %│
+├────────────────────────────────────────────────────────┼────────┼────────┼────────┼────────┼───────┼────────┼────────┤
+│105b. How likely is it that drivers who have Almost │ .│ 9.5%│ 8.2%│ 12.4%│ 9.9%│ 20.0%│ 23.8%│
+│had too much to drink to drive safely will certain │ │ │ │ │ │ │ │
+│A. Get stopped by the police? Very likely│ .│ 24.9%│ 18.5%│ 24.0%│ 26.6%│ 25.5%│ 33.3%│
+│ Somewhat │ .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
+│ likely │ │ │ │ │ │ │ │
+│ Subtotal │ │ 72.8%│ 68.6%│ 75.0%│ 74.0%│ 81.8%│ 81.0%│
+│ Somewhat │ .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│ 9.5%│
+│ unlikely │ │ │ │ │ │ │ │
+│ Very │ .│ 9.2%│ 9.7%│ 8.2%│ 9.4%│ 7.3%│ 9.5%│
+│ unlikely │ │ │ │ │ │ │ │
+│ Subtotal │ │ 27.2%│ 31.4%│ 25.0%│ 26.0%│ 18.2%│ 19.0%│
+╰────────────────────────────────────────────────────────┴────────┴────────┴────────┴────────┴───────┴────────┴────────╯
+
+ Custom Tables
+╭─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────╮
+│ │ S1. Including yourself, how many members of this household │
+│ │ are age 16 or older? │
+│ ├───────┬───────┬─────────┬───────┬────────┬──────┬──────────┤
+│ │ 1 │ 2 │ Subtotal│ 3 │ 4 │ 5 │ Subtotal │
+│ ├───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│ │ Count │ Count │ Count │ Count │ Count │ Count│ Count │
+├─────────────────────────────────────────────────────────┼───────┼───────┼─────────┼───────┼────────┼──────┼──────────┤
+│105b. How likely is it that drivers who have Almost │ 147│ 246│ 393│ 62│ 19│ 11│ 92│
+│had too much to drink to drive safely will A. certain │ │ │ │ │ │ │ │
+│Get stopped by the police? Very likely│ 384│ 552│ 936│ 120│ 51│ 14│ 185│
+│ Somewhat │ 590│ 1249│ 1839│ 193│ 72│ 20│ 285│
+│ likely │ │ │ │ │ │ │ │
+│ Subtotal │ 1121│ 2047│ 3168│ 375│ 142│ 45│ 562│
+│ Somewhat │ 278│ 647│ 925│ 84│ 32│ 6│ 122│
+│ unlikely │ │ │ │ │ │ │ │
+│ Very │ 141│ 290│ 431│ 41│ 18│ 4│ 63│
+│ unlikely │ │ │ │ │ │ │ │
+│ Subtotal │ 419│ 937│ 1356│ 125│ 50│ 10│ 185│
+╰─────────────────────────────────────────────────────────┴───────┴───────┴─────────┴───────┴────────┴──────┴──────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES PCOMPUTE])
+AT_KEYWORDS([postcompute])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /PCOMPUTE &x=EXPR([3] + [4])
+ /PCOMPUTE &y=EXPR([4] + [5])
+ /PPROPERTIES &x LABEL='3+4' FORMAT=COUNT F8.2
+ /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]'
+ /TABLE=qn105ba [COUNT, ROWPCT] BY qns1
+ /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL] TOTAL=YES
+
+* Adding HIDESOURCECATS=YES for one PPROPERTIES.
+CTABLES
+ /PCOMPUTE &x=EXPR([3] + [4])
+ /PCOMPUTE &y=EXPR([4] + [5])
+ /PPROPERTIES &x LABEL='3+4' FORMAT=COUNT F8.2
+ /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]' HIDESOURCECATS=YES
+ /TABLE=qn105ba [COUNT, ROWPCT] BY qns1
+ /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL] TOTAL=YES
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
+ Custom Tables
+╭───────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│ │ S1. Including yourself, how many members of this household are age 16 or older? │
+│ ├───────────┬───────────┬───────────┬───────────┬──────────┬──────────┬────────────┬──────────┬───────────┬────────────┤
+│ │ 1 │ 2 │ Subtotal │ 3 │ 4 │ 5 │ 3+4 │ 4+5 │ Subtotal │ Total │
+│ ├─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┼─────┬────┼─────┬────┼──────┬─────┼─────┬────┼─────┬─────┼─────┬──────┤
+│ │ │ │ │ │ │ │ │ │ │ Row│ │ Row│ │ │ │ Row│ │ │ │ │
+│ │Count│Row %│Count│Row %│Count│Row %│Count│Row %│Count│ % │Count│ % │ Count│Row %│Count│ % │Count│Row %│Count│ Row %│
+├───────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼────┼─────┼────┼──────┼─────┼─────┼────┼─────┼─────┼─────┼──────┤
+│105b. How Almost │ 147│30.3%│ 246│50.7%│ 393│81.0%│ 62│12.8%│ 19│3.9%│ 11│2.3%│ 81.00│16.7%│ 30│6.2%│ 92│19.0%│ 485│100.0%│
+│likely is certain │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│it that │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│drivers Very │ 384│34.3%│ 552│49.2%│ 936│83.5%│ 120│10.7%│ 51│4.5%│ 14│1.2%│171.00│15.3%│ 65│5.8%│ 185│16.5%│ 1121│100.0%│
+│who have likely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│had too │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│much to Somewhat│ 590│27.8%│ 1249│58.8%│ 1839│86.6%│ 193│ 9.1%│ 72│3.4%│ 20│ .9%│265.00│12.5%│ 92│4.3%│ 285│13.4%│ 2124│100.0%│
+│drink to likely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│drive │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│safely Somewhat│ 278│26.6%│ 647│61.8%│ 925│88.3%│ 84│ 8.0%│ 32│3.1%│ 6│ .6%│116.00│11.1%│ 38│3.6%│ 122│11.7%│ 1047│100.0%│
+│will A. unlikely│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│Get │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│stopped by Very │ 141│28.5%│ 290│58.7%│ 431│87.2%│ 41│ 8.3%│ 18│3.6%│ 4│ .8%│ 59.00│11.9%│ 22│4.5%│ 63│12.8%│ 494│100.0%│
+│the unlikely│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│police? │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+╰───────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴────┴─────┴────┴──────┴─────┴─────┴────┴─────┴─────┴─────┴──────╯
+
+ Custom Tables
+╭─────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────╮
+│ │ S1. Including yourself, how many members of this household are age 16 or older? │
+│ ├───────────┬───────────┬───────────┬───────────┬────────────┬──────────┬───────────┬────────────┤
+│ │ 1 │ 2 │ Subtotal │ 3 │ 3+4 │ 4+5 │ Subtotal │ Total │
+│ ├─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┼──────┬─────┼─────┬────┼─────┬─────┼─────┬──────┤
+│ │ │ │ │ │ │ │ │ │ │ │ │ Row│ │ │ │ │
+│ │Count│Row %│Count│Row %│Count│Row %│Count│Row %│ Count│Row %│Count│ % │Count│Row %│Count│ Row %│
+├─────────────────────────────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼──────┼─────┼─────┼────┼─────┼─────┼─────┼──────┤
+│105b. How likely is it that Almost │ 147│30.3%│ 246│50.7%│ 393│81.0%│ 62│12.8%│ 81.00│16.7%│ 30│6.2%│ 92│19.0%│ 485│100.0%│
+│drivers who have had too much certain │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│to drink to drive safely will Very │ 384│34.3%│ 552│49.2%│ 936│83.5%│ 120│10.7%│171.00│15.3%│ 65│5.8%│ 185│16.5%│ 1121│100.0%│
+│A. Get stopped by the police? likely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│ Somewhat │ 590│27.8%│ 1249│58.8%│ 1839│86.6%│ 193│ 9.1%│265.00│12.5%│ 92│4.3%│ 285│13.4%│ 2124│100.0%│
+│ likely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│ Somewhat │ 278│26.6%│ 647│61.8%│ 925│88.3%│ 84│ 8.0%│116.00│11.1%│ 38│3.6%│ 122│11.7%│ 1047│100.0%│
+│ unlikely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+│ Very │ 141│28.5%│ 290│58.7%│ 431│87.2%│ 41│ 8.3%│ 59.00│11.9%│ 22│4.5%│ 63│12.8%│ 494│100.0%│
+│ unlikely │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+╰─────────────────────────────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴──────┴─────┴─────┴────┴─────┴─────┴─────┴──────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES PCOMPUTE - OTHERNM and MISSING])
+AT_KEYWORDS([postcompute])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /PCOMPUTE &x=EXPR(OTHERNM)
+ /PCOMPUTE &y=EXPR(MISSING)
+ /PPROPERTIES &x LABEL='Drivers'
+ /PPROPERTIES &y LABEL='Missing Values 2'
+ /TABLE=qn1 BY qns3a
+ /CATEGORIES VARIABLES=qn1 [OTHERNM, 5, &x, SUBTOTAL='Valid Values', MISSING, SUBTOTAL='Missing Values', &y]
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
+ Custom Tables
+╭──────────────────────────────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├──────────────────────────────────────────────────────────────────────────────────────────┼─────┼──────┤
+│ 1. How often do you usually drive a car or other motor vehicle? Every day │ 2305│ 2362│
+│ Several days a week │ 440│ 834│
+│ Once a week or less │ 125│ 236│
+│ Only certain times a year│ 58│ 72│
+│ Never │ 192│ 348│
+│ Drivers │ 2928│ 3504│
+│ Valid Values │ 3120│ 3852│
+│ Don't know │ 3│ 5│
+│ Refused │ 9│ 10│
+│ Missing Values │ 12│ 15│
+│ Missing Values 2 │ 12│ 15│
+╰──────────────────────────────────────────────────────────────────────────────────────────┴─────┴──────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES PCOMPUTE - THRU])
+AT_KEYWORDS([postcompute])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /PCOMPUTE &x=EXPR([1 THRU 2])
+ /PCOMPUTE &y=EXPR([3 THRU 4])
+ /PCOMPUTE &z=EXPR([5] + MISSING)
+ /PPROPERTIES &x LABEL='Frequent Drivers'
+ /PPROPERTIES &y LABEL='Infrequent Drivers'
+ /PPROPERTIES &z LABEL='Not Drivers or Missing'
+ /TABLE=qn1 BY qns3a
+ /CATEGORIES VARIABLES=qn1 [1 THRU 2, &x, 3 THRU 4, &y, SUBTOTAL='Drivers', 5, MISSING, &z]
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl
+ Custom Tables
+╭──────────────────────────────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├──────────────────────────────────────────────────────────────────────────────────────────┼─────┼──────┤
+│ 1. How often do you usually drive a car or other motor vehicle? Every day │ 2305│ 2362│
+│ Several days a week │ 440│ 834│
+│ Frequent Drivers │ 2745│ 3196│
+│ Once a week or less │ 125│ 236│
+│ Only certain times a year│ 58│ 72│
+│ Infrequent Drivers │ 183│ 308│
+│ Drivers │ 2928│ 3504│
+│ Never │ 192│ 348│
+│ Don't know │ 3│ 5│
+│ Refused │ 9│ 10│
+│ Not Drivers or Missing │ 204│ 363│
+╰──────────────────────────────────────────────────────────────────────────────────────────┴─────┴──────╯
+])
+AT_CLEANUP
+
+dnl I'm not sure that this is the correct behavior (see
+dnl https://mail.gnu.org/archive/html/pspp-users/2022-07/msg00002.html)
+dnl but at least this test will notify us if the behavior changes.
+AT_SETUP([CTABLES intersecting PCOMPUTEs])
+AT_KEYWORDS([PCOMPUTE postcompute])
+AT_DATA([ctables.sps],
+[[DATA LIST LIST NOTABLE/x y z.
+WEIGHT by z.
+FORMATS ALL (F1.0).
+VARIABLE LEVEL x y (NOMINAL).
+BEGIN DATA.
+1 4 5
+1 5 2
+1 6 9
+2 4 2
+2 5 3
+2 6 4
+3 4 1
+3 5 6
+3 6 1
+END DATA.
+
+CTABLES
+ /PCOMPUTE &a = EXPR([1] + [2])
+ /PCOMPUTE &b = EXPR([2] + [3])
+ /PCOMPUTE &c = EXPR([4] * [5])
+ /PCOMPUTE &d = EXPR([5] * [6])
+ /TABLE x BY y
+ /CATEGORIES VARIABLES=x [1, &a, 2, &b, 3]
+ /CATEGORIES VARIABLES=y [4, &c, 5, &d, 6].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0],
+[[ Custom Tables
+╭───────────┬─────────────────────────────────────╮
+│ │ y │
+│ ├─────┬─────────┬─────┬─────────┬─────┤
+│ │ 4 │[4] * [5]│ 5 │[5] * [6]│ 6 │
+│ ├─────┼─────────┼─────┼─────────┼─────┤
+│ │Count│ Count │Count│ Count │Count│
+├───────────┼─────┼─────────┼─────┼─────────┼─────┤
+│x 1 │ 5│ 10│ 2│ 18│ 9│
+│ [1] + [2]│ 7│ .│ 5│ .│ 13│
+│ 2 │ 2│ 6│ 3│ 12│ 4│
+│ [2] + [3]│ 3│ .│ 9│ .│ 5│
+│ 3 │ 1│ 6│ 6│ 6│ 1│
+╰───────────┴─────┴─────────┴─────┴─────────┴─────╯
+]])
+AT_CLEANUP
+
+AT_SETUP([CTABLES string and date and time])
+
+weight=1
+for gender in F M; do
+ for month in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
+ for wkday in Sun Mon Tue Wed Thu Fri Sat Sun; do
+ printf "$weight $gender $month $wkday\n"
+ weight=$(expr \( $weight + 3 \) % 7 + 2)
+ done
+ done
+done > ctables.txt
+
+AT_DATA([ctables.sps],
+[[DATA LIST LIST NOTABLE FILE='ctables.txt'
+ /w (F5.0) gender (A1) fmon (MONTH3) fday (WKDAY3).
+WEIGHT by w.
+VARIABLE LEVEL w (SCALE).
+VARIABLE LEVEL gender fmon fday (NOMINAL).
+VARIABLE LABEL
+ gender 'Gender'
+ fmon 'Favorite month'
+ fday 'Favorite day of the week'.
+VALUE LABELS /gender 'M' 'Male' 'F' 'Female'.
+CTABLES
+ /PCOMPUTE &q2 = EXPR(['APR' THRU 'June'])
+ /PPROPERTIES &q2 LABEL='Q2'
+ /PCOMPUTE &weekend = EXPR(['sun'] + ['Sat'])
+ /PPROPERTIES &weekend LABEL='Weekend'
+ /TABLE fmon BY gender > fday
+ /CATEGORIES VARIABLES=fmon ['JAN', 'FEB', 'Mar', SUBTOTAL="Q1",
+ 4 THRU 6, &q2,
+ 'JUL' THRU 'sep', SUBTOTAL="Q3",
+ OTHERNM, SUBTOTAL='Q4']
+ /CATEGORIES VARIABLES=gender ['M', 'F']
+ /CATEGORIES VARIABLE=fday ['Sun', 2 THRU 6, 'Sat', &weekend] TOTAL=YES
+ /SLABELS VISIBLE=NO.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭──────────────────┬───────────────────────────────────────────────────────────────────────────────────╮
+│ │ Gender │
+│ ├─────────────────────────────────────────┬─────────────────────────────────────────┤
+│ │ Male │ Female │
+│ ├─────────────────────────────────────────┼─────────────────────────────────────────┤
+│ │ Favorite day of the week │ Favorite day of the week │
+│ ├───┬───┬───┬───┬───┬───┬───┬───────┬─────┼───┬───┬───┬───┬───┬───┬───┬───────┬─────┤
+│ │SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│
+├──────────────────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┤
+│Favorite month JAN│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│ 9│ 6│ 4│ 2│ 7│ 5│ 3│ 12│ 36│
+│ FEB│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│
+│ MAR│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│
+│ Q1 │ 32│ 17│ 18│ 12│ 13│ 14│ 15│ │ │ 29│ 12│ 13│ 14│ 15│ 16│ 17│ │ │
+│ APR│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│
+│ MAY│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│
+│ JUN│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│
+│ Q2 │ 24│ 13│ 14│ 15│ 16│ 17│ 18│ .│ │ 28│ 15│ 16│ 17│ 18│ 12│ 13│ .│ │
+│ JUL│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│
+│ AUG│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│
+│ SEP│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│
+│ Q3 │ 54│ 29│ 31│ 33│ 28│ 30│ 32│ │ │ 62│ 33│ 28│ 30│ 32│ 27│ 29│ │ │
+│ OCT│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│
+│ NOV│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│
+│ DEC│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│
+│ Q4 │ 36│ 12│ 13│ 14│ 15│ 16│ 17│ │ │ 26│ 14│ 15│ 16│ 17│ 18│ 12│ │ │
+╰──────────────────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES CLABELS])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE AgeGroup BY qns3a.
+CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
+CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
+CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
+CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭───────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├───────────────────────┼─────┼──────┤
+│Age group 15 or younger│ 0│ 0│
+│ 16 to 25 │ 594│ 505│
+│ 26 to 35 │ 476│ 491│
+│ 36 to 45 │ 489│ 548│
+│ 46 to 55 │ 526│ 649│
+│ 56 to 65 │ 516│ 731│
+│ 66 or older │ 531│ 943│
+╰───────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│ │ S3a. GENDER: │
+│ ├──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┤
+│ │ Male │ Female │
+│ ├─────────┬───────┬──────┬──────┬──────┬───────┬───────┼──────────┬──────┬───────┬──────┬──────┬──────┬────────┤
+│ │ 15 or │ 16 to │ 26 to│ 36 to│ 46 to│ 56 to │ 66 or │ 15 or │ 16 to│ 26 to │ 36 to│ 46 to│ 56 to│ 66 or │
+│ │ younger │ 25 │ 35 │ 45 │ 55 │ 65 │ older │ younger │ 25 │ 35 │ 45 │ 55 │ 65 │ older │
+│ ├─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
+│ │ Count │ Count │ Count│ Count│ Count│ Count │ Count │ Count │ Count│ Count │ Count│ Count│ Count│ Count │
+├───────┼─────────┼───────┼──────┼──────┼──────┼───────┼───────┼──────────┼──────┼───────┼──────┼──────┼──────┼────────┤
+│Age │ 0│ 594│ 476│ 489│ 526│ 516│ 531│ 0│ 505│ 491│ 548│ 649│ 731│ 943│
+│group │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
+╰───────┴─────────┴───────┴──────┴──────┴──────┴───────┴───────┴──────────┴──────┴───────┴──────┴──────┴──────┴────────╯
+
+ Custom Tables
+╭──────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├────────────┤
+│ │ Count │
+├──────────────────────────────┼────────────┤
+│Age group 15 or younger Male │ 0│
+│ Female│ 0│
+│ ╶────────────────────┼────────────┤
+│ 16 to 25 Male │ 594│
+│ Female│ 505│
+│ ╶────────────────────┼────────────┤
+│ 26 to 35 Male │ 476│
+│ Female│ 491│
+│ ╶────────────────────┼────────────┤
+│ 36 to 45 Male │ 489│
+│ Female│ 548│
+│ ╶────────────────────┼────────────┤
+│ 46 to 55 Male │ 526│
+│ Female│ 649│
+│ ╶────────────────────┼────────────┤
+│ 56 to 65 Male │ 516│
+│ Female│ 731│
+│ ╶────────────────────┼────────────┤
+│ 66 or older Male │ 531│
+│ Female│ 943│
+╰──────────────────────────────┴────────────╯
+
+ Custom Tables
+15 or younger
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 0│ 0│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+16 to 25
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 594│ 505│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+26 to 35
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 476│ 491│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+36 to 45
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 489│ 548│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+46 to 55
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 526│ 649│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+56 to 65
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 516│ 731│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+66 or older
+╭─────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────┼─────┼──────┤
+│Age group│ 531│ 943│
+╰─────────┴─────┴──────╯
+
+ Custom Tables
+Male
+╭───────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├────────────┤
+│ │ Count │
+├───────────────────────┼────────────┤
+│Age group 15 or younger│ 0│
+│ 16 to 25 │ 594│
+│ 26 to 35 │ 476│
+│ 36 to 45 │ 489│
+│ 46 to 55 │ 526│
+│ 56 to 65 │ 516│
+│ 66 or older │ 531│
+╰───────────────────────┴────────────╯
+
+ Custom Tables
+Female
+╭───────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├────────────┤
+│ │ Count │
+├───────────────────────┼────────────┤
+│Age group 15 or younger│ 0│
+│ 16 to 25 │ 505│
+│ 26 to 35 │ 491│
+│ 36 to 45 │ 548│
+│ 46 to 55 │ 649│
+│ 56 to 65 │ 731│
+│ 66 or older │ 943│
+╰───────────────────────┴────────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES missing values])
+AT_DATA([ctables.sps],
+[[DATA LIST LIST NOTABLE/x y.
+BEGIN DATA.
+1 1
+1 2
+1 3
+1 4
+1 5
+1 .
+2 1
+2 2
+2 3
+2 4
+2 5
+2 .
+3 1
+3 2
+3 3
+3 4
+3 5
+3 .
+4 1
+4 2
+4 3
+4 4
+4 5
+4 .
+5 1
+5 2
+5 3
+5 4
+5 5
+5 .
+. 1
+. 2
+. 3
+. 4
+. 5
+. .
+END DATA.
+MISSING VALUES x (1, 2) y (2, 3).
+VARIABLE LEVEL ALL (NOMINAL).
+
+CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
+ TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=ALL TOTAL=YES.
+CTABLES /TABLE x[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN,
+ TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
+CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
+ TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=ALL TOTAL=YES
+ /SLABELS POSITION=ROW.
+CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
+ TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE
+ /SLABELS POSITION=ROW.
+CTABLES /TABLE x BY y[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN,
+ TOTALS[COUNT, COLPCT, COLPCT.VALIDN, COLPCT.TOTALN, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=x [1, 2, 3, 4] TOTAL=YES
+ /CATEGORIES VARIABLES=y [1, 3, 4, 5] TOTAL=YES
+ /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
+│ │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
+├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
+│x 3.00 │ 6│ 33.3%│ 33.3%│ 16.7%│ │ │
+│ 4.00 │ 6│ 33.3%│ 33.3%│ 16.7%│ │ │
+│ 5.00 │ 6│ 33.3%│ 33.3%│ 16.7%│ │ │
+│ Total│ 18│ 100.0%│ 100.0%│ 100.0%│ 18│ 36│
+╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
+dnl Note that Column Total N % doesn't add up to 100 because missing
+dnl values are included in the total but not shown as a category and this
+dnl is expected behavior.
+
+ Custom Tables
+╭───────┬─────┬────────┬────────────────┬────────────────┬───────┬───────╮
+│ │Count│Column %│Column Valid N %│Column Total N %│Valid N│Total N│
+├───────┼─────┼────────┼────────────────┼────────────────┼───────┼───────┤
+│x 1.00 │ 6│ 20.0%│ .0%│ 16.7%│ │ │
+│ 2.00 │ 6│ 20.0%│ .0%│ 16.7%│ │ │
+│ 3.00 │ 6│ 20.0%│ 33.3%│ 16.7%│ │ │
+│ 4.00 │ 6│ 20.0%│ 33.3%│ 16.7%│ │ │
+│ 5.00 │ 6│ 20.0%│ 33.3%│ 16.7%│ │ │
+│ Total│ 30│ 100.0%│ 100.0%│ 100.0%│ 18│ 36│
+╰───────┴─────┴────────┴────────────────┴────────────────┴───────┴───────╯
+dnl Note that Column Total N % doesn't add up to 100 because system-missing
+dnl values are included in the total but not shown as a category and this
+dnl is expected behavior.
+
+ Custom Tables
+╭────────────────────────┬───────────────────────────╮
+│ │ y │
+│ ├──────┬──────┬──────┬──────┤
+│ │ 1.00 │ 4.00 │ 5.00 │ Total│
+├────────────────────────┼──────┼──────┼──────┼──────┤
+│x 3.00 Count │ 1│ 1│ 1│ 3│
+│ Column % │ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Valid N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Total N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Row % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Valid N % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ 3│
+│ Total N │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┤
+│ 4.00 Count │ 1│ 1│ 1│ 3│
+│ Column % │ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Valid N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Total N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Row % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Valid N % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ 3│
+│ Total N │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┤
+│ 5.00 Count │ 1│ 1│ 1│ 3│
+│ Column % │ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Valid N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Column Total N %│ 33.3%│ 33.3%│ 33.3%│ .│
+│ Row % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Valid N % │ 33.3%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ 3│
+│ Total N │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┤
+│ Total Count │ 3│ 3│ 3│ 9│
+│ Column % │100.0%│100.0%│100.0%│ .│
+│ Column Valid N %│100.0%│100.0%│100.0%│ .│
+│ Column Total N %│100.0%│100.0%│100.0%│ .│
+│ Row % │ .│ .│ .│ .│
+│ Row Valid N % │ .│ .│ .│ .│
+│ Row Total N % │ .│ .│ .│ .│
+│ Valid N │ 3│ 3│ 3│ 9│
+│ Total N │ 3│ 3│ 3│ 18│
+╰────────────────────────┴──────┴──────┴──────┴──────╯
+
+ Custom Tables
+╭────────────────────────┬─────────────────────────────────────────╮
+│ │ y │
+│ ├──────┬──────┬──────┬──────┬──────┬──────┤
+│ │ 1.00 │ 2.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
+├────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│x 1.00 Count │ 1│ 1│ 1│ 1│ 1│ 5│
+│ Column % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Column Valid N %│ 20.0%│ .│ .│ 20.0%│ 20.0%│ .│
+│ Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Row % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ 2.00 Count │ 1│ 1│ 1│ 1│ 1│ 5│
+│ Column % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Column Valid N %│ 20.0%│ .│ .│ 20.0%│ 20.0%│ .│
+│ Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Row % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ 3.00 Count │ 1│ 1│ 1│ 1│ 1│ 5│
+│ Column % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Column Valid N %│ 20.0%│ .│ .│ 20.0%│ 20.0%│ .│
+│ Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Row % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ 4.00 Count │ 1│ 1│ 1│ 1│ 1│ 5│
+│ Column % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Column Valid N %│ 20.0%│ .│ .│ 20.0%│ 20.0%│ .│
+│ Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Row % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ 5.00 Count │ 1│ 1│ 1│ 1│ 1│ 5│
+│ Column % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Column Valid N %│ 20.0%│ .│ .│ 20.0%│ 20.0%│ .│
+│ Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│ .│
+│ Row % │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ Total Count │ 5│ 5│ 5│ 5│ 5│ 25│
+│ Column % │100.0%│100.0%│100.0%│100.0%│100.0%│ .│
+│ Column Valid N %│100.0%│ .│ .│100.0%│100.0%│ .│
+│ Column Total N %│100.0%│100.0%│100.0%│100.0%│100.0%│ .│
+│ Row % │ .│ .│ .│ .│ .│ .│
+│ Row Valid N % │ .│ .│ .│ .│ .│ .│
+│ Row Total N % │ .│ .│ .│ .│ .│ .│
+│ Valid N │ 5│ 0│ 0│ 5│ 5│ 15│
+│ Total N │ 5│ 5│ 5│ 5│ 5│ 30│
+╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
+
+ Custom Tables
+╭────────────────────────┬──────────────────────────────────╮
+│ │ y │
+│ ├──────┬──────┬──────┬──────┬──────┤
+│ │ 1.00 │ 3.00 │ 4.00 │ 5.00 │ Total│
+├────────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│x 1.00 Count │ 1│ 1│ 1│ 1│ 4│
+│ Column % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Column Valid N %│ 25.0%│ .│ 25.0%│ 25.0%│ .│
+│ Column Total N %│ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Row % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│ 2.00 Count │ 1│ 1│ 1│ 1│ 4│
+│ Column % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Column Valid N %│ 25.0%│ .│ 25.0%│ 25.0%│ .│
+│ Column Total N %│ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Row % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│ 3.00 Count │ 1│ 1│ 1│ 1│ 4│
+│ Column % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Column Valid N %│ 25.0%│ .│ 25.0%│ 25.0%│ .│
+│ Column Total N %│ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Row % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│ 4.00 Count │ 1│ 1│ 1│ 1│ 4│
+│ Column % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Column Valid N %│ 25.0%│ .│ 25.0%│ 25.0%│ .│
+│ Column Total N %│ 25.0%│ 25.0%│ 25.0%│ 25.0%│ .│
+│ Row % │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│ Row Valid N % │ 33.3%│ .0%│ 33.3%│ 33.3%│100.0%│
+│ Row Total N % │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│ Valid N │ │ │ │ │ 3│
+│ Total N │ │ │ │ │ 6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│ Total Count │ 4│ 4│ 4│ 4│ 16│
+│ Column % │100.0%│100.0%│100.0%│100.0%│ .│
+│ Column Valid N %│100.0%│ .│100.0%│100.0%│ .│
+│ Column Total N %│100.0%│100.0%│100.0%│100.0%│ .│
+│ Row % │ .│ .│ .│ .│ .│
+│ Row Valid N % │ .│ .│ .│ .│ .│
+│ Row Total N % │ .│ .│ .│ .│ .│
+│ Valid N │ 4│ 0│ 4│ 4│ 12│
+│ Total N │ 4│ 4│ 4│ 4│ 24│
+╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES SMISSING=LISTWISE])
+AT_KEYWORDS([SMISSING LISTWISE])
+AT_DATA([ctables.sps],
+[[DATA LIST LIST NOTABLE/x y z.
+BEGIN DATA.
+1 . 40
+1 10 50
+1 20 60
+1 . .
+1 30 .
+END DATA.
+VARIABLE LEVEL x (NOMINAL).
+
+CTABLES /TABLE (y + z) > x.
+CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
+
+* The following doesn't come out as listwise because the tables are
+separate, not linked by an > operator.
+CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭────────┬─────╮
+│ │ Mean│
+├────────┼─────┤
+│y x 1.00│20.00│
+├────────┼─────┤
+│z x 1.00│50.00│
+╰────────┴─────╯
+
+ Custom Tables
+╭────────┬─────╮
+│ │ Mean│
+├────────┼─────┤
+│y x 1.00│15.00│
+├────────┼─────┤
+│z x 1.00│55.00│
+╰────────┴─────╯
+
+ Custom Tables
+╭────────┬─────╮
+│ │ Mean│
+├────────┼─────┤
+│y x 1.00│20.00│
+├────────┼─────┤
+│z x 1.00│50.00│
+╰────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES VLABELS - variables on different axes])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=DEFAULT /TABLE qnd5a BY qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NAME /TABLE qnd5a BY qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=LABEL /TABLE qnd5a BY qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=BOTH /TABLE qnd5a BY qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a BY qns3a.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├────────────────────────────────────────────────────────────────┼─────┼──────┤
+│D5a. What would you say is your primary Cuban │ 13│ 7│
+│ethnic background? Mexican │ 175│ 136│
+│ Spanish │ 20│ 28│
+│ South American │ 21│ 13│
+│ Central American │ 27│ 25│
+│ Puerto Rican, OR │ 37│ 41│
+│ Something else │ 35│ 33│
+│ Multiple - cannot │ 2│ 5│
+│ choose one │ │ │
+╰────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭──────────────────────────────────┬────────────╮
+│ │ QNS3A │
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├──────────────────────────────────┼─────┼──────┤
+│QND5A Cuban │ 13│ 7│
+│ Mexican │ 175│ 136│
+│ Spanish │ 20│ 28│
+│ South American │ 21│ 13│
+│ Central American │ 27│ 25│
+│ Puerto Rican, OR │ 37│ 41│
+│ Something else │ 35│ 33│
+│ Multiple - cannot choose one│ 2│ 5│
+╰──────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├────────────────────────────────────────────────────────────────┼─────┼──────┤
+│D5a. What would you say is your primary Cuban │ 13│ 7│
+│ethnic background? Mexican │ 175│ 136│
+│ Spanish │ 20│ 28│
+│ South American │ 21│ 13│
+│ Central American │ 27│ 25│
+│ Puerto Rican, OR │ 37│ 41│
+│ Something else │ 35│ 33│
+│ Multiple - cannot │ 2│ 5│
+│ choose one │ │ │
+╰────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────┬────────────────╮
+│ │ QNS3A S3a. │
+│ │ GENDER: │
+│ ├───────┬────────┤
+│ │ Male │ Female │
+│ ├───────┼────────┤
+│ │ Count │ Count │
+├────────────────────────────────────────────────────────────┼───────┼────────┤
+│QND5A D5a. What would you say is your Cuban │ 13│ 7│
+│primary ethnic background? Mexican │ 175│ 136│
+│ Spanish │ 20│ 28│
+│ South American │ 21│ 13│
+│ Central American │ 27│ 25│
+│ Puerto Rican, OR │ 37│ 41│
+│ Something else │ 35│ 33│
+│ Multiple - cannot │ 2│ 5│
+│ choose one │ │ │
+╰────────────────────────────────────────────────────────────┴───────┴────────╯
+
+ Custom Tables
+╭────────────────────────────┬─────┬──────╮
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├────────────────────────────┼─────┼──────┤
+│Cuban │ 13│ 7│
+│Mexican │ 175│ 136│
+│Spanish │ 20│ 28│
+│South American │ 21│ 13│
+│Central American │ 27│ 25│
+│Puerto Rican, OR │ 37│ 41│
+│Something else │ 35│ 33│
+│Multiple - cannot choose one│ 2│ 5│
+╰────────────────────────────┴─────┴──────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES VLABELS - stacked variables])
+AT_KEYWORDS([stack stacking])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic Cuban │ 20│
+│background? Mexican │ 311│
+│ Spanish │ 48│
+│ South American │ 34│
+│ Central American │ 52│
+│ Puerto Rican, OR │ 78│
+│ Something else │ 68│
+│ Multiple - cannot │ 7│
+│ choose one │ │
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│QNS3A Male │ 3132│
+│ Female │ 3867│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭─────────────────────────────────────────┬─────╮
+│ │Count│
+├─────────────────────────────────────────┼─────┤
+│QND5A Cuban │ 20│
+│ Mexican │ 311│
+│ Spanish │ 48│
+│ South American │ 34│
+│ Central American │ 52│
+│ Puerto Rican, OR │ 78│
+│ Something else │ 68│
+│ Multiple - cannot choose one│ 7│
+├─────────────────────────────────────────┼─────┤
+│S3a. GENDER: Male │ 3132│
+│ Female │ 3867│
+╰─────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic Cuban │ 20│
+│background? Mexican │ 311│
+│ Spanish │ 48│
+│ South American │ 34│
+│ Central American │ 52│
+│ Puerto Rican, OR │ 78│
+│ Something else │ 68│
+│ Multiple - cannot │ 7│
+│ choose one │ │
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│Male │ 3132│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│Female │ 3867│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭─────────────────────────────┬─────╮
+│ │Count│
+├─────────────────────────────┼─────┤
+│Cuban │ 20│
+├─────────────────────────────┼─────┤
+│Mexican │ 311│
+├─────────────────────────────┼─────┤
+│Spanish │ 48│
+├─────────────────────────────┼─────┤
+│South American │ 34│
+├─────────────────────────────┼─────┤
+│Central American │ 52│
+├─────────────────────────────┼─────┤
+│Puerto Rican, OR │ 78│
+├─────────────────────────────┼─────┤
+│Something else │ 68│
+├─────────────────────────────┼─────┤
+│Multiple - cannot choose one │ 7│
+├─────────────────────────────┼─────┤
+│S3a. GENDER: Male │ 3132│
+│ Female │ 3867│
+╰─────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────┼─────┤
+│Cuban │ 20│
+│Mexican │ 311│
+│Spanish │ 48│
+│South American │ 34│
+│Central American │ 52│
+│Puerto Rican, OR │ 78│
+│Something else │ 68│
+│Multiple - cannot choose one│ 7│
+│Male │ 3132│
+│Female │ 3867│
+╰────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES VLABELS - nested variables])
+AT_KEYWORDS([nest nesting])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your Cuban QNS3A Male │ 13│
+│primary ethnic background? Female│ 7│
+│ ╶─────────────────────────────────┼─────┤
+│ Mexican QNS3A Male │ 175│
+│ Female│ 136│
+│ ╶─────────────────────────────────┼─────┤
+│ Spanish QNS3A Male │ 20│
+│ Female│ 28│
+│ ╶─────────────────────────────────┼─────┤
+│ South American QNS3A Male │ 21│
+│ Female│ 13│
+│ ╶─────────────────────────────────┼─────┤
+│ Central American QNS3A Male │ 27│
+│ Female│ 25│
+│ ╶─────────────────────────────────┼─────┤
+│ Puerto Rican, OR QNS3A Male │ 37│
+│ Female│ 41│
+│ ╶─────────────────────────────────┼─────┤
+│ Something else QNS3A Male │ 35│
+│ Female│ 33│
+│ ╶─────────────────────────────────┼─────┤
+│ Multiple - cannot QNS3A Male │ 2│
+│ choose one Female│ 5│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├──────────────────────────────────────────────────────┼─────┤
+│QND5A Cuban S3a. GENDER: Male │ 13│
+│ Female│ 7│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Mexican S3a. GENDER: Male │ 175│
+│ Female│ 136│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Spanish S3a. GENDER: Male │ 20│
+│ Female│ 28│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ South American S3a. GENDER: Male │ 21│
+│ Female│ 13│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Central American S3a. GENDER: Male │ 27│
+│ Female│ 25│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Puerto Rican, OR S3a. GENDER: Male │ 37│
+│ Female│ 41│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Something else S3a. GENDER: Male │ 35│
+│ Female│ 33│
+│ ╶────────────────────────────────────────────────┼─────┤
+│ Multiple - cannot choose one S3a. GENDER: Male │ 2│
+│ Female│ 5│
+╰──────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary Cuban Male │ 13│
+│ethnic background? Female│ 7│
+│ ╶────────────────────────────┼─────┤
+│ Mexican Male │ 175│
+│ Female│ 136│
+│ ╶────────────────────────────┼─────┤
+│ Spanish Male │ 20│
+│ Female│ 28│
+│ ╶────────────────────────────┼─────┤
+│ South American Male │ 21│
+│ Female│ 13│
+│ ╶────────────────────────────┼─────┤
+│ Central American Male │ 27│
+│ Female│ 25│
+│ ╶────────────────────────────┼─────┤
+│ Puerto Rican, OR Male │ 37│
+│ Female│ 41│
+│ ╶────────────────────────────┼─────┤
+│ Something else Male │ 35│
+│ Female│ 33│
+│ ╶────────────────────────────┼─────┤
+│ Multiple - cannot Male │ 2│
+│ choose one Female│ 5│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────┼─────┤
+│Cuban S3a. GENDER: Male │ 13│
+│ Female│ 7│
+├────────────────────────────────────────────────┼─────┤
+│Mexican S3a. GENDER: Male │ 175│
+│ Female│ 136│
+├────────────────────────────────────────────────┼─────┤
+│Spanish S3a. GENDER: Male │ 20│
+│ Female│ 28│
+├────────────────────────────────────────────────┼─────┤
+│South American S3a. GENDER: Male │ 21│
+│ Female│ 13│
+├────────────────────────────────────────────────┼─────┤
+│Central American S3a. GENDER: Male │ 27│
+│ Female│ 25│
+├────────────────────────────────────────────────┼─────┤
+│Puerto Rican, OR S3a. GENDER: Male │ 37│
+│ Female│ 41│
+├────────────────────────────────────────────────┼─────┤
+│Something else S3a. GENDER: Male │ 35│
+│ Female│ 33│
+├────────────────────────────────────────────────┼─────┤
+│Multiple - cannot choose one S3a. GENDER: Male │ 2│
+│ Female│ 5│
+╰────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭───────────────────────────────────┬─────╮
+│ │Count│
+├───────────────────────────────────┼─────┤
+│Cuban Male │ 13│
+│ Female│ 7│
+├───────────────────────────────────┼─────┤
+│Mexican Male │ 175│
+│ Female│ 136│
+├───────────────────────────────────┼─────┤
+│Spanish Male │ 20│
+│ Female│ 28│
+├───────────────────────────────────┼─────┤
+│South American Male │ 21│
+│ Female│ 13│
+├───────────────────────────────────┼─────┤
+│Central American Male │ 27│
+│ Female│ 25│
+├───────────────────────────────────┼─────┤
+│Puerto Rican, OR Male │ 37│
+│ Female│ 41│
+├───────────────────────────────────┼─────┤
+│Something else Male │ 35│
+│ Female│ 33│
+├───────────────────────────────────┼─────┤
+│Multiple - cannot choose one Male │ 2│
+│ Female│ 5│
+╰───────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES FORMAT EMPTY])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /FORMAT EMPTY=ZERO /TABLE qnd5a BY qnd5.
+CTABLES /FORMAT EMPTY=BLANK /TABLE qnd5a BY qnd5.
+CTABLES /FORMAT EMPTY='n/a' /TABLE qnd5a BY qnd5.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭─────────────────────────────────────────────┬───────────────────────────────╮
+│ │ D5. ETHNICITY: Are you of │
+│ │ Hispanic or Latino origin or │
+│ │ descent? │
+│ ├───────────────┬───────────────┤
+│ │ Yes │ No │
+│ ├───────────────┼───────────────┤
+│ │ Count │ Count │
+├─────────────────────────────────────────────┼───────────────┼───────────────┤
+│D5a. What would you say is Cuban │ 20│ 0│
+│your primary ethnic Mexican │ 311│ 0│
+│background? Spanish │ 48│ 0│
+│ South American │ 34│ 0│
+│ Central American│ 52│ 0│
+│ Puerto Rican, OR│ 78│ 0│
+│ Something else │ 68│ 0│
+│ Multiple - │ 7│ 0│
+│ cannot choose │ │ │
+│ one │ │ │
+╰─────────────────────────────────────────────┴───────────────┴───────────────╯
+
+ Custom Tables
+╭─────────────────────────────────────────────┬───────────────────────────────╮
+│ │ D5. ETHNICITY: Are you of │
+│ │ Hispanic or Latino origin or │
+│ │ descent? │
+│ ├───────────────┬───────────────┤
+│ │ Yes │ No │
+│ ├───────────────┼───────────────┤
+│ │ Count │ Count │
+├─────────────────────────────────────────────┼───────────────┼───────────────┤
+│D5a. What would you say is Cuban │ 20│ │
+│your primary ethnic Mexican │ 311│ │
+│background? Spanish │ 48│ │
+│ South American │ 34│ │
+│ Central American│ 52│ │
+│ Puerto Rican, OR│ 78│ │
+│ Something else │ 68│ │
+│ Multiple - │ 7│ │
+│ cannot choose │ │ │
+│ one │ │ │
+╰─────────────────────────────────────────────┴───────────────┴───────────────╯
+
+ Custom Tables
+╭─────────────────────────────────────────────┬───────────────────────────────╮
+│ │ D5. ETHNICITY: Are you of │
+│ │ Hispanic or Latino origin or │
+│ │ descent? │
+│ ├───────────────┬───────────────┤
+│ │ Yes │ No │
+│ ├───────────────┼───────────────┤
+│ │ Count │ Count │
+├─────────────────────────────────────────────┼───────────────┼───────────────┤
+│D5a. What would you say is Cuban │ 20│n/a │
+│your primary ethnic Mexican │ 311│n/a │
+│background? Spanish │ 48│n/a │
+│ South American │ 34│n/a │
+│ Central American│ 52│n/a │
+│ Puerto Rican, OR│ 78│n/a │
+│ Something else │ 68│n/a │
+│ Multiple - │ 7│n/a │
+│ cannot choose │ │ │
+│ one │ │ │
+╰─────────────────────────────────────────────┴───────────────┴───────────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES FORMAT MISSING])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /FORMAT MISSING='(no data)' /TABLE qnd5a[COLPCT] BY qnd5.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭─────────────────────────────────────────────┬───────────────────────────────╮
+│ │ D5. ETHNICITY: Are you of │
+│ │ Hispanic or Latino origin or │
+│ │ descent? │
+│ ├───────────────┬───────────────┤
+│ │ Yes │ No │
+│ ├───────────────┼───────────────┤
+│ │ Column % │ Column % │
+├─────────────────────────────────────────────┼───────────────┼───────────────┤
+│D5a. What would you say is Cuban │ 3.2%│(no data) │
+│your primary ethnic Mexican │ 50.3%│(no data) │
+│background? Spanish │ 7.8%│(no data) │
+│ South American │ 5.5%│(no data) │
+│ Central American│ 8.4%│(no data) │
+│ Puerto Rican, OR│ 12.6%│(no data) │
+│ Something else │ 11.0%│(no data) │
+│ Multiple - │ 1.1%│(no data) │
+│ cannot choose │ │ │
+│ one │ │ │
+╰─────────────────────────────────────────────┴───────────────┴───────────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES HIDESMALLCOUNTS])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE qn38[c][COUNT, COLPCT].
+CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
+CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│ │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that Less than one│ 7│ .5%│
+│occasion? 1 │ 491│ 34.9%│
+│ 2 │ 462│ 32.9%│
+│ 3 │ 229│ 16.3%│
+│ 4 │ 82│ 5.8%│
+│ 5 │ 56│ 4.0%│
+│ 6 │ 32│ 2.3%│
+│ 7 │ 9│ .6%│
+│ 8 │ 8│ .6%│
+│ 9 │ 4│ .3%│
+│ 10 │ 6│ .4%│
+│ 11 │ 2│ .1%│
+│ 12 │ 5│ .4%│
+│ 14 │ 1│ .1%│
+│ 15 │ 1│ .1%│
+│ 18 │ 1│ .1%│
+│ 20 │ 4│ .3%│
+│ 25 │ 1│ .1%│
+│ 30 │ 3│ .2%│
+│ 60 │ 1│ .1%│
+│ 99+ │ 0│ .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│ │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that Less than one│ 7│ .5%│
+│occasion? 1 │ 491│ 34.9%│
+│ 2 │ 462│ 32.9%│
+│ 3 │ 229│ 16.3%│
+│ 4 │ 82│ 5.8%│
+│ 5 │ 56│ 4.0%│
+│ 6 │ 32│ 2.3%│
+│ 7 │ 9│ .6%│
+│ 8 │ 8│ .6%│
+│ 9 │<5 │ .3%│
+│ 10 │ 6│ .4%│
+│ 11 │<5 │ .1%│
+│ 12 │ 5│ .4%│
+│ 14 │<5 │ .1%│
+│ 15 │<5 │ .1%│
+│ 18 │<5 │ .1%│
+│ 20 │<5 │ .3%│
+│ 25 │<5 │ .1%│
+│ 30 │<5 │ .2%│
+│ 60 │<5 │ .1%│
+│ 99+ │<5 │ .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+
+ Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│ │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that Less than one│<10 │ .5%│
+│occasion? 1 │ 491│ 34.9%│
+│ 2 │ 462│ 32.9%│
+│ 3 │ 229│ 16.3%│
+│ 4 │ 82│ 5.8%│
+│ 5 │ 56│ 4.0%│
+│ 6 │ 32│ 2.3%│
+│ 7 │<10 │ .6%│
+│ 8 │<10 │ .6%│
+│ 9 │<10 │ .3%│
+│ 10 │<10 │ .4%│
+│ 11 │<10 │ .1%│
+│ 12 │<10 │ .4%│
+│ 14 │<10 │ .1%│
+│ 15 │<10 │ .1%│
+│ 18 │<10 │ .1%│
+│ 20 │<10 │ .3%│
+│ 25 │<10 │ .1%│
+│ 30 │<10 │ .2%│
+│ 60 │<10 │ .1%│
+│ 99+ │<10 │ .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
+]])
+AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
+ Custom Tables
+╭────────────╮
+│S3a. GENDER:│
+├─────┬──────┤
+│ Male│Female│
+├─────┼──────┤
+│Count│ Count│
+├─────┼──────┤
+│ 3132│ 3867│
+╰─────┴──────╯
+])
+AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
+AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
+maximumColumnWidth="192"
+minimumColumnWidth="96"
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES special formats])
+AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+COMPUTE x = qnd3 - 4.
+CTABLES /TABLE x[MINIMUM NEGPAREN8.1, MINIMUM NEQUAL8.1, MINIMUM PAREN8.1, MINIMUM PCTPAREN8.1, MAXIMUM NEGPAREN8.1, MAXIMUM NEQUAL8.1, MAXIMUM PAREN8.1, MAXIMUM PCTPAREN8.1].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
+│ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
+├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
+│x│(3.0) │N=-3.0 │(-3.0) │(-3.0%)│8.0 │N=8.0 │(8.0) │(8.0%) │
+╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES TITLES])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=qn1 DISPLAY=NONE
+ /TABLE ((qn1[c][COUNT])) BY qns3a[c] > qnd5
+ /TITLES TITLE='How often do you drive?'
+ CAPTION='Generated )TIME on )DATE'
+ CORNER=')TABLE'.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode | sed 's/..:..:../HH:MM:SS/
+s&../../..&MM/DD/YY&'], [0], [dnl
+ How often do you drive?
+╭───────────────────────────────────┬─────────────────────────────────────────╮
+│ │ S3a. GENDER: │
+│ ├────────────────────┬────────────────────┤
+│ │ Male │ Female │
+│ ├────────────────────┼────────────────────┤
+│ │ D5. ETHNICITY: Are │ D5. ETHNICITY: Are │
+│ │ you of Hispanic or │ you of Hispanic or │
+│ │ Latino origin or │ Latino origin or │
+│( ( 1. How often do you usually │ descent? │ descent? │
+│drive a car or other motor ├─────────┬──────────┼─────────┬──────────┤
+│vehicle?) ) BY S3a. GENDER: > D5. │ Yes │ No │ Yes │ No │
+│ETHNICITY: Are you of Hispanic or ├─────────┼──────────┼─────────┼──────────┤
+│Latino origin or descent? │ Count │ Count │ Count │ Count │
+├───────────────────────────────────┼─────────┼──────────┼─────────┼──────────┤
+│Every day │ 218│ 2066│ 166│ 2175│
+│Several days a week │ 44│ 391│ 45│ 782│
+│Once a week or less │ 16│ 109│ 12│ 223│
+│Only certain times a year │ 15│ 41│ 11│ 61│
+│Never │ 39│ 150│ 56│ 278│
+╰───────────────────────────────────┴─────────┴──────────┴─────────┴──────────╯
+Generated HH:MM:SS on MM/DD/YY
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES area definitions])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=ALL DISPLAY=NAME
+ /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[TABLEID, LAYERID, SUBTABLEID]
+ /SLABELS POSITION=ROW
+ /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[ROWID, LAYERROWID]
+ /SLABELS POSITION=ROW
+ /TABLE qn61 > qn57 BY qnd7a > qn86 + qn64b BY qns3a[COLID, LAYERCOLID]
+ /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+Male
+╭─────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Subtable ID│ 1│ 1│ 2│ 2│ 3│ 3│
+│ ╶───────────────┼───┼──┼───┼──┼───┼──┤
+│ No Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Subtable ID│ 1│ 1│ 2│ 2│ 3│ 3│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Subtable ID│ 4│ 4│ 5│ 5│ 6│ 6│
+│ ╶───────────────┼───┼──┼───┼──┼───┼──┤
+│ No Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Subtable ID│ 4│ 4│ 5│ 5│ 6│ 6│
+╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭─────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├─────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 3│ 3│ 3│ 3│ 4│ 4│
+│ Subtable ID│ 7│ 7│ 8│ 8│ 9│ 9│
+│ ╶───────────────┼───┼──┼───┼──┼───┼──┤
+│ No Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 3│ 3│ 3│ 3│ 4│ 4│
+│ Subtable ID│ 7│ 7│ 8│ 8│ 9│ 9│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 3│ 3│ 3│ 3│ 4│ 4│
+│ Subtable ID│ 10│10│ 11│11│ 12│12│
+│ ╶───────────────┼───┼──┼───┼──┼───┼──┤
+│ No Table ID │ 1│ 1│ 1│ 1│ 2│ 2│
+│ Layer ID │ 3│ 3│ 3│ 3│ 4│ 4│
+│ Subtable ID│ 10│10│ 11│11│ 12│12│
+╰─────────────────────────────┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+╭──────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Row ID │ 1│ 1│ 2│ 2│ 3│ 3│
+│ Layer Row ID│ 1│ 1│ 1│ 1│ 2│ 2│
+│ ╶────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Row ID │ 4│ 4│ 5│ 5│ 6│ 6│
+│ Layer Row ID│ 3│ 3│ 3│ 3│ 4│ 4│
+│ ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Row ID │ 7│ 7│ 8│ 8│ 9│ 9│
+│ Layer Row ID│ 5│ 5│ 5│ 5│ 6│ 6│
+│ ╶────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Row ID │ 10│10│ 11│11│ 12│12│
+│ Layer Row ID│ 7│ 7│ 7│ 7│ 8│ 8│
+╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭──────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├──────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Row ID │ 13│13│ 14│14│ 15│15│
+│ Layer Row ID│ 9│ 9│ 9│ 9│ 10│10│
+│ ╶────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Row ID │ 16│16│ 17│17│ 18│18│
+│ Layer Row ID│ 11│11│ 11│11│ 12│12│
+│ ╶─────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Row ID │ 19│19│ 20│20│ 21│21│
+│ Layer Row ID│ 13│13│ 13│13│ 14│14│
+│ ╶────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Row ID │ 22│22│ 23│23│ 24│24│
+│ Layer Row ID│ 15│15│ 15│15│ 16│16│
+╰──────────────────────────────┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+╭─────────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Column ID │ 1│ 2│ 3│ 4│ 5│ 6│
+│ Layer Column ID│ 1│ 2│ 3│ 4│ 5│ 6│
+│ ╶───────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Column ID │ 1│ 2│ 3│ 4│ 5│ 6│
+│ Layer Column ID│ 1│ 2│ 3│ 4│ 5│ 6│
+│ ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Column ID │ 7│ 8│ 9│10│ 11│12│
+│ Layer Column ID│ 1│ 2│ 3│ 4│ 5│ 6│
+│ ╶───────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Column ID │ 7│ 8│ 9│10│ 11│12│
+│ Layer Column ID│ 1│ 2│ 3│ 4│ 5│ 6│
+╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭─────────────────────────────────┬─────────────┬──────╮
+│ │ QND7A │ QN64B│
+│ ├──────┬──────┼───┬──┤
+│ │ Yes │ No │ │ │
+│ ├──────┼──────┤ │ │
+│ │ QN86 │ QN86 │ │ │
+│ ├───┬──┼───┬──┤ │ │
+│ │Yes│No│Yes│No│Yes│No│
+├─────────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│QN61 Yes QN57 Yes Column ID │ 13│14│ 15│16│ 17│18│
+│ Layer Column ID│ 7│ 8│ 9│10│ 11│12│
+│ ╶───────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Column ID │ 13│14│ 15│16│ 17│18│
+│ Layer Column ID│ 7│ 8│ 9│10│ 11│12│
+│ ╶────────────────────────────┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Yes Column ID │ 19│20│ 21│22│ 23│24│
+│ Layer Column ID│ 7│ 8│ 9│10│ 11│12│
+│ ╶───────────────────┼───┼──┼───┼──┼───┼──┤
+│ No Column ID │ 19│20│ 21│22│ 23│24│
+│ Layer Column ID│ 7│ 8│ 9│10│ 11│12│
+╰─────────────────────────────────┴───┴──┴───┴──┴───┴──╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES area definitions with CLABELS ROWLABELS=OPPOSITE])
+AT_KEYWORDS([ROWLABELS OPPOSITE])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=ALL DISPLAY=NAME
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[TABLEID, LAYERID, SUBTABLEID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=OPPOSITE
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[ROWID, LAYERROWID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=OPPOSITE
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[COLID, LAYERCOLID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=OPPOSITE.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+Male
+╭──────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 2│ 2│ 3│ 3│ 4│ 4│ 5│ 5│ 6│ 6│ 7│ 7│ 8│ 8│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 2│ 2│ 3│ 3│ 4│ 4│ 5│ 5│ 6│ 6│ 7│ 7│ 8│ 8│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 10│10│ 11│11│ 12│12│ 13│13│ 14│14│ 15│15│ 16│16│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 10│10│ 11│11│ 12│12│ 13│13│ 14│14│ 15│15│ 16│16│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭──────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 17│17│ 18│18│ 19│19│ 20│20│ 21│21│ 22│22│ 23│23│ 24│24│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 17│17│ 18│18│ 19│19│ 20│20│ 21│21│ 22│22│ 23│23│ 24│24│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 25│25│ 26│26│ 27│27│ 28│28│ 29│29│ 30│30│ 31│31│ 32│32│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 25│25│ 26│26│ 27│27│ 28│28│ 29│29│ 30│30│ 31│31│ 32│32│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+╭───────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 1│ 1│ 2│ 2│ 3│ 3│ 4│ 4│ 5│ 5│ 6│ 6│ 7│ 7│ 8│ 8│
+│ Layer Row ID│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 9│ 9│ 10│10│ 11│11│ 12│12│ 13│13│ 14│14│ 15│15│ 16│16│
+│ Layer Row ID│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 17│17│ 18│18│ 19│19│ 20│20│ 21│21│ 22│22│ 23│23│ 24│24│
+│ Layer Row ID│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 25│25│ 26│26│ 27│27│ 28│28│ 29│29│ 30│30│ 31│31│ 32│32│
+│ Layer Row ID│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭───────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 33│33│ 34│34│ 35│35│ 36│36│ 37│37│ 38│38│ 39│39│ 40│40│
+│ Layer Row ID│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 41│41│ 42│42│ 43│43│ 44│44│ 45│45│ 46│46│ 47│47│ 48│48│
+│ Layer Row ID│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 49│49│ 50│50│ 51│51│ 52│52│ 53│53│ 54│54│ 55│55│ 56│56│
+│ Layer Row ID│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 57│57│ 58│58│ 59│59│ 60│60│ 61│61│ 62│62│ 63│63│ 64│64│
+│ Layer Row ID│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+╭──────────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+│ Layer Column ID│ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+│ Layer Column ID│ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 32│31│
+│ Layer Column ID│ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 32│31│
+│ Layer Column ID│ 2│ 1│ 4│ 3│ 6│ 5│ 7│ 8│ 10│ 9│ 11│12│ 14│13│ 15│16│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+╭──────────────────────────────────────┬───────────────────────────────────────────────────────╮
+│ │ QN27 │
+│ ├───────────────────────────┬───────────────────────────┤
+│ │ Yes │ No │
+│ ├───────────────────────────┼───────────────────────────┤
+│ │ QND7A │ QND7A │
+│ ├─────────────┬─────────────┼─────────────┬─────────────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├─────────────┼─────────────┼─────────────┼─────────────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├──────┬──────┼──────┬──────┼──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │ Yes │ No │ Yes │ No │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 34│33│ 35│36│ 37│38│ 39│40│ 41│42│ 44│43│ 45│46│ 47│48│
+│ Layer Column ID│ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 31│32│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 34│33│ 35│36│ 37│38│ 39│40│ 41│42│ 44│43│ 45│46│ 47│48│
+│ Layer Column ID│ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 31│32│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 50│49│ 51│52│ 53│54│ 55│56│ 57│58│ 59│60│ 62│61│ 64│63│
+│ Layer Column ID│ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 31│32│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 50│49│ 51│52│ 53│54│ 55│56│ 57│58│ 59│60│ 62│61│ 64│63│
+│ Layer Column ID│ 18│17│ 19│20│ 21│22│ 23│24│ 25│26│ 28│27│ 29│30│ 31│32│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES area definitions with CLABELS COLLABELS=OPPOSITE])
+AT_KEYWORDS([COLLABELS OPPOSITE])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=ALL DISPLAY=NAME
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[TABLEID, LAYERID, SUBTABLEID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=OPPOSITE
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[ROWID, LAYERROWID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=OPPOSITE
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[COLID, LAYERCOLID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=OPPOSITE.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+Male
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 2│ 2│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 2│ 2│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 3│ 3│ 4│ 4│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 3│ 3│ 4│ 4│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 5│ 5│ 6│ 6│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 5│ 5│ 6│ 6│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 7│ 7│ 8│ 8│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 7│ 7│ 8│ 8│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 10│ 10│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 10│ 10│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 11│ 11│ 12│ 12│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 11│ 11│ 12│ 12│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 13│ 13│ 14│ 14│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 13│ 13│ 14│ 14│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 15│ 15│ 16│ 16│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 15│ 15│ 16│ 16│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 17│ 17│ 18│ 18│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 17│ 17│ 18│ 18│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 19│ 19│ 20│ 20│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 19│ 19│ 20│ 20│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 21│ 21│ 22│ 22│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 21│ 21│ 22│ 22│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 23│ 23│ 24│ 24│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 23│ 23│ 24│ 24│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 25│ 25│ 26│ 26│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 25│ 25│ 26│ 26│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 27│ 27│ 28│ 28│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 27│ 27│ 28│ 28│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 29│ 29│ 30│ 30│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 29│ 29│ 30│ 30│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 31│ 31│ 32│ 32│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 31│ 31│ 32│ 32│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+╭───────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Row ID │ 2│ 2│ 3│ 3│
+│ Layer Row ID│ 2│ 2│ 2│ 2│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 1│ 1│ 4│ 4│
+│ Layer Row ID│ 1│ 1│ 1│ 1│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 5│ 5│ 7│ 7│
+│ Layer Row ID│ 3│ 3│ 3│ 3│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 6│ 6│ 8│ 8│
+│ Layer Row ID│ 4│ 4│ 4│ 4│
+│ ╶─────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Row ID │ 10│ 10│ 11│ 11│
+│ Layer Row ID│ 6│ 6│ 6│ 6│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 9│ 9│ 12│ 12│
+│ Layer Row ID│ 5│ 5│ 5│ 5│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 14│ 14│ 16│ 16│
+│ Layer Row ID│ 8│ 8│ 8│ 8│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 13│ 13│ 15│ 15│
+│ Layer Row ID│ 7│ 7│ 7│ 7│
+│ ╶──────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Row ID │ 17│ 17│ 19│ 19│
+│ Layer Row ID│ 9│ 9│ 9│ 9│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 18│ 18│ 20│ 20│
+│ Layer Row ID│ 10│ 10│ 10│ 10│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 21│ 21│ 23│ 23│
+│ Layer Row ID│ 11│ 11│ 11│ 11│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 22│ 22│ 24│ 24│
+│ Layer Row ID│ 12│ 12│ 12│ 12│
+│ ╶─────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Row ID │ 26│ 26│ 28│ 28│
+│ Layer Row ID│ 14│ 14│ 14│ 14│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 25│ 25│ 27│ 27│
+│ Layer Row ID│ 13│ 13│ 13│ 13│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 30│ 30│ 32│ 32│
+│ Layer Row ID│ 16│ 16│ 16│ 16│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 29│ 29│ 31│ 31│
+│ Layer Row ID│ 15│ 15│ 15│ 15│
+╰───────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+╭───────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Row ID │ 33│ 33│ 36│ 36│
+│ Layer Row ID│ 17│ 17│ 17│ 17│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 34│ 34│ 35│ 35│
+│ Layer Row ID│ 18│ 18│ 18│ 18│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 37│ 37│ 39│ 39│
+│ Layer Row ID│ 19│ 19│ 19│ 19│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 38│ 38│ 40│ 40│
+│ Layer Row ID│ 20│ 20│ 20│ 20│
+│ ╶─────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Row ID │ 41│ 41│ 44│ 44│
+│ Layer Row ID│ 21│ 21│ 21│ 21│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 42│ 42│ 43│ 43│
+│ Layer Row ID│ 22│ 22│ 22│ 22│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 45│ 45│ 48│ 48│
+│ Layer Row ID│ 23│ 23│ 23│ 23│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 46│ 46│ 47│ 47│
+│ Layer Row ID│ 24│ 24│ 24│ 24│
+│ ╶──────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Row ID │ 49│ 49│ 52│ 52│
+│ Layer Row ID│ 25│ 25│ 25│ 25│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 50│ 50│ 51│ 51│
+│ Layer Row ID│ 26│ 26│ 26│ 26│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 53│ 53│ 55│ 55│
+│ Layer Row ID│ 27│ 27│ 27│ 27│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 54│ 54│ 56│ 56│
+│ Layer Row ID│ 28│ 28│ 28│ 28│
+│ ╶─────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Row ID │ 58│ 58│ 59│ 59│
+│ Layer Row ID│ 30│ 30│ 30│ 30│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 57│ 57│ 60│ 60│
+│ Layer Row ID│ 29│ 29│ 29│ 29│
+│ ╶────────────────────┼────┼────┼────┼────┤
+│ No Yes Row ID │ 62│ 62│ 64│ 64│
+│ Layer Row ID│ 32│ 32│ 32│ 32│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 61│ 61│ 63│ 63│
+│ Layer Row ID│ 31│ 31│ 31│ 31│
+╰───────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+╭──────────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Column ID │ 1│ 2│ 3│ 4│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 1│ 2│ 3│ 4│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 5│ 6│ 7│ 8│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 5│ 6│ 7│ 8│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶────────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Column ID │ 9│ 10│ 11│ 12│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 9│ 10│ 11│ 12│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 13│ 14│ 15│ 16│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 13│ 14│ 15│ 16│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶─────────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Column ID │ 17│ 18│ 19│ 20│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 17│ 18│ 19│ 20│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 21│ 22│ 23│ 24│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 21│ 22│ 23│ 24│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶────────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Column ID │ 25│ 26│ 27│ 28│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 25│ 26│ 27│ 28│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 29│ 30│ 31│ 32│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 29│ 30│ 31│ 32│
+│ Layer Column ID│ 1│ 2│ 3│ 4│
+╰──────────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+╭──────────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Yes Column ID │ 33│ 34│ 35│ 36│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 33│ 34│ 35│ 36│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 37│ 38│ 39│ 40│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 37│ 38│ 39│ 40│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶────────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Column ID │ 41│ 42│ 43│ 44│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 41│ 42│ 43│ 44│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 45│ 46│ 47│ 48│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 45│ 46│ 47│ 48│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶─────────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Yes Column ID │ 49│ 50│ 51│ 52│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 49│ 50│ 51│ 52│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 53│ 54│ 55│ 56│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 53│ 54│ 55│ 56│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶────────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Yes Column ID │ 57│ 58│ 59│ 60│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 57│ 58│ 59│ 60│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────────┼────┼────┼────┼────┤
+│ No Yes Column ID │ 61│ 62│ 63│ 64│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 61│ 62│ 63│ 64│
+│ Layer Column ID│ 5│ 6│ 7│ 8│
+╰──────────────────────────────────────────────┴────┴────┴────┴────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES area definitions with CLABELS ROWLABELS=LAYER])
+AT_KEYWORDS([ROWLABELS LAYER])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=ALL DISPLAY=NAME
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[TABLEID, LAYERID, SUBTABLEID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=LAYER
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[ROWID, LAYERROWID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=LAYER
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[COLID, LAYERCOLID]
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=LAYER.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+Male
+Yes
+╭──────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 2│ 2│ 3│ 3│ 5│ 5│ 7│ 7│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 2│ 2│ 3│ 3│ 5│ 5│ 7│ 7│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 10│10│ 12│12│ 13│13│ 16│16│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ Subtable ID│ 10│10│ 12│12│ 13│13│ 16│16│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+No
+╭──────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 4│ 4│ 6│ 6│ 8│ 8│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 4│ 4│ 6│ 6│ 8│ 8│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 11│11│ 14│14│ 15│15│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 11│11│ 14│14│ 15│15│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+Yes
+╭──────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ Subtable ID│ 17│17│ 19│19│ 21│21│ 23│23│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ Subtable ID│ 17│17│ 19│19│ 21│21│ 23│23│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ Subtable ID│ 25│25│ 28│28│ 29│29│ 32│32│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ Subtable ID│ 25│25│ 28│28│ 29│29│ 32│32│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+No
+╭──────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+│ Subtable ID│ 18│18│ 20│20│ 22│22│ 24│24│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+│ Subtable ID│ 18│18│ 20│20│ 22│22│ 24│24│
+│ ╶─────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+│ Subtable ID│ 26│26│ 27│27│ 30│30│ 31│31│
+│ ╶────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Table ID │ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+│ Subtable ID│ 26│26│ 27│27│ 30│30│ 31│31│
+╰──────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+Yes
+╭───────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 1│ 1│ 3│ 3│ 6│ 6│ 8│ 8│
+│ Layer Row ID│ 1│ 1│ 1│ 1│ 1│ 1│ 1│ 1│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 9│ 9│ 11│11│ 14│14│ 15│15│
+│ Layer Row ID│ 3│ 3│ 3│ 3│ 3│ 3│ 3│ 3│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 18│18│ 20│20│ 22│22│ 23│23│
+│ Layer Row ID│ 6│ 6│ 6│ 6│ 6│ 6│ 6│ 6│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 26│26│ 28│28│ 29│29│ 32│32│
+│ Layer Row ID│ 8│ 8│ 8│ 8│ 8│ 8│ 8│ 8│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+No
+╭───────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 2│ 2│ 4│ 4│ 5│ 5│ 7│ 7│
+│ Layer Row ID│ 2│ 2│ 2│ 2│ 2│ 2│ 2│ 2│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 10│10│ 12│12│ 13│13│ 16│16│
+│ Layer Row ID│ 4│ 4│ 4│ 4│ 4│ 4│ 4│ 4│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 17│17│ 19│19│ 21│21│ 24│24│
+│ Layer Row ID│ 5│ 5│ 5│ 5│ 5│ 5│ 5│ 5│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 25│25│ 27│27│ 30│30│ 31│31│
+│ Layer Row ID│ 7│ 7│ 7│ 7│ 7│ 7│ 7│ 7│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+Yes
+╭───────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 33│33│ 36│36│ 38│38│ 40│40│
+│ Layer Row ID│ 9│ 9│ 9│ 9│ 9│ 9│ 9│ 9│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 42│42│ 43│43│ 45│45│ 47│47│
+│ Layer Row ID│ 12│12│ 12│12│ 12│12│ 12│12│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 50│50│ 52│52│ 53│53│ 56│56│
+│ Layer Row ID│ 14│14│ 14│14│ 14│14│ 14│14│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 57│57│ 60│60│ 61│61│ 63│63│
+│ Layer Row ID│ 15│15│ 15│15│ 15│15│ 15│15│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+No
+╭───────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├───────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Row ID │ 34│34│ 35│35│ 37│37│ 39│39│
+│ Layer Row ID│ 10│10│ 10│10│ 10│10│ 10│10│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 41│41│ 44│44│ 46│46│ 48│48│
+│ Layer Row ID│ 11│11│ 11│11│ 11│11│ 11│11│
+│ ╶──────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Row ID │ 49│49│ 51│51│ 54│54│ 55│55│
+│ Layer Row ID│ 13│13│ 13│13│ 13│13│ 13│13│
+│ ╶─────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Row ID │ 58│58│ 59│59│ 62│62│ 64│64│
+│ Layer Row ID│ 16│16│ 16│16│ 16│16│ 16│16│
+╰───────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+Yes
+╭──────────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+│ Layer Column ID│ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+│ Layer Column ID│ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 18│19│ 21│23│ 25│28│ 29│32│
+│ Layer Column ID│ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 18│19│ 21│23│ 25│28│ 29│32│
+│ Layer Column ID│ 2│ 4│ 6│ 7│ 10│11│ 14│15│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Male
+No
+╭──────────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+│ Layer Column ID│ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+│ Layer Column ID│ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 17│20│ 22│24│ 26│27│ 30│31│
+│ Layer Column ID│ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 17│20│ 22│24│ 26│27│ 30│31│
+│ Layer Column ID│ 1│ 3│ 5│ 8│ 9│12│ 13│16│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+Yes
+╭──────────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 34│35│ 37│39│ 41│44│ 45│47│
+│ Layer Column ID│ 18│19│ 21│23│ 25│28│ 29│31│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 34│35│ 37│39│ 41│44│ 45│47│
+│ Layer Column ID│ 18│19│ 21│23│ 25│28│ 29│31│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 50│51│ 53│55│ 57│59│ 62│64│
+│ Layer Column ID│ 18│19│ 21│23│ 25│28│ 29│31│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 50│51│ 53│55│ 57│59│ 62│64│
+│ Layer Column ID│ 18│19│ 21│23│ 25│28│ 29│31│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+
+ Custom Tables
+Female
+No
+╭──────────────────────────────────────┬───────────────────────────╮
+│ │ QN27 │
+│ ├─────────────┬─────────────┤
+│ │ Yes │ No │
+│ ├─────────────┼─────────────┤
+│ │ QND7A │ QND7A │
+│ ├──────┬──────┼──────┬──────┤
+│ │ Yes │ No │ Yes │ No │
+│ ├──────┼──────┼──────┼──────┤
+│ │ QN86 │ QN86 │ QN86 │ QN86 │
+│ ├───┬──┼───┬──┼───┬──┼───┬──┤
+│ │Yes│No│Yes│No│Yes│No│Yes│No│
+├──────────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│QN26 Yes QN61 Yes QN57 Column ID │ 33│36│ 38│40│ 42│43│ 46│48│
+│ Layer Column ID│ 17│20│ 22│24│ 26│27│ 30│32│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 33│36│ 38│40│ 42│43│ 46│48│
+│ Layer Column ID│ 17│20│ 22│24│ 26│27│ 30│32│
+│ ╶─────────────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN61 Yes QN57 Column ID │ 49│52│ 54│56│ 58│60│ 61│63│
+│ Layer Column ID│ 17│20│ 22│24│ 26│27│ 30│32│
+│ ╶────────────────────────┼───┼──┼───┼──┼───┼──┼───┼──┤
+│ No QN57 Column ID │ 49│52│ 54│56│ 58│60│ 61│63│
+│ Layer Column ID│ 17│20│ 22│24│ 26│27│ 30│32│
+╰──────────────────────────────────────┴───┴──┴───┴──┴───┴──┴───┴──╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES area definitions with CLABELS COLLABELS=LAYER])
+AT_KEYWORDS([COLLABELS LAYER])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /VLABELS VARIABLES=ALL DISPLAY=NAME
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[TABLEID, LAYERID, SUBTABLEID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=LAYER
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[ROWID, LAYERROWID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=LAYER
+ /TABLE qn26 > qn61 > qn57 BY qn27 > qnd7a > qn86 BY qns3a[COLID, LAYERCOLID]
+ /SLABELS POSITION=ROW
+ /CLABELS COLLABELS=LAYER.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+Male
+Yes
+╭──────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 2│ 2│ 4│ 4│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 2│ 2│ 4│ 4│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 5│ 5│ 7│ 7│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 5│ 5│ 7│ 7│
+│ ╶─────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 10│ 10│ 12│ 12│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 10│ 10│ 12│ 12│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 13│ 13│ 15│ 15│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 2│ 2│ 2│ 2│
+│ Subtable ID│ 13│ 13│ 15│ 15│
+╰──────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+No
+╭──────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 3│ 3│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 1│ 1│ 3│ 3│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 6│ 6│ 8│ 8│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 6│ 6│ 8│ 8│
+│ ╶─────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 11│ 11│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 9│ 9│ 11│ 11│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 14│ 14│ 16│ 16│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 1│ 1│ 1│ 1│
+│ Subtable ID│ 14│ 14│ 16│ 16│
+╰──────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+Yes
+╭──────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 18│ 18│ 19│ 19│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 18│ 18│ 19│ 19│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 22│ 22│ 23│ 23│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 22│ 22│ 23│ 23│
+│ ╶─────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 26│ 26│ 28│ 28│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 26│ 26│ 28│ 28│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 29│ 29│ 31│ 31│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 4│ 4│ 4│ 4│
+│ Subtable ID│ 29│ 29│ 31│ 31│
+╰──────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+No
+╭──────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 17│ 17│ 20│ 20│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 17│ 17│ 20│ 20│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 21│ 21│ 24│ 24│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 21│ 21│ 24│ 24│
+│ ╶─────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 25│ 25│ 27│ 27│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 25│ 25│ 27│ 27│
+│ ╶────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 30│ 30│ 32│ 32│
+│ ╶───────────────┼────┼────┼────┼────┤
+│ No Table ID │ 1│ 1│ 1│ 1│
+│ Layer ID │ 3│ 3│ 3│ 3│
+│ Subtable ID│ 30│ 30│ 32│ 32│
+╰──────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+Yes
+╭───────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Row ID │ 2│ 2│ 3│ 3│
+│ Layer Row ID│ 2│ 2│ 2│ 2│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 5│ 5│ 7│ 7│
+│ Layer Row ID│ 3│ 3│ 3│ 3│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 10│ 10│ 11│ 11│
+│ Layer Row ID│ 6│ 6│ 6│ 6│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 14│ 14│ 16│ 16│
+│ Layer Row ID│ 8│ 8│ 8│ 8│
+│ ╶──────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Row ID │ 17│ 17│ 19│ 19│
+│ Layer Row ID│ 9│ 9│ 9│ 9│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 21│ 21│ 23│ 23│
+│ Layer Row ID│ 11│ 11│ 11│ 11│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 26│ 26│ 28│ 28│
+│ Layer Row ID│ 14│ 14│ 14│ 14│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 30│ 30│ 32│ 32│
+│ Layer Row ID│ 16│ 16│ 16│ 16│
+╰───────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+No
+╭───────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Row ID │ 1│ 1│ 4│ 4│
+│ Layer Row ID│ 1│ 1│ 1│ 1│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 6│ 6│ 8│ 8│
+│ Layer Row ID│ 4│ 4│ 4│ 4│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 9│ 9│ 12│ 12│
+│ Layer Row ID│ 5│ 5│ 5│ 5│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 13│ 13│ 15│ 15│
+│ Layer Row ID│ 7│ 7│ 7│ 7│
+│ ╶──────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Row ID │ 18│ 18│ 20│ 20│
+│ Layer Row ID│ 10│ 10│ 10│ 10│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 22│ 22│ 24│ 24│
+│ Layer Row ID│ 12│ 12│ 12│ 12│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 25│ 25│ 27│ 27│
+│ Layer Row ID│ 13│ 13│ 13│ 13│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 29│ 29│ 31│ 31│
+│ Layer Row ID│ 15│ 15│ 15│ 15│
+╰───────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+Yes
+╭───────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Row ID │ 33│ 33│ 36│ 36│
+│ Layer Row ID│ 17│ 17│ 17│ 17│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 37│ 37│ 39│ 39│
+│ Layer Row ID│ 19│ 19│ 19│ 19│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 41│ 41│ 44│ 44│
+│ Layer Row ID│ 21│ 21│ 21│ 21│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 45│ 45│ 48│ 48│
+│ Layer Row ID│ 23│ 23│ 23│ 23│
+│ ╶──────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Row ID │ 49│ 49│ 52│ 52│
+│ Layer Row ID│ 25│ 25│ 25│ 25│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 53│ 53│ 55│ 55│
+│ Layer Row ID│ 27│ 27│ 27│ 27│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 58│ 58│ 59│ 59│
+│ Layer Row ID│ 30│ 30│ 30│ 30│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 62│ 62│ 64│ 64│
+│ Layer Row ID│ 32│ 32│ 32│ 32│
+╰───────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+No
+╭───────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├───────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Row ID │ 34│ 34│ 35│ 35│
+│ Layer Row ID│ 18│ 18│ 18│ 18│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 38│ 38│ 40│ 40│
+│ Layer Row ID│ 20│ 20│ 20│ 20│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 42│ 42│ 43│ 43│
+│ Layer Row ID│ 22│ 22│ 22│ 22│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 46│ 46│ 47│ 47│
+│ Layer Row ID│ 24│ 24│ 24│ 24│
+│ ╶──────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Row ID │ 50│ 50│ 51│ 51│
+│ Layer Row ID│ 26│ 26│ 26│ 26│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 54│ 54│ 56│ 56│
+│ Layer Row ID│ 28│ 28│ 28│ 28│
+│ ╶─────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Row ID │ 57│ 57│ 60│ 60│
+│ Layer Row ID│ 29│ 29│ 29│ 29│
+│ ╶────────────────┼────┼────┼────┼────┤
+│ No Row ID │ 61│ 61│ 63│ 63│
+│ Layer Row ID│ 31│ 31│ 31│ 31│
+╰───────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+Yes
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Column ID │ 1│ 4│ 5│ 7│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 1│ 4│ 5│ 7│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 9│ 12│ 14│ 15│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 9│ 12│ 14│ 15│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Column ID │ 18│ 20│ 22│ 24│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 18│ 20│ 22│ 24│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 26│ 27│ 30│ 31│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 26│ 27│ 30│ 31│
+│ Layer Column ID│ 1│ 4│ 5│ 7│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Male
+No
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Column ID │ 2│ 3│ 6│ 8│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 2│ 3│ 6│ 8│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 10│ 11│ 13│ 16│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 10│ 11│ 13│ 16│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Column ID │ 17│ 19│ 21│ 23│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 17│ 19│ 21│ 23│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 25│ 28│ 29│ 32│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 25│ 28│ 29│ 32│
+│ Layer Column ID│ 2│ 3│ 6│ 8│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+Yes
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Column ID │ 34│ 36│ 37│ 39│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 34│ 36│ 37│ 39│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 41│ 43│ 46│ 48│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 41│ 43│ 46│ 48│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Column ID │ 50│ 51│ 53│ 55│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 50│ 51│ 53│ 55│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 58│ 60│ 62│ 64│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 58│ 60│ 62│ 64│
+│ Layer Column ID│ 10│ 12│ 13│ 15│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+
+ Custom Tables
+Female
+No
+╭──────────────────────────────────────────┬───────────────────╮
+│ │ QN27 │
+│ ├─────────┬─────────┤
+│ │ Yes │ No │
+│ ├─────────┼─────────┤
+│ │ QND7A │ QND7A │
+│ ├────┬────┼────┬────┤
+│ │ Yes│ No │ Yes│ No │
+│ ├────┼────┼────┼────┤
+│ │QN86│QN86│QN86│QN86│
+├──────────────────────────────────────────┼────┼────┼────┼────┤
+│QN26 Yes QN61 Yes QN57 Yes Column ID │ 33│ 35│ 38│ 40│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 33│ 35│ 38│ 40│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 42│ 44│ 45│ 47│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 42│ 44│ 45│ 47│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶─────────────────────────────────────┼────┼────┼────┼────┤
+│ No QN61 Yes QN57 Yes Column ID │ 49│ 52│ 54│ 56│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 49│ 52│ 54│ 56│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶────────────────────────────┼────┼────┼────┼────┤
+│ No QN57 Yes Column ID │ 57│ 59│ 61│ 63│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+│ ╶───────────────────┼────┼────┼────┼────┤
+│ No Column ID │ 57│ 59│ 61│ 63│
+│ Layer Column ID│ 9│ 11│ 14│ 16│
+╰──────────────────────────────────────────┴────┴────┴────┴────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES categorical summary functions])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /TABLE region BY qnd5a[COUNT, ROWPCT, ROWPCT.VALIDN, ROWPCT.TOTALN, TOTAL[COUNT, VALIDN, TOTALN]]
+ /CATEGORIES VARIABLES=qnd5a TOTAL=YES MISSING=INCLUDE
+ /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Custom Tables
+╭─────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│ │ D5a. What would you say is your primary ethnic background? │
+│ ├─────┬───────┬───────┬──────────┬──────────┬─────────┬──────────┬──────────────┬──────┬───────┬─────┤
+│ │ │ │ │ │ │ │ │ Multiple - │ │ │ │
+│ │ │ │ │ South │ Central │ Puerto │ Something│ cannot choose│ Don't│ │ │
+│ │Cuban│Mexican│Spanish│ American │ American │Rican, OR│ else │ one │ know │Refused│Total│
+├─────────────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
+│Region NE Count │ 6│ 8│ 8│ 11│ 7│ 39│ 23│ 2│ 0│ 1│ 105│
+│ Row % │ 5.7%│ 7.6%│ 7.6%│ 10.5%│ 6.7%│ 37.1%│ 21.9%│ 1.9%│ .0%│ 1.0%│ │
+│ Row │ 5.8%│ 7.7%│ 7.7%│ 10.6%│ 6.7%│ 37.5%│ 22.1%│ 1.9%│ .0%│ .0%│ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Row │ .4%│ .6%│ .6%│ .8%│ .5%│ 2.8%│ 1.6%│ .1%│ .0%│ .1%│ │
+│ Total N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ 104│
+│ Total N│ │ │ │ │ │ │ │ │ │ │ 1409│
+│ ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
+│ MW Count │ 3│ 24│ 1│ 4│ 5│ 9│ 6│ 0│ 0│ 1│ 53│
+│ Row % │ 5.7%│ 45.3%│ 1.9%│ 7.5%│ 9.4%│ 17.0%│ 11.3%│ .0%│ .0%│ 1.9%│ │
+│ Row │ 5.8%│ 46.2%│ 1.9%│ 7.7%│ 9.6%│ 17.3%│ 11.5%│ .0%│ .0%│ .0%│ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Row │ .2%│ 1.5%│ .1%│ .2%│ .3%│ .5%│ .4%│ .0%│ .0%│ .1%│ │
+│ Total N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ 52│
+│ Total N│ │ │ │ │ │ │ │ │ │ │ 1654│
+│ ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
+│ S Count │ 10│ 113│ 11│ 14│ 25│ 23│ 20│ 2│ 3│ 2│ 223│
+│ Row % │ 4.5%│ 50.7%│ 4.9%│ 6.3%│ 11.2%│ 10.3%│ 9.0%│ .9%│ 1.3%│ .9%│ │
+│ Row │ 4.6%│ 51.8%│ 5.0%│ 6.4%│ 11.5%│ 10.6%│ 9.2%│ .9%│ .0%│ .0%│ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Row │ .4%│ 4.7%│ .5%│ .6%│ 1.0%│ 1.0%│ .8%│ .1%│ .1%│ .1%│ │
+│ Total N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ 218│
+│ Total N│ │ │ │ │ │ │ │ │ │ │ 2390│
+│ ╶──────────┼─────┼───────┼───────┼──────────┼──────────┼─────────┼──────────┼──────────────┼──────┼───────┼─────┤
+│ W Count │ 1│ 166│ 28│ 5│ 15│ 7│ 19│ 3│ 0│ 1│ 245│
+│ Row % │ .4%│ 67.8%│ 11.4%│ 2.0%│ 6.1%│ 2.9%│ 7.8%│ 1.2%│ .0%│ .4%│ │
+│ Row │ .4%│ 68.0%│ 11.5%│ 2.0%│ 6.1%│ 2.9%│ 7.8%│ 1.2%│ .0%│ .0%│ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Row │ .1%│ 10.7%│ 1.8%│ .3%│ 1.0%│ .5%│ 1.2%│ .2%│ .0%│ .1%│ │
+│ Total N│ │ │ │ │ │ │ │ │ │ │ │
+│ % │ │ │ │ │ │ │ │ │ │ │ │
+│ Valid N│ │ │ │ │ │ │ │ │ │ │ 244│
+│ Total N│ │ │ │ │ │ │ │ │ │ │ 1546│
+╰─────────────────┴─────┴───────┴───────┴──────────┴──────────┴─────────┴──────────┴──────────────┴──────┴───────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES scale summary functions])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+SET TVAR=NAME.
+
+* Use SPLIT FILE with FREQUENCIES to generate output equivalent to
+ CTABLES later, to make the results easier to verify.
+SPLIT FILE BY REGION.
+FREQUENCIES
+ qn19a
+ /STATISTICS=MEAN SEMEAN MEDIAN MODE STDDEV VARIANCE RANGE MINIMUM MAXIMUM SUM
+ /FORMAT NOTABLE /MISSING=INCLUDE.
+SPLIT FILE OFF.
+
+CTABLES
+ /VLABELS VARIABLE=qn19a DISPLAY=NONE
+ /TABLE region BY qn19a[VALIDN, MISSING, MEAN, SEMEAN, MEDIAN, MODE, STDDEV, VARIANCE, RANGE, MINIMUM, MAXIMUM, SUM, COUNT, TOTALN, ROWPCT.SUM]
+ /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
+ /SLABELS POSITION=ROW
+ /CLABELS ROWLABELS=OPPOSITE.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Statistics
+╭─────────┬───────────────────────────────────╮
+│ │ REGION │
+│ ├────────┬────────┬────────┬────────┤
+│ │ NE │ MW │ S │ W │
+│ ├────────┼────────┼────────┼────────┤
+│ │ QN19A │ QN19A │ QN19A │ QN19A │
+├─────────┼────────┼────────┼────────┼────────┤
+│N Valid │ 936│ 1019│ 1276│ 950│
+│ Missing│ 473│ 635│ 1114│ 596│
+├─────────┼────────┼────────┼────────┼────────┤
+│Mean │ 19.33│ 19.83│ 20.29│ 19.87│
+├─────────┼────────┼────────┼────────┼────────┤
+│S.E. Mean│ .14│ .16│ .18│ .17│
+├─────────┼────────┼────────┼────────┼────────┤
+│Median │ 18.00│ 19.00│ 19.00│ 19.00│
+├─────────┼────────┼────────┼────────┼────────┤
+│Mode │ 18.00│ 18.00│ 18.00│ 18.00│
+├─────────┼────────┼────────┼────────┼────────┤
+│Std Dev │ 4.41│ 5.15│ 6.44│ 5.25│
+├─────────┼────────┼────────┼────────┼────────┤
+│Variance │ 19.41│ 26.47│ 41.43│ 27.59│
+├─────────┼────────┼────────┼────────┼────────┤
+│Range │ 59.00│ 71.00│ 75.00│ 61.00│
+├─────────┼────────┼────────┼────────┼────────┤
+│Minimum │ .00│ 4.00│ 4.00│ 4.00│
+├─────────┼────────┼────────┼────────┼────────┤
+│Maximum │ 59.00│ 75.00│ 79.00│ 65.00│
+├─────────┼────────┼────────┼────────┼────────┤
+│Sum │18092.00│20206.00│25886.00│18877.00│
+╰─────────┴────────┴────────┴────────┴────────╯
+
+ Custom Tables
+╭────────────────────────┬────────┬────────┬────────┬────────╮
+│ │ NE │ MW │ S │ W │
+├────────────────────────┼────────┼────────┼────────┼────────┤
+│REGION Valid N │ 936│ 1019│ 1276│ 950│
+│ Missing │ 473.00│ 635.00│ 1114.00│ 596.00│
+│ Mean │ 19.33│ 19.83│ 20.29│ 19.87│
+│ Std Error of Mean│ .14│ .16│ .18│ .17│
+│ Median │ 18.00│ 19.00│ 19.00│ 19.00│
+│ Mode │ 18.00│ 18.00│ 18.00│ 18.00│
+│ Std Deviation │ 4.41│ 5.15│ 6.44│ 5.25│
+│ Variance │ 19.41│ 26.47│ 41.43│ 27.59│
+│ Range │ 59.00│ 71.00│ 75.00│ 61.00│
+│ Minimum │ .00│ 4.00│ 4.00│ 4.00│
+│ Maximum │ 59.00│ 75.00│ 79.00│ 65.00│
+│ Sum │18092.00│20206.00│25886.00│18877.00│
+│ Count │ 1409│ 1654│ 2390│ 1546│
+│ Total N │ 1409│ 1654│ 2390│ 1546│
+│ Row Sum % │ 21.8%│ 24.3%│ 31.2%│ 22.7%│
+╰────────────────────────┴────────┴────────┴────────┴────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES scale summary functions - weighting])
+weight=1
+c=10
+for a in 1 2 9; do
+ for b in 3 4 9; do
+ for n in 1 2 3 4 5 6 7 8 9 10; do
+ if test $c -lt 15; then
+ cval=.
+ else
+ cval=$c
+ fi
+ printf "$weight $a $b $cval\n"
+ weight=$(expr \( $weight + 3 \) % 7 + 2)
+ c=$(expr \( $c + 13 \) % 29 + 7)
+ done
+ done
+done > ctables.txt
+
+AT_DATA([analysis.sps],
+[[* Use SPLIT FILE with FREQUENCIES to generate output equivalent to
+ CTABLES later, to make the results easier to verify.
+SPLIT FILE BY a b.
+FREQUENCIES
+ c
+ /STATISTICS=MEAN SEMEAN MEDIAN MODE STDDEV VARIANCE RANGE MINIMUM MAXIMUM SUM
+ /FORMAT NOTABLE /MISSING=INCLUDE.
+SPLIT FILE OFF.
+
+CTABLES
+ /TABLE c[VALIDN, MISSING, MEAN F8.2, SEMEAN F8.2, MEDIAN F8.2, MODE, STDDEV F8.2, VARIANCE F8.2, RANGE F8.2, MINIMUM, MAXIMUM, SUM F8.2, COUNT, TOTALN, LAYERROWPCT.SUM] BY a>b
+ /SLABELS POSITION=ROW
+ /CATEGORIES VARIABLES=a b MISSING=INCLUDE.
+]])
+
+AT_DATA([ctables.sps],
+[[DATA LIST LIST NOTABLE FILE='ctables.txt'
+ /w (F5.0) a b c (f2.0).
+VAR LEVEL w c (SCALE) a b (NOMINAL).
+MISSING VALUES a b (9).
+
+INCLUDE 'analysis.sps'.
+
+WEIGHT BY w.
+INCLUDE 'analysis.sps'.
+
+* Same as original analysis using unweighted versions of summaries.
+CTABLES
+ /TABLE c[UVALIDN, UMISSING, UMEAN F8.2, USEMEAN F8.2, UMEDIAN F8.2, UMODE, USTDDEV F8.2, UVARIANCE F8.2, USUM F8.2, UCOUNT, UTOTALN, ULAYERROWPCT.SUM] BY a>b
+ /SLABELS POSITION=ROW
+ /CATEGORIES VARIABLES=a b MISSING=INCLUDE.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+ Statistics
+╭─────────┬──────────────────────────────────────────────────────────────╮
+│ │ a │
+│ ├────────────────────┬────────────────────┬────────────────────┤
+│ │ 1 │ 2 │ 9 │
+│ ├────────────────────┼────────────────────┼────────────────────┤
+│ │ b │ b │ b │
+│ ├──────┬──────┬──────┼──────┬──────┬──────┼──────┬──────┬──────┤
+│ │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │
+│ ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│ │ c │ c │ c │ c │ c │ c │ c │ c │ c │
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│N Valid │ 7│ 6│ 8│ 7│ 7│ 8│ 7│ 7│ 8│
+│ Missing│ 3│ 4│ 2│ 3│ 3│ 2│ 3│ 3│ 2│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Mean │ 25.86│ 24.50│ 24.63│ 25.86│ 25.71│ 24.25│ 25.43│ 25.29│ 23.88│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│S.E. Mean│ 2.44│ 2.14│ 2.58│ 2.44│ 2.18│ 2.43│ 2.36│ 2.18│ 2.47│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Median │ 25.00│ 24.50│ 25.00│ 25.00│ 27.00│ 25.00│ 25.00│ 24.00│ 23.50│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Mode │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Std Dev │ 6.47│ 5.24│ 7.31│ 6.47│ 5.77│ 6.88│ 6.24│ 5.77│ 6.98│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Variance │ 41.81│ 27.50│ 53.41│ 41.81│ 33.24│ 47.36│ 38.95│ 33.24│ 48.70│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Range │ 18.00│ 13.00│ 20.00│ 18.00│ 15.00│ 20.00│ 18.00│ 15.00│ 20.00│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Minimum │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Maximum │ 34│ 31│ 35│ 34│ 33│ 35│ 34│ 33│ 35│
+├─────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│Sum │181.00│147.00│197.00│181.00│180.00│194.00│178.00│177.00│191.00│
+╰─────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
+
+ Custom Tables
+╭───────────────────┬──────────────────────────────────────────────────────────────╮
+│ │ a │
+│ ├────────────────────┬────────────────────┬────────────────────┤
+│ │ 1 │ 2 │ 9 │
+│ ├────────────────────┼────────────────────┼────────────────────┤
+│ │ b │ b │ b │
+│ ├──────┬──────┬──────┼──────┬──────┬──────┼──────┬──────┬──────┤
+│ │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │
+├───────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│c Valid N │ 7│ 6│ 8│ 7│ 7│ 8│ 7│ 7│ 8│
+│ Missing │ 3│ 4│ 2│ 3│ 3│ 2│ 3│ 3│ 2│
+│ Mean │ 25.86│ 24.50│ 24.63│ 25.86│ 25.71│ 24.25│ 25.43│ 25.29│ 23.88│
+│ Std Error of Mean│ 2.44│ 2.14│ 2.58│ 2.44│ 2.18│ 2.43│ 2.36│ 2.18│ 2.47│
+│ Median │ 25.00│ 24.50│ 25.00│ 25.00│ 27.00│ 25.00│ 25.00│ 24.00│ 23.50│
+│ Mode │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+│ Std Deviation │ 6.47│ 5.24│ 7.31│ 6.47│ 5.77│ 6.88│ 6.24│ 5.77│ 6.98│
+│ Variance │ 41.81│ 27.50│ 53.41│ 41.81│ 33.24│ 47.36│ 38.95│ 33.24│ 48.70│
+│ Range │ 18.00│ 13.00│ 20.00│ 18.00│ 15.00│ 20.00│ 18.00│ 15.00│ 20.00│
+│ Minimum │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+│ Maximum │ 34│ 31│ 35│ 34│ 33│ 35│ 34│ 33│ 35│
+│ Sum │181.00│147.00│197.00│181.00│180.00│194.00│178.00│177.00│191.00│
+│ Count │ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│
+│ Total N │ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│
+│ Layer Row Sum % │ 11.1%│ 9.0%│ 12.1%│ 11.1%│ 11.1%│ 11.9%│ 10.9%│ 10.9%│ 11.7%│
+╰───────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
+
+ Statistics
+╭─────────┬─────────────────────────────────────────────────────────────────╮
+│ │ a │
+│ ├─────────────────────┬─────────────────────┬─────────────────────┤
+│ │ 1 │ 2 │ 9 │
+│ ├─────────────────────┼─────────────────────┼─────────────────────┤
+│ │ b │ b │ b │
+│ ├───────┬──────┬──────┼──────┬───────┬──────┼──────┬──────┬───────┤
+│ │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │
+│ ├───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│ │ c │ c │ c │ c │ c │ c │ c │ c │ c │
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│N Valid │ 40│ 35│ 41│ 26│ 38│ 40│ 34│ 32│ 39│
+│ Missing│ 6│ 14│ 11│ 22│ 13│ 7│ 16│ 21│ 10│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Mean │ 27.23│ 24.20│ 22.63│ 27.96│ 27.21│ 23.48│ 23.71│ 25.47│ 26.03│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│S.E. Mean│ .93│ .75│ 1.03│ 1.12│ .84│ .87│ 1.01│ 1.05│ 1.01│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Median │ 30.00│ 22.00│ 19.00│ 30.00│ 29.00│ 24.00│ 23.00│ 24.00│ 28.00│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Mode │ 34│ 29│ 19│ 34│ 33│ 28│ 23│ 18│ 30│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Std Dev │ 5.89│ 4.42│ 6.59│ 5.69│ 5.16│ 5.50│ 5.87│ 5.94│ 6.30│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Variance │ 34.64│ 19.52│ 43.39│ 32.36│ 26.66│ 30.20│ 34.46│ 35.29│ 39.71│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Range │ 18.00│ 13.00│ 20.00│ 18.00│ 15.00│ 20.00│ 18.00│ 15.00│ 20.00│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Minimum │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Maximum │ 34│ 31│ 35│ 34│ 33│ 35│ 34│ 33│ 35│
+├─────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│Sum │1089.00│847.00│928.00│727.00│1034.00│939.00│806.00│815.00│1015.00│
+╰─────────┴───────┴──────┴──────┴──────┴───────┴──────┴──────┴──────┴───────╯
+
+ Custom Tables
+╭───────────────────┬─────────────────────────────────────────────────────────────────╮
+│ │ a │
+│ ├─────────────────────┬─────────────────────┬─────────────────────┤
+│ │ 1 │ 2 │ 9 │
+│ ├─────────────────────┼─────────────────────┼─────────────────────┤
+│ │ b │ b │ b │
+│ ├───────┬──────┬──────┼──────┬───────┬──────┼──────┬──────┬───────┤
+│ │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │
+├───────────────────┼───────┼──────┼──────┼──────┼───────┼──────┼──────┼──────┼───────┤
+│c Valid N │ 40│ 35│ 41│ 26│ 38│ 40│ 34│ 32│ 39│
+│ Missing │ 6│ 14│ 11│ 22│ 13│ 7│ 16│ 21│ 10│
+│ Mean │ 27.22│ 24.20│ 22.63│ 27.96│ 27.21│ 23.48│ 23.71│ 25.47│ 26.03│
+│ Std Error of Mean│ .93│ .75│ 1.03│ 1.12│ .84│ .87│ 1.01│ 1.05│ 1.01│
+│ Median │ 30.00│ 22.00│ 19.00│ 30.00│ 29.00│ 24.00│ 23.00│ 24.00│ 28.00│
+│ Mode │ 34│ 29│ 19│ 34│ 33│ 28│ 23│ 18│ 30│
+│ Std Deviation │ 5.89│ 4.42│ 6.59│ 5.69│ 5.16│ 5.50│ 5.87│ 5.94│ 6.30│
+│ Variance │ 34.64│ 19.52│ 43.39│ 32.36│ 26.66│ 30.20│ 34.46│ 35.29│ 39.71│
+│ Range │ 18.00│ 13.00│ 20.00│ 18.00│ 15.00│ 20.00│ 18.00│ 15.00│ 20.00│
+│ Minimum │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+│ Maximum │ 34│ 31│ 35│ 34│ 33│ 35│ 34│ 33│ 35│
+│ Sum │1089.00│847.00│928.00│727.00│1034.00│939.00│806.00│815.00│1015.00│
+│ Count │ 46│ 49│ 52│ 48│ 51│ 47│ 50│ 53│ 49│
+│ Total N │ 46│ 49│ 52│ 48│ 51│ 47│ 50│ 53│ 49│
+│ Layer Row Sum % │ 13.3%│ 10.3%│ 11.3%│ 8.9%│ 12.6%│ 11.5%│ 9.8%│ 9.9%│ 12.4%│
+╰───────────────────┴───────┴──────┴──────┴──────┴───────┴──────┴──────┴──────┴───────╯
+
+ Custom Tables
+╭──────────────────────────────┬──────────────────────────────────────────────────────────────╮
+│ │ a │
+│ ├────────────────────┬────────────────────┬────────────────────┤
+│ │ 1 │ 2 │ 9 │
+│ ├────────────────────┼────────────────────┼────────────────────┤
+│ │ b │ b │ b │
+│ ├──────┬──────┬──────┼──────┬──────┬──────┼──────┬──────┬──────┤
+│ │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │ 3 │ 4 │ 9 │
+├──────────────────────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
+│c Unweighted Valid N │ 7│ 6│ 8│ 7│ 7│ 8│ 7│ 7│ 8│
+│ Unweighted Missing │ 3│ 4│ 2│ 3│ 3│ 2│ 3│ 3│ 2│
+│ Unweighted Mean │ 25.86│ 24.50│ 24.63│ 25.86│ 25.71│ 24.25│ 25.43│ 25.29│ 23.88│
+│ Unweighted Std Error of Mean│ 2.44│ 2.14│ 2.58│ 2.44│ 2.18│ 2.43│ 2.36│ 2.18│ 2.47│
+│ Unweighted Median │ 25.00│ 24.50│ 25.00│ 25.00│ 27.00│ 25.00│ 25.00│ 24.00│ 23.50│
+│ Unweighted Mode │ 16│ 18│ 15│ 16│ 18│ 15│ 16│ 18│ 15│
+│ Unweighted Std Deviation │ 6.47│ 5.24│ 7.31│ 6.47│ 5.77│ 6.88│ 6.24│ 5.77│ 6.98│
+│ Unweighted Variance │ 41.81│ 27.50│ 53.41│ 41.81│ 33.24│ 47.36│ 38.95│ 33.24│ 48.70│
+│ Unweighted Sum │181.00│147.00│197.00│181.00│180.00│194.00│178.00│177.00│191.00│
+│ Unweighted Count │ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│
+│ Unweighted Total N │ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│ 10│
+│ Unweighted Layer Row Sum % │ 11.1%│ 9.0%│ 12.1%│ 11.1%│ 11.1%│ 11.9%│ 10.9%│ 10.9%│ 11.7%│
+╰──────────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES hidden scale VLABELS])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+CTABLES
+ /VLABELS VARIABLE=qn19a DISPLAY=NONE
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+CTABLES
+ /VLABELS VARIABLE=qn35 DISPLAY=NONE
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+
+* This one in particular caused a crash because no categories were
+ created on the column axis, so passing in 0 for the index was still
+ too big for that number of categories. It was fixed by creating a
+ name-only category for each variable despite the "NONE" request,
+ then hiding the entire dimension's labels if all its labels were
+ set to "NONE".
+CTABLES
+ /VLABELS VARIABLE=qn19a qn35 DISPLAY=NONE
+ /TABLE region BY qn19a + qn35
+ /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+ Custom Tables
+╭──────────────┬────────────────────────────┬─────────────────────────────────╮
+│ │ 19a. About how old were you│ 35. In the past thirty days, how│
+│ │ when you first starting │ many times have you driven a │
+│ │ drinking alcohol, not │ motor vehicle WITHIN TWO HOURS │
+│ │ counting small tastes or │ AFTER drinking alcoholic │
+│ │ sips of alcohol. │ beverages? │
+├──────────────┼────────────────────────────┼─────────────────────────────────┤
+│Region NE Mean│ 19.33│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ MW Mean│ 19.83│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ S Mean│ 20.29│ 2│
+│ ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│ W Mean│ 19.87│ 2│
+╰──────────────┴────────────────────────────┴─────────────────────────────────╯
+
+ Custom Tables
+╭──────────────┬─────┬────────────────────────────────────────────────────────╮
+│ │ │ 35. In the past thirty days, how many times have you │
+│ │ │ driven a motor vehicle WITHIN TWO HOURS AFTER drinking │
+│ │QN19A│ alcoholic beverages? │
+├──────────────┼─────┼────────────────────────────────────────────────────────┤
+│Region NE Mean│19.33│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ MW Mean│19.83│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ S Mean│20.29│ 2│
+│ ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│ W Mean│19.87│ 2│
+╰──────────────┴─────┴────────────────────────────────────────────────────────╯
+
+ Custom Tables
+╭──────────────┬─────────────────────────────────────────────────────────┬────╮
+│ │ 19a. About how old were you when you first starting │ │
+│ │ drinking alcohol, not counting small tastes or sips of │ │
+│ │ alcohol. │qn35│
+├──────────────┼─────────────────────────────────────────────────────────┼────┤
+│Region NE Mean│ 19.33│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ MW Mean│ 19.83│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ S Mean│ 20.29│ 2│
+│ ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│ W Mean│ 19.87│ 2│
+╰──────────────┴─────────────────────────────────────────────────────────┴────╯
+
+ Custom Tables
+╭──────────────┬───────╮
+│Region NE Mean│19.33 2│
+│ ╶───────┼───────┤
+│ MW Mean│19.83 2│
+│ ╶───────┼───────┤
+│ S Mean│20.29 2│
+│ ╶───────┼───────┤
+│ W Mean│19.87 2│
+╰──────────────┴───────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES with SPLIT FILE])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+
+SORT CASES BY qns3a.
+
+CTABLES /TABLE qn105ba.
+
+* Layered split has no effect on output.
+SPLIT FILE BY qns3a.
+CTABLES /TABLE qn105ba.
+
+* Add column variable qns3a to compare against separate splits.
+CTABLES /TABLE qn105ba BY qns3a.
+
+* Separate splits are truly output separately.
+SPLIT FILE SEPARATE BY qns3a.
+CTABLES /TABLE qn105ba.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│105b. How likely is it that drivers who have had too much Almost │ 700│
+│to drink to drive safely will A. Get stopped by the police? certain │ │
+│ Very likely │ 1502│
+│ Somewhat │ 2763│
+│ likely │ │
+│ Somewhat │ 1307│
+│ unlikely │ │
+│ Very │ 609│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│105b. How likely is it that drivers who have had too much Almost │ 700│
+│to drink to drive safely will A. Get stopped by the police? certain │ │
+│ Very likely │ 1502│
+│ Somewhat │ 2763│
+│ likely │ │
+│ Somewhat │ 1307│
+│ unlikely │ │
+│ Very │ 609│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Custom Tables
+╭─────────────────────────────────────────────────────────────────┬────────────╮
+│ │S3a. GENDER:│
+│ ├─────┬──────┤
+│ │ Male│Female│
+│ ├─────┼──────┤
+│ │Count│ Count│
+├─────────────────────────────────────────────────────────────────┼─────┼──────┤
+│105b. How likely is it that drivers who have had too Almost │ 297│ 403│
+│much to drink to drive safely will A. Get stopped by certain │ │ │
+│the police? Very likely │ 660│ 842│
+│ Somewhat │ 1174│ 1589│
+│ likely │ │ │
+│ Somewhat │ 640│ 667│
+│ unlikely │ │ │
+│ Very │ 311│ 298│
+│ unlikely │ │ │
+╰─────────────────────────────────────────────────────────────────┴─────┴──────╯
+
+ Split Values
+╭────────────┬─────╮
+│Variable │Value│
+├────────────┼─────┤
+│S3a. GENDER:│Male │
+╰────────────┴─────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│105b. How likely is it that drivers who have had too much Almost │ 297│
+│to drink to drive safely will A. Get stopped by the police? certain │ │
+│ Very likely │ 660│
+│ Somewhat │ 1174│
+│ likely │ │
+│ Somewhat │ 640│
+│ unlikely │ │
+│ Very │ 311│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+ Split Values
+╭────────────┬──────╮
+│Variable │ Value│
+├────────────┼──────┤
+│S3a. GENDER:│Female│
+╰────────────┴──────╯
+
+ Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│ │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│105b. How likely is it that drivers who have had too much Almost │ 403│
+│to drink to drive safely will A. Get stopped by the police? certain │ │
+│ Very likely │ 842│
+│ Somewhat │ 1589│
+│ likely │ │
+│ Somewhat │ 667│
+│ unlikely │ │
+│ Very │ 298│
+│ unlikely │ │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES variable level inference])
+AT_DATA([data.txt], [dnl
+dnl n1 has 10 unique small values -> nominal.
+dnl n2 has 23 unique small values -> nominal.
+dnl n3 is all missing -> nominal.
+dnl s1 has 24 unique small values -> scale.
+dnl s2 has one negative value -> scale.
+dnl s3 has one non-integer value -> scale.
+dnl s4 has no valid values less than 10 -> scale.
+dnl s5 has no valid values less than 10,000 -> scale.
+1 1 . 1 1 1 10 10001
+2 2 . 2 2 2 11 10002
+3 3 . 3 3 3 12 10003
+4 4 . 4 4 4 13 10004
+5 5 . 5 5 5 14 10005
+6 6 . 6 6 6 15 10006
+7 7 . 7 7 7 16 10007
+8 8 . 8 8 8 17 10008
+9 9 . 9 9 9 18 10009
+10 10 . 10 10 10.5 19 110000
+1 11 . 11 -1 1 11 10001
+2 12 . 12 2 2 12 10002
+3 13 . 13 3 3 13 10003
+4 14 . 14 4 4 14 10004
+5 15 . 15 5 5 15 10005
+6 16 . 16 6 6 16 10006
+7 17 . 17 7 7 17 10007
+8 18 . 18 8 8 18 10008
+9 19 . 19 9 9 19 10009
+1 20 . 20 1 1 20 10001
+2 21 . 21 2 2 21 10002
+3 22 . 22 3 3 22 10003
+4 23 . 23 4 4 23 10004
+5 23 . 24 5 5 24 10005
+6 23 . 24 6 6 25 10006
+])
+
+AT_DATA([ctables.sps], [dnl
+DATA LIST LIST file='data.txt' NOTABLE /n1 to n3 s1 to s5.
+
+* Nominal formats (copied from data that will default to scale).
+COMPUTE n4=s1.
+COMPUTE n5=s1.
+FORMATS n4(WKDAY5) n5(MONTH5).
+
+* Scale formats (copied from data that will default to nominal).
+COMPUTE s6=n1.
+COMPUTE s7=n1.
+COMPUTE s8=n1.
+FORMATS s6(DOLLAR6.2) s7(CCA8.2) s8(DATETIME17).
+
+STRING string(A8).
+
+DISPLAY DICTIONARY.
+CTABLES /TABLE n1 + n2 + n3 + string + s1 + s2 + s3 + s4 + s5.
+DISPLAY DICTIONARY.
+])
+
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Variables
+╭──────┬────────┬──────────────┬─────┬─────┬─────────┬────────────┬────────────╮
+│ │ │ Measurement │ │ │ │ │ │
+│Name │Position│ Level │ Role│Width│Alignment│Print Format│Write Format│
+├──────┼────────┼──────────────┼─────┼─────┼─────────┼────────────┼────────────┤
+│n1 │ 1│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│n2 │ 2│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│n3 │ 3│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│s1 │ 4│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│s2 │ 5│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│s3 │ 6│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│s4 │ 7│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│s5 │ 8│Unknown │Input│ 8│Right │F8.2 │F8.2 │
+│n4 │ 9│Unknown │Input│ 8│Right │WKDAY5 │WKDAY5 │
+│n5 │ 10│Unknown │Input│ 8│Right │MONTH5 │MONTH5 │
+│s6 │ 11│Unknown │Input│ 8│Right │DOLLAR6.2 │DOLLAR6.2 │
+│s7 │ 12│Unknown │Input│ 8│Right │CCA8.2 │CCA8.2 │
+│s8 │ 13│Unknown │Input│ 8│Right │DATETIME17.0│DATETIME17.0│
+│string│ 14│Nominal │Input│ 8│Left │A8 │A8 │
+╰──────┴────────┴──────────────┴─────┴─────┴─────────┴────────────┴────────────╯
+
+ Custom Tables
+╭────────────┬─────┬────────╮
+│ │Count│ Mean │
+├────────────┼─────┼────────┤
+│n1 1.00 │ 3│ │
+│ 2.00 │ 3│ │
+│ 3.00 │ 3│ │
+│ 4.00 │ 3│ │
+│ 5.00 │ 3│ │
+│ 6.00 │ 3│ │
+│ 7.00 │ 2│ │
+│ 8.00 │ 2│ │
+│ 9.00 │ 2│ │
+│ 10.00│ 1│ │
+├────────────┼─────┼────────┤
+│n2 1.00 │ 1│ │
+│ 2.00 │ 1│ │
+│ 3.00 │ 1│ │
+│ 4.00 │ 1│ │
+│ 5.00 │ 1│ │
+│ 6.00 │ 1│ │
+│ 7.00 │ 1│ │
+│ 8.00 │ 1│ │
+│ 9.00 │ 1│ │
+│ 10.00│ 1│ │
+│ 11.00│ 1│ │
+│ 12.00│ 1│ │
+│ 13.00│ 1│ │
+│ 14.00│ 1│ │
+│ 15.00│ 1│ │
+│ 16.00│ 1│ │
+│ 17.00│ 1│ │
+│ 18.00│ 1│ │
+│ 19.00│ 1│ │
+│ 20.00│ 1│ │
+│ 21.00│ 1│ │
+│ 22.00│ 1│ │
+│ 23.00│ 3│ │
+├────────────┼─────┼────────┤
+│string │ 25│ │
+├────────────┼─────┼────────┤
+│s1 │ │ 12.96│
+├────────────┼─────┼────────┤
+│s2 │ │ 4.76│
+├────────────┼─────┼────────┤
+│s3 │ │ 4.86│
+├────────────┼─────┼────────┤
+│s4 │ │ 16.60│
+├────────────┼─────┼────────┤
+│s5 │ │14004.44│
+╰────────────┴─────┴────────╯
+
+ Variables
+╭──────┬────────┬──────────────┬─────┬─────┬─────────┬────────────┬────────────╮
+│ │ │ Measurement │ │ │ │ │ │
+│Name │Position│ Level │ Role│Width│Alignment│Print Format│Write Format│
+├──────┼────────┼──────────────┼─────┼─────┼─────────┼────────────┼────────────┤
+│n1 │ 1│Nominal │Input│ 8│Right │F8.2 │F8.2 │
+│n2 │ 2│Nominal │Input│ 8│Right │F8.2 │F8.2 │
+│n3 │ 3│Nominal │Input│ 8│Right │F8.2 │F8.2 │
+│s1 │ 4│Scale │Input│ 8│Right │F8.2 │F8.2 │
+│s2 │ 5│Scale │Input│ 8│Right │F8.2 │F8.2 │
+│s3 │ 6│Scale │Input│ 8│Right │F8.2 │F8.2 │
+│s4 │ 7│Scale │Input│ 8│Right │F8.2 │F8.2 │
+│s5 │ 8│Scale │Input│ 8│Right │F8.2 │F8.2 │
+│n4 │ 9│Nominal │Input│ 8│Right │WKDAY5 │WKDAY5 │
+│n5 │ 10│Nominal │Input│ 8│Right │MONTH5 │MONTH5 │
+│s6 │ 11│Scale │Input│ 8│Right │DOLLAR6.2 │DOLLAR6.2 │
+│s7 │ 12│Scale │Input│ 8│Right │CCA8.2 │CCA8.2 │
+│s8 │ 13│Scale │Input│ 8│Right │DATETIME17.0│DATETIME17.0│
+│string│ 14│Nominal │Input│ 8│Left │A8 │A8 │
+╰──────┴────────┴──────────────┴─────┴─────┴─────────┴────────────┴────────────╯
+])
+AT_CLEANUP