dnl * OTHERNM
dnl - Date/time variables and values
dnl - Test PCOMPUTE:
-dnl * MISSING, OTHERNM
-dnl * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
dnl * dates
dnl - Summary functions:
dnl * U-prefix for unweighted summaries.
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'.
])
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 CLABELS])
AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
AT_DATA([ctables.sps],
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
╭───────────────────────┬────────────╮