vlabels tests
[pspp] / tests / language / stats / ctables.at
index 0b6e769af1c4dcf87399d6a40c216376a0ec5846..26ff5f9de52866d94c6f7c3e1dbd52c64bf31b37 100644 (file)
@@ -841,6 +841,7 @@ D1. AGE: What is your age?
 AT_CLEANUP
 
 AT_SETUP([CTABLES simple stacking])
+AT_KEYWORDS([stack stacked])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -1077,6 +1078,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 AT_CLEANUP
 
 AT_SETUP([CTABLES simple nesting])
+AT_KEYWORDS([nest nested])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -1281,6 +1283,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 AT_CLEANUP
 
 AT_SETUP([CTABLES nesting and scale variables])
+AT_KEYWORDS([nest nested])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -2149,7 +2152,7 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 ])
 AT_CLEANUP
 
-AT_SETUP([CTABLES VLABELS])
+AT_SETUP([CTABLES VLABELS - variables on different axes])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
@@ -2254,6 +2257,273 @@ AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
 ])
 AT_CLEANUP
 
+AT_SETUP([CTABLES VLABELS - stacked variables])
+AT_KEYWORDS([stack stacking])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a + qns3a.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+                                 Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                       │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  Cuban                  │   20│
+│background?                                     Mexican                │  311│
+│                                                Spanish                │   48│
+│                                                South American         │   34│
+│                                                Central American       │   52│
+│                                                Puerto Rican, OR       │   78│
+│                                                Something else         │   68│
+│                                                Multiple - cannot      │    7│
+│                                                choose one             │     │
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│QNS3A                                           Male                   │ 3132│
+│                                                Female                 │ 3867│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+                  Custom Tables
+╭─────────────────────────────────────────┬─────╮
+│                                         │Count│
+├─────────────────────────────────────────┼─────┤
+│QND5A        Cuban                       │   20│
+│             Mexican                     │  311│
+│             Spanish                     │   48│
+│             South American              │   34│
+│             Central American            │   52│
+│             Puerto Rican, OR            │   78│
+│             Something else              │   68│
+│             Multiple - cannot choose one│    7│
+├─────────────────────────────────────────┼─────┤
+│S3a. GENDER: Male                        │ 3132│
+│             Female                      │ 3867│
+╰─────────────────────────────────────────┴─────╯
+
+                                 Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                       │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary ethnic  Cuban                  │   20│
+│background?                                     Mexican                │  311│
+│                                                Spanish                │   48│
+│                                                South American         │   34│
+│                                                Central American       │   52│
+│                                                Puerto Rican, OR       │   78│
+│                                                Something else         │   68│
+│                                                Multiple - cannot      │    7│
+│                                                choose one             │     │
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│Male                                                                   │ 3132│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│Female                                                                 │ 3867│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+            Custom Tables
+╭─────────────────────────────┬─────╮
+│                             │Count│
+├─────────────────────────────┼─────┤
+│Cuban                        │   20│
+├─────────────────────────────┼─────┤
+│Mexican                      │  311│
+├─────────────────────────────┼─────┤
+│Spanish                      │   48│
+├─────────────────────────────┼─────┤
+│South American               │   34│
+├─────────────────────────────┼─────┤
+│Central American             │   52│
+├─────────────────────────────┼─────┤
+│Puerto Rican, OR             │   78│
+├─────────────────────────────┼─────┤
+│Something else               │   68│
+├─────────────────────────────┼─────┤
+│Multiple - cannot choose one │    7│
+├─────────────────────────────┼─────┤
+│S3a. GENDER:     Male        │ 3132│
+│                 Female      │ 3867│
+╰─────────────────────────────┴─────╯
+
+            Custom Tables
+╭────────────────────────────┬─────╮
+│                            │Count│
+├────────────────────────────┼─────┤
+│Cuban                       │   20│
+│Mexican                     │  311│
+│Spanish                     │   48│
+│South American              │   34│
+│Central American            │   52│
+│Puerto Rican, OR            │   78│
+│Something else              │   68│
+│Multiple - cannot choose one│    7│
+│Male                        │ 3132│
+│Female                      │ 3867│
+╰────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
+AT_SETUP([CTABLES VLABELS - nested variables])
+AT_KEYWORDS([nest nesting])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NAME /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NAME /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qns3a DISPLAY=NONE /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
+CTABLES /VLABELS VARIABLES=qns3a qnd5a DISPLAY=NONE /TABLE qnd5a > qns3a.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+                                 Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                       │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your       Cuban                QNS3A Male  │   13│
+│primary ethnic background?                                       Female│    7│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Mexican              QNS3A Male  │  175│
+│                                                                 Female│  136│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Spanish              QNS3A Male  │   20│
+│                                                                 Female│   28│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      South American       QNS3A Male  │   21│
+│                                                                 Female│   13│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Central American     QNS3A Male  │   27│
+│                                                                 Female│   25│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Puerto Rican, OR     QNS3A Male  │   37│
+│                                                                 Female│   41│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Something else       QNS3A Male  │   35│
+│                                                                 Female│   33│
+│                                     ╶─────────────────────────────────┼─────┤
+│                                      Multiple - cannot    QNS3A Male  │    2│
+│                                      choose one                 Female│    5│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+                         Custom Tables
+╭──────────────────────────────────────────────────────┬─────╮
+│                                                      │Count│
+├──────────────────────────────────────────────────────┼─────┤
+│QND5A Cuban                        S3a. GENDER: Male  │   13│
+│                                                Female│    7│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Mexican                      S3a. GENDER: Male  │  175│
+│                                                Female│  136│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Spanish                      S3a. GENDER: Male  │   20│
+│                                                Female│   28│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      South American               S3a. GENDER: Male  │   21│
+│                                                Female│   13│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Central American             S3a. GENDER: Male  │   27│
+│                                                Female│   25│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Puerto Rican, OR             S3a. GENDER: Male  │   37│
+│                                                Female│   41│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Something else               S3a. GENDER: Male  │   35│
+│                                                Female│   33│
+│     ╶────────────────────────────────────────────────┼─────┤
+│      Multiple - cannot choose one S3a. GENDER: Male  │    2│
+│                                                Female│    5│
+╰──────────────────────────────────────────────────────┴─────╯
+
+                                 Custom Tables
+╭───────────────────────────────────────────────────────────────────────┬─────╮
+│                                                                       │Count│
+├───────────────────────────────────────────────────────────────────────┼─────┤
+│D5a. What would you say is your primary    Cuban                 Male  │   13│
+│ethnic background?                                               Female│    7│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Mexican               Male  │  175│
+│                                                                 Female│  136│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Spanish               Male  │   20│
+│                                                                 Female│   28│
+│                                          ╶────────────────────────────┼─────┤
+│                                           South American        Male  │   21│
+│                                                                 Female│   13│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Central American      Male  │   27│
+│                                                                 Female│   25│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Puerto Rican, OR      Male  │   37│
+│                                                                 Female│   41│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Something else        Male  │   35│
+│                                                                 Female│   33│
+│                                          ╶────────────────────────────┼─────┤
+│                                           Multiple - cannot     Male  │    2│
+│                                           choose one            Female│    5│
+╰───────────────────────────────────────────────────────────────────────┴─────╯
+
+                      Custom Tables
+╭────────────────────────────────────────────────┬─────╮
+│                                                │Count│
+├────────────────────────────────────────────────┼─────┤
+│Cuban                        S3a. GENDER: Male  │   13│
+│                                          Female│    7│
+├────────────────────────────────────────────────┼─────┤
+│Mexican                      S3a. GENDER: Male  │  175│
+│                                          Female│  136│
+├────────────────────────────────────────────────┼─────┤
+│Spanish                      S3a. GENDER: Male  │   20│
+│                                          Female│   28│
+├────────────────────────────────────────────────┼─────┤
+│South American               S3a. GENDER: Male  │   21│
+│                                          Female│   13│
+├────────────────────────────────────────────────┼─────┤
+│Central American             S3a. GENDER: Male  │   27│
+│                                          Female│   25│
+├────────────────────────────────────────────────┼─────┤
+│Puerto Rican, OR             S3a. GENDER: Male  │   37│
+│                                          Female│   41│
+├────────────────────────────────────────────────┼─────┤
+│Something else               S3a. GENDER: Male  │   35│
+│                                          Female│   33│
+├────────────────────────────────────────────────┼─────┤
+│Multiple - cannot choose one S3a. GENDER: Male  │    2│
+│                                          Female│    5│
+╰────────────────────────────────────────────────┴─────╯
+
+               Custom Tables
+╭───────────────────────────────────┬─────╮
+│                                   │Count│
+├───────────────────────────────────┼─────┤
+│Cuban                        Male  │   13│
+│                             Female│    7│
+├───────────────────────────────────┼─────┤
+│Mexican                      Male  │  175│
+│                             Female│  136│
+├───────────────────────────────────┼─────┤
+│Spanish                      Male  │   20│
+│                             Female│   28│
+├───────────────────────────────────┼─────┤
+│South American               Male  │   21│
+│                             Female│   13│
+├───────────────────────────────────┼─────┤
+│Central American             Male  │   27│
+│                             Female│   25│
+├───────────────────────────────────┼─────┤
+│Puerto Rican, OR             Male  │   37│
+│                             Female│   41│
+├───────────────────────────────────┼─────┤
+│Something else               Male  │   35│
+│                             Female│   33│
+├───────────────────────────────────┼─────┤
+│Multiple - cannot choose one Male  │    2│
+│                             Female│    5│
+╰───────────────────────────────────┴─────╯
+])
+AT_CLEANUP
+
 AT_SETUP([CTABLES FORMAT EMPTY])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
@@ -2774,12 +3044,199 @@ AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.s
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
 SET TVAR=NAME.
+
+* Use SPLIT FILE with FREQUENCIES to generate output equivalent to
+  CTABLES later, to make the results easier to verify.
 SPLIT FILE BY REGION.
-FREQUENCIES qn19a /STATISTICS=ALL /FORMAT NOTABLE.
+FREQUENCIES
+    qn19a
+    /STATISTICS=MEAN SEMEAN MEDIAN MODE STDDEV VARIANCE RANGE MINIMUM MAXIMUM SUM
+    /FORMAT NOTABLE /MISSING=INCLUDE.
 SPLIT FILE OFF.
+
 CTABLES
     /VLABELS VARIABLE=qn19a DISPLAY=NAME /*XXX NONE yields an assertion failure
-    /TABLE region BY qn19a[COUNT, MAXIMUM, MEAN, MINIMUM, MISSING, MODE]
+    /TABLE region BY qn19a[VALIDN, MISSING, MEAN, SEMEAN, MEDIAN, MODE, STDDEV, VARIANCE, RANGE, MINIMUM, MAXIMUM, SUM, COUNT, TOTALN, COLPCT.SUM]
+    /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
+    /SLABELS POSITION=ROW.
+]])
+AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
+         Statistics
+╭────────────────┬────────╮
+│REGION          │  QN19A │
+├────────────────┼────────┤
+│NE     N Valid  │     936│
+│         Missing│     473│
+│      ╶─────────┼────────┤
+│       Mean     │   19.33│
+│      ╶─────────┼────────┤
+│       S.E. Mean│     .14│
+│      ╶─────────┼────────┤
+│       Median   │   18.00│
+│      ╶─────────┼────────┤
+│       Mode     │   18.00│
+│      ╶─────────┼────────┤
+│       Std Dev  │    4.41│
+│      ╶─────────┼────────┤
+│       Variance │   19.41│
+│      ╶─────────┼────────┤
+│       Range    │   59.00│
+│      ╶─────────┼────────┤
+│       Minimum  │     .00│
+│      ╶─────────┼────────┤
+│       Maximum  │   59.00│
+│      ╶─────────┼────────┤
+│       Sum      │18092.00│
+├────────────────┼────────┤
+│MW     N Valid  │    1019│
+│         Missing│     635│
+│      ╶─────────┼────────┤
+│       Mean     │   19.83│
+│      ╶─────────┼────────┤
+│       S.E. Mean│     .16│
+│      ╶─────────┼────────┤
+│       Median   │   19.00│
+│      ╶─────────┼────────┤
+│       Mode     │   18.00│
+│      ╶─────────┼────────┤
+│       Std Dev  │    5.15│
+│      ╶─────────┼────────┤
+│       Variance │   26.47│
+│      ╶─────────┼────────┤
+│       Range    │   71.00│
+│      ╶─────────┼────────┤
+│       Minimum  │    4.00│
+│      ╶─────────┼────────┤
+│       Maximum  │   75.00│
+│      ╶─────────┼────────┤
+│       Sum      │20206.00│
+├────────────────┼────────┤
+│S      N Valid  │    1276│
+│         Missing│    1114│
+│      ╶─────────┼────────┤
+│       Mean     │   20.29│
+│      ╶─────────┼────────┤
+│       S.E. Mean│     .18│
+│      ╶─────────┼────────┤
+│       Median   │   19.00│
+│      ╶─────────┼────────┤
+│       Mode     │   18.00│
+│      ╶─────────┼────────┤
+│       Std Dev  │    6.44│
+│      ╶─────────┼────────┤
+│       Variance │   41.43│
+│      ╶─────────┼────────┤
+│       Range    │   75.00│
+│      ╶─────────┼────────┤
+│       Minimum  │    4.00│
+│      ╶─────────┼────────┤
+│       Maximum  │   79.00│
+│      ╶─────────┼────────┤
+│       Sum      │25886.00│
+├────────────────┼────────┤
+│W      N Valid  │     950│
+│         Missing│     596│
+│      ╶─────────┼────────┤
+│       Mean     │   19.87│
+│      ╶─────────┼────────┤
+│       S.E. Mean│     .17│
+│      ╶─────────┼────────┤
+│       Median   │   19.00│
+│      ╶─────────┼────────┤
+│       Mode     │   18.00│
+│      ╶─────────┼────────┤
+│       Std Dev  │    5.25│
+│      ╶─────────┼────────┤
+│       Variance │   27.59│
+│      ╶─────────┼────────┤
+│       Range    │   61.00│
+│      ╶─────────┼────────┤
+│       Minimum  │    4.00│
+│      ╶─────────┼────────┤
+│       Maximum  │   65.00│
+│      ╶─────────┼────────┤
+│       Sum      │18877.00│
+╰────────────────┴────────╯
+
+             Custom Tables
+╭───────────────────────────┬────────╮
+│                           │  QN19A │
+├───────────────────────────┼────────┤
+│REGION NE Valid N          │     936│
+│          Missing          │  473.00│
+│          Mean             │   19.33│
+│          Std Error of Mean│     .14│
+│          Median           │   18.00│
+│          Mode             │   18.00│
+│          Std Deviation    │    4.41│
+│          Variance         │   19.41│
+│          Range            │   59.00│
+│          Minimum          │     .00│
+│          Maximum          │   59.00│
+│          Sum              │18092.00│
+│          Count            │    1409│
+│          Total N          │    1409│
+│          Column Sum %     │   21.8%│
+│      ╶────────────────────┼────────┤
+│       MW Valid N          │    1019│
+│          Missing          │  635.00│
+│          Mean             │   19.83│
+│          Std Error of Mean│     .16│
+│          Median           │   19.00│
+│          Mode             │   18.00│
+│          Std Deviation    │    5.15│
+│          Variance         │   26.47│
+│          Range            │   71.00│
+│          Minimum          │    4.00│
+│          Maximum          │   75.00│
+│          Sum              │20206.00│
+│          Count            │    1654│
+│          Total N          │    1654│
+│          Column Sum %     │   24.3%│
+│      ╶────────────────────┼────────┤
+│       S  Valid N          │    1276│
+│          Missing          │ 1114.00│
+│          Mean             │   20.29│
+│          Std Error of Mean│     .18│
+│          Median           │   19.00│
+│          Mode             │   18.00│
+│          Std Deviation    │    6.44│
+│          Variance         │   41.43│
+│          Range            │   75.00│
+│          Minimum          │    4.00│
+│          Maximum          │   79.00│
+│          Sum              │25886.00│
+│          Count            │    2390│
+│          Total N          │    2390│
+│          Column Sum %     │   31.2%│
+│      ╶────────────────────┼────────┤
+│       W  Valid N          │     950│
+│          Missing          │  596.00│
+│          Mean             │   19.87│
+│          Std Error of Mean│     .17│
+│          Median           │   19.00│
+│          Mode             │   18.00│
+│          Std Deviation    │    5.25│
+│          Variance         │   27.59│
+│          Range            │   61.00│
+│          Minimum          │    4.00│
+│          Maximum          │   65.00│
+│          Sum              │18877.00│
+│          Count            │    1546│
+│          Total N          │    1546│
+│          Column Sum %     │   22.7%│
+╰───────────────────────────┴────────╯
+])
+AT_CLEANUP
+
+
+AT_SETUP([CTABLES scale summary functions - assertion failure])
+AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
+AT_DATA([ctables.sps],
+[[GET 'nhtsa.sav'.
+CTABLES
+    /VLABELS VARIABLE=qn19a DISPLAY=NONE
+    /TABLE region BY qn19a
     /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
     /SLABELS POSITION=ROW.
 ]])