)LABEL[N]. untested, probably doesn't work.
[pspp] / tests / language / stats / ctables.at
index 1b7021438e98fba13e2e23acdb1c58cceb220183..1d787428d3fd96cd8a8585e7228595f349f5a3f2 100644 (file)
@@ -2,7 +2,6 @@ AT_BANNER([CTABLES])
 
 dnl Features not yet implemented:
 dnl
-dnl - Date/time variables and values
 dnl - SPLIT FILE with SEPARATE splits
 dnl - Definition of columns/rows when labels are rotated from one axis to another.
 dnl - Preprocessing to distinguish categorical from scale.
@@ -12,21 +11,14 @@ dnl   * Unimplemented ones.
 dnl   * U-prefix for unweighted summaries.
 dnl   * .LCL and .UCL suffixes.
 dnl   * .SE suffixes.
-dnl   * Why are summary functions for scale variables also available for totals and subtotals?
 dnl - CATEGORIES:
-dnl   * String values
-dnl   * Date values
 dnl   * Data-dependent sorting.
-dnl - TITLES: )DATE, )TIME, )TABLE.
-dnl - SMISSING (see documentation).
 dnl - PCOMPUTE:
 dnl   * multi-dimensional
 dnl   * MISSING, OTHERNM
 dnl   * strings
 dnl - PPROPERTIES:
-dnl   * )LABEL[N].
 dnl   * summary statistics and formats?
-dnl - Are string ranges a thing?
 dnl
 dnl Features not yet tested:
 dnl - Parsing (positive and negative)
@@ -36,17 +28,25 @@ dnl - test CLABELS ROWLABELS=LAYER.
 dnl - Test VLABELS.
 dnl - Test WEIGHT and adjustment weights.
 dnl - Test PCOMPUTE and PPROPERTIES.
+dnl - EMPTY=INCLUDE For string ranges.
 dnl - Summary functions:
 dnl   * Separate summary functions for totals and subtotals.
 dnl - CATEGORIES:
-dnl   * THRU
+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 - PPROPERTIES:
+dnl   * )LABEL[N].
 dnl
 dnl Not for v1:
 dnl - Multiple response sets
@@ -978,17 +978,274 @@ BEGIN DATA.
 . 3
 . 4
 . 5
+. .
 END DATA.
 MISSING VALUES x (1, 2) y (2, 3).
 VARIABLE LEVEL ALL (NOMINAL).
 
-CTABLES /TABLE x[COUNT,TOTALS[COUNT, VALIDN, TOTALN]]
+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,TOTALS[COUNT, VALIDN, TOTALN]]
+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.
-CTABLES /TABLE x BY y /CATEGORIES VARIABLES=ALL MISSING=INCLUDE.
-CTABLES /TABLE y BY x /CATEGORIES VARIABLES=ALL 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], [])
-AT_CLEANUP
\ No newline at end of file
+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 %│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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 %│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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 %│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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         │     6│     6│     6│    36│
+╰────────────────────────┴──────┴──────┴──────┴──────╯
+
+                            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 %│   .0%│     .│     .│   .0%│   .0%│     .│
+│        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
+│        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│        Row Valid N %   │     .│     .│     .│     .│     .│     .│
+│        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│        Valid N         │      │      │      │      │      │     0│
+│        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 %│   .0%│     .│     .│   .0%│   .0%│     .│
+│        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
+│        Row %           │ 20.0%│ 20.0%│ 20.0%│ 20.0%│ 20.0%│100.0%│
+│        Row Valid N %   │     .│     .│     .│     .│     .│     .│
+│        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│        Valid N         │      │      │      │      │      │     0│
+│        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 %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
+│        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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 %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
+│        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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 %│ 33.3%│     .│     .│ 33.3%│ 33.3%│     .│
+│        Column Total N %│ 16.7%│ 16.7%│ 16.7%│ 16.7%│ 16.7%│     .│
+│        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         │     3│     0│     0│     3│     3│     9│
+│        Total N         │     6│     6│     6│     6│     6│    36│
+╰────────────────────────┴──────┴──────┴──────┴──────┴──────┴──────╯
+
+                        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 %│   .0%│     .│   .0%│   .0%│     .│
+│        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
+│        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│        Row Valid N %   │     .│     .│     .│     .│     .│
+│        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│        Valid N         │      │      │      │      │     0│
+│        Total N         │      │      │      │      │     6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│  2.00  Count           │     1│     1│     1│     1│     4│
+│        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
+│        Column Valid N %│   .0%│     .│   .0%│   .0%│     .│
+│        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.0%│     .│
+│        Row %           │ 25.0%│ 25.0%│ 25.0%│ 25.0%│100.0%│
+│        Row Valid N %   │     .│     .│     .│     .│     .│
+│        Row Total N %   │ 16.7%│ 16.7%│ 16.7%│ 16.7%│100.0%│
+│        Valid N         │      │      │      │      │     0│
+│        Total N         │      │      │      │      │     6│
+│ ╶──────────────────────┼──────┼──────┼──────┼──────┼──────┤
+│  3.00  Count           │     1│     1│     1│     1│     4│
+│        Column %        │ 25.0%│ 25.0%│ 25.0%│ 25.0%│     .│
+│        Column Valid N %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
+│        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.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 %│ 50.0%│     .│ 50.0%│ 50.0%│     .│
+│        Column Total N %│ 20.0%│ 20.0%│ 20.0%│ 20.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         │     2│     0│     2│     2│     6│
+│        Total N         │     5│     5│     5│     5│    30│
+╰────────────────────────┴──────┴──────┴──────┴──────┴──────╯
+])
+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