sort orders
[pspp] / tests / language / stats / ctables.at
index 0453eeb1e8ea11c7f3fae648caaadb5d4f0664cf..4b520cc0cddd540a19ebeb8bfbb4660970772469 100644 (file)
@@ -7,19 +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 - FORMAT:
-dnl   * MINCOLWIDTH, MAXCOLWIDTH, UNITS.
-dnl - HIDESMALLCOUNTS.
 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]).
@@ -998,6 +990,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],
@@ -2176,8 +2250,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
 ])
 AT_CLEANUP
 
-AT_SETUP([CTABLES FORMAT=EMPTY])
-AT_KEYWORDS([FORMAT EMPTY])
+AT_SETUP([CTABLES FORMAT EMPTY])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -2254,8 +2327,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
 ])
 AT_CLEANUP
 
-AT_SETUP([CTABLES FORMAT=MISSING])
-AT_KEYWORDS([FORMAT MISSING])
+AT_SETUP([CTABLES FORMAT MISSING])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -2284,4 +2356,139 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
 │                             one             │               │               │
 ╰─────────────────────────────────────────────┴───────────────┴───────────────╯
 ])
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+AT_SETUP([CTABLES HIDESMALLCOUNTS])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /TABLE qn38[c][COUNT, COLPCT].
+CTABLES /HIDESMALLCOUNTS /TABLE qn38[c][COUNT, COLPCT].
+CTABLES /HIDESMALLCOUNTS COUNT=10 /TABLE qn38[c][COUNT, COLPCT].
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+                                 Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│                                                              │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that         Less than one│    7│     .5%│
+│occasion?                                        1            │  491│   34.9%│
+│                                                 2            │  462│   32.9%│
+│                                                 3            │  229│   16.3%│
+│                                                 4            │   82│    5.8%│
+│                                                 5            │   56│    4.0%│
+│                                                 6            │   32│    2.3%│
+│                                                 7            │    9│     .6%│
+│                                                 8            │    8│     .6%│
+│                                                 9            │    4│     .3%│
+│                                                 10           │    6│     .4%│
+│                                                 11           │    2│     .1%│
+│                                                 12           │    5│     .4%│
+│                                                 14           │    1│     .1%│
+│                                                 15           │    1│     .1%│
+│                                                 18           │    1│     .1%│
+│                                                 20           │    4│     .3%│
+│                                                 25           │    1│     .1%│
+│                                                 30           │    3│     .2%│
+│                                                 60           │    1│     .1%│
+│                                                 99+          │    0│     .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+
+                                 Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│                                                              │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that         Less than one│    7│     .5%│
+│occasion?                                        1            │  491│   34.9%│
+│                                                 2            │  462│   32.9%│
+│                                                 3            │  229│   16.3%│
+│                                                 4            │   82│    5.8%│
+│                                                 5            │   56│    4.0%│
+│                                                 6            │   32│    2.3%│
+│                                                 7            │    9│     .6%│
+│                                                 8            │    8│     .6%│
+│                                                 9            │<5   │     .3%│
+│                                                 10           │    6│     .4%│
+│                                                 11           │<5   │     .1%│
+│                                                 12           │    5│     .4%│
+│                                                 14           │<5   │     .1%│
+│                                                 15           │<5   │     .1%│
+│                                                 18           │<5   │     .1%│
+│                                                 20           │<5   │     .3%│
+│                                                 25           │<5   │     .1%│
+│                                                 30           │<5   │     .2%│
+│                                                 60           │<5   │     .1%│
+│                                                 99+          │<5   │     .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+
+                                 Custom Tables
+╭──────────────────────────────────────────────────────────────┬─────┬────────╮
+│                                                              │Count│Column %│
+├──────────────────────────────────────────────────────────────┼─────┼────────┤
+│38. How many drinks did you have on that         Less than one│<10  │     .5%│
+│occasion?                                        1            │  491│   34.9%│
+│                                                 2            │  462│   32.9%│
+│                                                 3            │  229│   16.3%│
+│                                                 4            │   82│    5.8%│
+│                                                 5            │   56│    4.0%│
+│                                                 6            │   32│    2.3%│
+│                                                 7            │<10  │     .6%│
+│                                                 8            │<10  │     .6%│
+│                                                 9            │<10  │     .3%│
+│                                                 10           │<10  │     .4%│
+│                                                 11           │<10  │     .1%│
+│                                                 12           │<10  │     .4%│
+│                                                 14           │<10  │     .1%│
+│                                                 15           │<10  │     .1%│
+│                                                 18           │<10  │     .1%│
+│                                                 20           │<10  │     .3%│
+│                                                 25           │<10  │     .1%│
+│                                                 30           │<10  │     .2%│
+│                                                 60           │<10  │     .1%│
+│                                                 99+          │<10  │     .0%│
+╰──────────────────────────────────────────────────────────────┴─────┴────────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES FORMAT MINCOLWIDTH MAXCOLWIDTH])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /FORMAT MINCOLWIDTH=1 MAXCOLWIDTH=2 UNITS=INCHES /TABLE BY qns3a.
+]])
+AT_CHECK([pspp ctables.sps -o - -O box=unicode -o pspp.spv], [0], [dnl
+ Custom Tables
+╭────────────╮
+│S3a. GENDER:│
+├─────┬──────┤
+│ Male│Female│
+├─────┼──────┤
+│Count│ Count│
+├─────┼──────┤
+│ 3132│  3867│
+╰─────┴──────╯
+])
+AT_CHECK([pspp-output get-table-look pspp.spv pspp.stt])
+AT_CHECK([sed 's/ /\n/g' pspp.stt | grep ColumnWidth | sort], [0], [dnl
+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