X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Fctables.at;h=4bdd1744ff72901981e824a10f45499c12de1396;hb=69b31e124aff05df3492e6e6412c03c64e4e9d12;hp=388c61f1c1cad3846050b679f7be6ae324f7a428;hpb=32d612555853c41f5fd89cc225a2d98bfa240718;p=pspp diff --git a/tests/language/stats/ctables.at b/tests/language/stats/ctables.at index 388c61f1c1..4bdd1744ff 100644 --- a/tests/language/stats/ctables.at +++ b/tests/language/stats/ctables.at @@ -7,19 +7,9 @@ dnl - Test WEIGHT and adjustment weights. dnl - Summary functions: dnl * Separate summary functions for totals and subtotals. dnl * )CILEVEL in summary label specification -dnl - CATEGORIES: -dnl * Date values -dnl * THRU (numeric ranges) -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. dnl * areaPCT.SUM and UareaPCT.SUM functions. -dnl - SPLIT FILE with SEPARATE splits dnl - Definition of columns/rows when labels are rotated from one axis to another. dnl dnl Not for v1: @@ -1609,6 +1599,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl 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'. @@ -1679,6 +1670,199 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=140], [0], [dnl ]) 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. +]]) +AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl + Custom Tables +╭──────────────────┬───────────────────────────────────────────────────────────────────────────────────╮ +│ │ Gender │ +│ ├─────────────────────────────────────────┬─────────────────────────────────────────┤ +│ │ Male │ Female │ +│ ├─────────────────────────────────────────┼─────────────────────────────────────────┤ +│ │ Favorite day of the week │ Favorite day of the week │ +│ ├───┬───┬───┬───┬───┬───┬───┬───────┬─────┼───┬───┬───┬───┬───┬───┬───┬───────┬─────┤ +│ │SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│SUN│MON│TUE│WED│THU│FRI│SAT│Weekend│Total│ +├──────────────────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┼───┼───┼───┼───┼───┼───┼───┼───────┼─────┤ +│Favorite month JAN│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│ 9│ 6│ 4│ 2│ 7│ 5│ 3│ 12│ 36│ +│ FEB│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ +│ MAR│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ +│ Q1 │ 32│ 17│ 18│ 12│ 13│ 14│ 15│ │ │ 29│ 12│ 13│ 14│ 15│ 16│ 17│ │ │ +│ APR│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│ +│ MAY│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│ +│ JUN│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│ +│ Q2 │ 24│ 13│ 14│ 15│ 16│ 17│ 18│ .│ │ 28│ 15│ 16│ 17│ 18│ 12│ 13│ .│ │ +│ JUL│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│ +│ AUG│ 10│ 3│ 8│ 6│ 4│ 2│ 7│ 17│ 40│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│ +│ SEP│ 6│ 8│ 6│ 4│ 2│ 7│ 5│ 11│ 38│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ +│ Q3 │ 54│ 29│ 31│ 33│ 28│ 30│ 32│ │ │ 62│ 33│ 28│ 30│ 32│ 27│ 29│ │ │ +│ OCT│ 16│ 6│ 4│ 2│ 7│ 5│ 3│ 19│ 43│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ +│ NOV│ 12│ 4│ 2│ 7│ 5│ 3│ 8│ 20│ 41│ 4│ 7│ 5│ 3│ 8│ 6│ 4│ 8│ 37│ +│ DEC│ 8│ 2│ 7│ 5│ 3│ 8│ 6│ 14│ 39│ 14│ 5│ 3│ 8│ 6│ 4│ 2│ 16│ 42│ +│ Q4 │ 36│ 12│ 13│ 14│ 15│ 16│ 17│ │ │ 26│ 14│ 15│ 16│ 17│ 18│ 12│ │ │ +╰──────────────────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────┴───┴───┴───┴───┴───┴───┴───┴───────┴─────╯ +]) +AT_CLEANUP + AT_SETUP([CTABLES CLABELS]) AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) AT_DATA([ctables.sps], @@ -1689,7 +1873,6 @@ CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE. 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 ╭───────────────────────┬────────────╮ @@ -3071,7 +3254,6 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl ]) AT_CLEANUP - AT_SETUP([CTABLES scale summary functions]) AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) AT_DATA([ctables.sps], @@ -3351,3 +3533,118 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl ]) AT_CLEANUP +AT_SETUP([CTABLES with SPLIT FILE]) +AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) +AT_DATA([ctables.sps], +[[GET 'nhtsa.sav'. + +SORT CASES BY qns3a. + +CTABLES /TABLE qn105ba. + +* Layered split has no effect on output. +SPLIT FILE BY qns3a. +CTABLES /TABLE qn105ba. + +* Add column variable qns3a to compare against separate splits. +CTABLES /TABLE qn105ba BY qns3a. + +* Separate splits are truly output separately. +SPLIT FILE SEPARATE BY qns3a. +CTABLES /TABLE qn105ba. +]]) +AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl + Custom Tables +╭────────────────────────────────────────────────────────────────────────┬─────╮ +│ │Count│ +├────────────────────────────────────────────────────────────────────────┼─────┤ +│105b. How likely is it that drivers who have had too much Almost │ 700│ +│to drink to drive safely will A. Get stopped by the police? certain │ │ +│ Very likely │ 1502│ +│ Somewhat │ 2763│ +│ likely │ │ +│ Somewhat │ 1307│ +│ unlikely │ │ +│ Very │ 609│ +│ unlikely │ │ +╰────────────────────────────────────────────────────────────────────────┴─────╯ + + Custom Tables +╭────────────────────────────────────────────────────────────────────────┬─────╮ +│ │Count│ +├────────────────────────────────────────────────────────────────────────┼─────┤ +│105b. How likely is it that drivers who have had too much Almost │ 700│ +│to drink to drive safely will A. Get stopped by the police? certain │ │ +│ Very likely │ 1502│ +│ Somewhat │ 2763│ +│ likely │ │ +│ Somewhat │ 1307│ +│ unlikely │ │ +│ Very │ 609│ +│ unlikely │ │ +╰────────────────────────────────────────────────────────────────────────┴─────╯ + + Custom Tables +╭─────────────────────────────────────────────────────────────────┬────────────╮ +│ │S3a. GENDER:│ +│ ├─────┬──────┤ +│ │ Male│Female│ +│ ├─────┼──────┤ +│ │Count│ Count│ +├─────────────────────────────────────────────────────────────────┼─────┼──────┤ +│105b. How likely is it that drivers who have had too Almost │ 297│ 403│ +│much to drink to drive safely will A. Get stopped by certain │ │ │ +│the police? Very likely │ 660│ 842│ +│ Somewhat │ 1174│ 1589│ +│ likely │ │ │ +│ Somewhat │ 640│ 667│ +│ unlikely │ │ │ +│ Very │ 311│ 298│ +│ unlikely │ │ │ +╰─────────────────────────────────────────────────────────────────┴─────┴──────╯ + + Split Values +╭────────────┬─────╮ +│Variable │Value│ +├────────────┼─────┤ +│S3a. GENDER:│Male │ +╰────────────┴─────╯ + + Custom Tables +╭────────────────────────────────────────────────────────────────────────┬─────╮ +│ │Count│ +├────────────────────────────────────────────────────────────────────────┼─────┤ +│105b. How likely is it that drivers who have had too much Almost │ 297│ +│to drink to drive safely will A. Get stopped by the police? certain │ │ +│ Very likely │ 660│ +│ Somewhat │ 1174│ +│ likely │ │ +│ Somewhat │ 640│ +│ unlikely │ │ +│ Very │ 311│ +│ unlikely │ │ +╰────────────────────────────────────────────────────────────────────────┴─────╯ + + Split Values +╭────────────┬──────╮ +│Variable │ Value│ +├────────────┼──────┤ +│S3a. GENDER:│Female│ +╰────────────┴──────╯ + + Custom Tables +╭────────────────────────────────────────────────────────────────────────┬─────╮ +│ │Count│ +├────────────────────────────────────────────────────────────────────────┼─────┤ +│105b. How likely is it that drivers who have had too much Almost │ 403│ +│to drink to drive safely will A. Get stopped by the police? certain │ │ +│ Very likely │ 842│ +│ Somewhat │ 1589│ +│ likely │ │ +│ Somewhat │ 667│ +│ unlikely │ │ +│ Very │ 298│ +│ unlikely │ │ +╰────────────────────────────────────────────────────────────────────────┴─────╯ +]) +AT_CLEANUP