dnl Features not yet tested:
dnl - Preprocessing to distinguish categorical from scale.
-dnl - Parsing (positive and negative)
-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 * 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 - 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:
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 .])
])
AT_CLEANUP
+AT_SETUP([CTABLES one string variable])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+STRING licensed(A8).
+MISSING VALUES licensed('DontKnow', 'Refused').
+RECODE qnd7a(1='Yes')(2='No')(3='DontKnow')(4='Refused') INTO licensed.
+CTABLES /TABLE licensed.
+CTABLES /TABLE licensed [COUNT, TOTALS[COUNT, VALIDN]] /CATEGORIES VARIABLES=ALL TOTAL=YES MISSING=INCLUDE.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'No'] TOTAL=YES.
+* Notice that the string matching is case-sensitive.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['Yes', 'no'] TOTAL=YES.
+CTABLES /TABLE licensed /CATEGORIES VARIABLES=licensed ['No' THRU 'yes'] TOTAL=YES.
+CTABLES
+ /PCOMPUTE ¬yes=EXPR(['No']+['DontKnow']+['Refused'])
+ /PPROPERTIES ¬yes LABEL='Not Yes' HIDESOURCECATS=YES
+ /TABLE licensed
+ /CATEGORIES VARIABLES=licensed ['Yes', ¬yes, 'No', 'DontKnow', 'Refused'].
+CTABLES
+ /PCOMPUTE ¬yes=EXPR(['DontKnow' THRU 'No'] + ['Refused'])
+ /PPROPERTIES ¬yes LABEL='Not Yes' HIDESOURCECATS=YES
+ /TABLE licensed
+ /CATEGORIES VARIABLES=licensed ['Yes', ¬yes, 'DontKnow' THRU 'No', 'Refused'].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+ Custom Tables
+╭────────────┬─────╮
+│ │Count│
+├────────────┼─────┤
+│licensed No │ 572│
+│ Yes│ 6379│
+╰────────────┴─────╯
+
+ Custom Tables
+╭─────────────────┬─────┬───────╮
+│ │Count│Valid N│
+├─────────────────┼─────┼───────┤
+│licensed DontKnow│ 4│ │
+│ No │ 572│ │
+│ Refused │ 44│ │
+│ Yes │ 6379│ │
+│ Total │ 6999│ 6951│
+╰─────────────────┴─────┴───────╯
+
+ Custom Tables
+╭──────────────┬─────╮
+│ │Count│
+├──────────────┼─────┤
+│licensed Yes │ 6379│
+│ No │ 572│
+│ Total│ 6951│
+╰──────────────┴─────╯
+
+ Custom Tables
+╭──────────────┬─────╮
+│ │Count│
+├──────────────┼─────┤
+│licensed Yes │ 6379│
+│ no │ 0│
+│ Total│ 6379│
+╰──────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed No │ 572│
+│ Refused│ 44│
+│ Yes │ 6379│
+│ Total │ 6995│
+╰────────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed Yes │ 6379│
+│ Not Yes│ 620│
+╰────────────────┴─────╯
+
+ Custom Tables
+╭────────────────┬─────╮
+│ │Count│
+├────────────────┼─────┤
+│licensed Yes │ 6379│
+│ Not Yes│ 620│
+╰────────────────┴─────╯
+])
+AT_CLEANUP
+
AT_SETUP([CTABLES one scale variable])
AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
AT_DATA([ctables.sps],
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: │
│ 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