improve error messages for scale variable summaries
[pspp] / tests / language / stats / ctables.at
index 171e92f83cc5a801c3c0237706a52a07c9c848ec..e9ab6d2187b71615d3277e603be8b328bdc42e25 100644 (file)
@@ -7,17 +7,11 @@ dnl - Test WEIGHT and adjustment weights.
 dnl - Summary functions:
 dnl   * Separate summary functions for totals and subtotals.
 dnl   * )CILEVEL in summary label specification
-dnl Category sorting:
-dnl   * VALUE
-dnl   * LABEL
-dnl   * ascending/descending
 dnl - CATEGORIES:
 dnl   * Date values
 dnl   * THRU (numeric ranges)
 dnl   * OTHERNM
 dnl - Date/time variables and values
-dnl - Special formats for summary functions: NEGPAREN, NEQUAL, PAREN, PCTPAREN.
-dnl - TITLES: )DATE, )TIME, )TABLE.
 dnl - Test PCOMPUTE:
 dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
 dnl   * MISSING, OTHERNM
@@ -654,6 +648,11 @@ variable must be specified.
 
 ctables.sps:23: error: CTABLES: Summaries may appear only on one axis.
 
+ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
+summary.
+   23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
+      |                                                  ^~~~~
+
 ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a
 summary.
    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
@@ -664,10 +663,10 @@ summary.
    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
       |                                 ^~~~~
 
-ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a
-summary.
+ctables.sps:23.33-23.37: note: CTABLES: This is a scale variable, so it always
+has a summary even if the syntax does not explicitly specify one.
    23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT].
-      |                                                  ^~~~~
+      |                                 ^~~~~
 ]])
 AT_CLEANUP
 
@@ -995,6 +994,88 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 ])
 AT_CLEANUP
 
+AT_SETUP([CTABLES sorting categories])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+IF (QND5A=6) QND5A=-1.
+IF (QND5A=5) QND5A=-2.
+CTABLES /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=A
+        /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=VALUE ORDER=D
+        /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=A
+        /TABLE qnd5a /CATEGORIES VARIABLES=qnd5a KEY=LABEL ORDER=D.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
+                                  Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                        │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  -2.00                   │   52│
+│background?                                     -1.00                   │   78│
+│                                                Cuban                   │   20│
+│                                                Mexican                 │  311│
+│                                                Spanish                 │   48│
+│                                                South American          │   34│
+│                                                Central American        │    0│
+│                                                Puerto Rican, OR        │    0│
+│                                                Something else          │   68│
+│                                                Multiple - cannot choose│    7│
+│                                                one                     │     │
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+                                  Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                        │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  Multiple - cannot choose│    7│
+│background?                                     one                     │     │
+│                                                Something else          │   68│
+│                                                Puerto Rican, OR        │    0│
+│                                                Central American        │    0│
+│                                                South American          │   34│
+│                                                Spanish                 │   48│
+│                                                Mexican                 │  311│
+│                                                Cuban                   │   20│
+│                                                -1.00                   │   78│
+│                                                -2.00                   │   52│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+                                  Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                        │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  Central American        │    0│
+│background?                                     Cuban                   │   20│
+│                                                Mexican                 │  311│
+│                                                Multiple - cannot choose│    7│
+│                                                one                     │     │
+│                                                Puerto Rican, OR        │    0│
+│                                                Something else          │   68│
+│                                                South American          │   34│
+│                                                Spanish                 │   48│
+│                                                -2.00                   │   52│
+│                                                -1.00                   │   78│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+
+                                  Custom Tables
+╭────────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                        │Count│
+├────────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  Spanish                 │   48│
+│background?                                     South American          │   34│
+│                                                Something else          │   68│
+│                                                Puerto Rican, OR        │    0│
+│                                                Multiple - cannot choose│    7│
+│                                                one                     │     │
+│                                                Mexican                 │  311│
+│                                                Cuban                   │   20│
+│                                                Central American        │    0│
+│                                                -1.00                   │   78│
+│                                                -2.00                   │   52│
+╰────────────────────────────────────────────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
 AT_SETUP([CTABLES simple nesting])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
@@ -2397,3 +2478,70 @@ maximumColumnWidth="192"
 minimumColumnWidth="96"
 ])
 AT_CLEANUP
+
+AT_SETUP([CTABLES special formats])
+AT_KEYWORDS([NEGPAREN NEQUAL PAREN PCTPAREN])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+COMPUTE x = qnd3 - 4.
+CTABLES /TABLE x[MINIMUM NEGPAREN8.1, MINIMUM NEQUAL8.1, MINIMUM PAREN8.1, MINIMUM PCTPAREN8.1, MAXIMUM NEGPAREN8.1, MAXIMUM NEQUAL8.1, MAXIMUM PAREN8.1, MAXIMUM PCTPAREN8.1].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+                           Custom Tables
+╭─┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────╮
+│ │Minimum│Minimum│Minimum│Minimum│Maximum│Maximum│Maximum│Maximum│
+├─┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
+│x│(3.0)  │N=-3.0 │(-3.0) │(-3.0%)│8.0    │N=8.0  │(8.0)  │(8.0%) │
+╰─┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES TITLES])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+    /VLABELS VARIABLES=qn1 DISPLAY=NONE
+    /TABLE ((qn1[c][COUNT])) BY qns3a[c] > qnd5
+    /TITLES TITLE='How often do you drive?'
+            CAPTION='Generated )TIME on )DATE'
+           CORNER=')TABLE'.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode | sed 's/..:..:../HH:MM:SS/
+s&../../..&MM/DD/YY&'], [0], [dnl
+                            How often do you drive?
+╭───────────────────────────────────┬─────────────────────────────────────────╮
+│                                   │               S3a. GENDER:              │
+│                                   ├────────────────────┬────────────────────┤
+│                                   │        Male        │       Female       │
+│                                   ├────────────────────┼────────────────────┤
+│                                   │ D5. ETHNICITY: Are │ D5. ETHNICITY: Are │
+│                                   │ you of Hispanic or │ you of Hispanic or │
+│                                   │  Latino origin or  │  Latino origin or  │
+│( ( 1. How often do you usually    │      descent?      │      descent?      │
+│drive a car or other motor         ├─────────┬──────────┼─────────┬──────────┤
+│vehicle?) ) BY S3a. GENDER: > D5.  │   Yes   │    No    │   Yes   │    No    │
+│ETHNICITY: Are you of Hispanic or  ├─────────┼──────────┼─────────┼──────────┤
+│Latino origin or descent?          │  Count  │   Count  │  Count  │   Count  │
+├───────────────────────────────────┼─────────┼──────────┼─────────┼──────────┤
+│Every day                          │      218│      2066│      166│      2175│
+│Several days a week                │       44│       391│       45│       782│
+│Once a week or less                │       16│       109│       12│       223│
+│Only certain times a year          │       15│        41│       11│        61│
+│Never                              │       39│       150│       56│       278│
+╰───────────────────────────────────┴─────────┴──────────┴─────────┴──────────╯
+Generated HH:MM:SS on MM/DD/YY
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES summary functions])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+    /TABLE region > qnd5 + qnd6_1 BY qnd7a + agegroup BY qns3a[COUNT, ROWPCT, COLPCT, SUBTABLEPCT]
+    /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], [])
+AT_CLEANUP