dates
[pspp] / tests / language / stats / ctables.at
index 726da3d723c4e3fc50060a329306ead40e143f6c..12caa73d3b3c0b57bacb64900f091c950e88224a 100644 (file)
@@ -7,18 +7,6 @@ dnl - Test WEIGHT and adjustment weights.
 dnl - Summary functions:
 dnl   * Separate summary functions for totals and subtotals.
 dnl   * )CILEVEL in summary label specification
-dnl - CATEGORIES:
-dnl   * Date values
-dnl   * THRU (numeric ranges)
-dnl   * OTHERNM
-dnl - Date/time variables and values
-dnl - Test PCOMPUTE:
-dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
-dnl   * MISSING, OTHERNM
-dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
-dnl   * dates
-dnl - PPROPERTIES:
-dnl   * )LABEL[N].
 dnl - Summary functions:
 dnl   * U-prefix for unweighted summaries.
 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
@@ -841,6 +829,7 @@ D1. AGE: What is your age?
 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'.
@@ -1077,6 +1066,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 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'.
@@ -1281,6 +1271,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 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'.
@@ -1609,37 +1600,267 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 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' HIDESOURCECATS=YES FORMAT=COUNT F8.2
-    /PPROPERTIES &y LABEL='4+5'
-    /TABLE=qn105ba BY qns1
-    /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
+    /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
-╭────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮
-│                                                        │  S1. Including yourself, how many members of this household │
-│                                                        │                     are age 16 or older?                    │
-│                                                        ├───────┬───────┬──────────┬───────┬────────┬──────┬──────────┤
-│                                                        │   1   │   2   │ Subtotal │   5   │   3+4  │  4+5 │ Subtotal │
-│                                                        ├───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
-│                                                        │ Count │ Count │   Count  │ Count │  Count │ Count│   Count  │
-├────────────────────────────────────────────────────────┼───────┼───────┼──────────┼───────┼────────┼──────┼──────────┤
-│105b. How likely is it that drivers who have Almost     │    147│    246│       393│     11│   81.00│    30│        92│
-│had too much to drink to drive safely will   certain    │       │       │          │       │        │      │          │
-│A. Get stopped by the police?                Very likely│    384│    552│       936│     14│  171.00│    65│       185│
-│                                             Somewhat   │    590│   1249│      1839│     20│  265.00│    92│       285│
-│                                             likely     │       │       │          │       │        │      │          │
-│                                             Somewhat   │    278│    647│       925│      6│  116.00│    38│       122│
-│                                             unlikely   │       │       │          │       │        │      │          │
-│                                             Very       │    141│    290│       431│      4│   59.00│    22│        63│
-│                                             unlikely   │       │       │          │       │        │      │          │
-╰────────────────────────────────────────────────────────┴───────┴───────┴──────────┴───────┴────────┴──────┴──────────╯
+                                              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
 
@@ -1653,7 +1874,6 @@ CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=LAYER.
 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=LAYER.
 ]])
-pwd
 AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [dnl
              Custom Tables
 ╭───────────────────────┬────────────╮
@@ -2149,7 +2369,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 ])
 AT_CLEANUP
 
-AT_SETUP([CTABLES VLABELS])
+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'.
@@ -2254,6 +2474,273 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
 ])
 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],
@@ -2960,16 +3447,91 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 AT_CLEANUP
 
 
-AT_SETUP([CTABLES scale summary functions - assertion failure])
+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
-    /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
+    /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 -O width=120], [0], [])
+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