sort orders
[pspp] / tests / language / stats / ctables.at
index 82e0f9bea8bfc703cc6cdc99331461437a8a12a7..4b520cc0cddd540a19ebeb8bfbb4660970772469 100644 (file)
@@ -2,37 +2,20 @@ AT_BANNER([CTABLES])
 
 dnl Features not yet tested:
 dnl - Preprocessing to distinguish categorical from scale.
-dnl - String variables and values
 dnl - Testing details of missing value handling in summaries.
-dnl - test CLABELS ROWLABELS=LAYER.
-dnl - Test VLABELS.
 dnl - Test WEIGHT and adjustment weights.
-dnl - EMPTY=INCLUDE For string ranges.
 dnl - Summary functions:
 dnl   * Separate summary functions for totals and subtotals.
 dnl   * )CILEVEL in summary label specification
-dnl Category sorting:
-dnl   * VALUE
-dnl   * LABEL
-dnl   * ascending/descending
 dnl - CATEGORIES:
-dnl   * String values
 dnl   * Date values
 dnl   * THRU (numeric ranges)
-dnl   * THRU (string ranges)
 dnl   * OTHERNM
-dnl - FORMAT:
-dnl   * MINCOLWIDTH, MAXCOLWIDTH, UNITS.
-dnl   * EMPTY.
-dnl   * MISSING.
-dnl - HIDESMALLCOUNTS.
 dnl - Date/time variables and values
-dnl - Special formats for summary functions: NEGPAREN, NEQUAL, PAREN, PCTPAREN.
 dnl - TITLES: )DATE, )TIME, )TABLE.
 dnl - Test PCOMPUTE:
 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
 dnl   * MISSING, OTHERNM
-dnl   * strings and string ranges
 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
 dnl   * dates
 dnl - PPROPERTIES:
@@ -54,23 +37,6 @@ dnl   * .LCL and .UCL suffixes.
 dnl   * .SE suffixes.
 dnl - CATEGORIES:
 dnl   * Data-dependent sorting.
-dnl
-dnl
-dnl Bug:
-dnl     CTABLES /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a.
-dnl produces a bad median:
-dnl                     Custom Tables
-dnl +--------------------------+-----------------------+
-dnl |                          |      S3a. GENDER:     |
-dnl |                          +-----------+-----------+
-dnl |                          |    Male   |   Female  |
-dnl |                          +----+------+----+------+
-dnl |                          |Mean|Median|Mean|Median|
-dnl +--------------------------+----+------+----+------+
-dnl |D1. AGE: What is your age?|  46|   999|  50|   999|
-dnl +--------------------------+----+------+----+------+
-
-
 
 AT_SETUP([CTABLES parsing])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
@@ -557,23 +523,6 @@ 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'].
       |                                                    ^~~~~
-
-ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
-
-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.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].
-      |                                                  ^~~~~
 ]])
 AT_CLEANUP
 
@@ -760,6 +709,96 @@ Every day
 ])
 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 &notyes=EXPR(['No']+['DontKnow']+['Refused'])
+    /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
+    /TABLE licensed
+    /CATEGORIES VARIABLES=licensed ['Yes', &notyes, 'No', 'DontKnow', 'Refused'].
+CTABLES
+    /PCOMPUTE &notyes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
+    /PPROPERTIES &notyes LABEL='Not Yes' HIDESOURCECATS=YES
+    /TABLE licensed
+    /CATEGORIES VARIABLES=licensed ['Yes', &notyes, '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],
@@ -951,6 +990,88 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 ])
 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_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
@@ -1522,10 +1643,31 @@ 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 -O box=unicode -O width=120], [0], [dnl
+pwd
+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:                                                 │
@@ -1568,6 +1710,122 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 │          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
 
@@ -1886,3 +2144,351 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 ╰────────┴─────╯
 ])
 AT_CLEANUP
+
+AT_SETUP([CTABLES VLABELS])
+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 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