+ /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.