test )LABEL[n]
[pspp] / tests / language / stats / ctables.at
index 726da3d723c4e3fc50060a329306ead40e143f6c..432da3deb4df29a3fbce98c8c85423edf35cfe63 100644 (file)
@@ -17,8 +17,6 @@ dnl   * PCOMPUTE for more than one kind of summary (e.g. [COUNT, ROWPCT]).
 dnl   * MISSING, OTHERNM
 dnl   * multi-dimensional (multiple CCT_POSTCOMPUTE in one cell)
 dnl   * dates
-dnl - PPROPERTIES:
-dnl   * )LABEL[N].
 dnl - Summary functions:
 dnl   * U-prefix for unweighted summaries.
 dnl   * areaPCT.SUM and UareaPCT.SUM functions.
@@ -841,6 +839,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 +1076,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 +1281,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'.
@@ -1616,7 +1617,7 @@ CTABLES
     /PCOMPUTE &x=EXPR([3] + [4])
     /PCOMPUTE &y=EXPR([4] + [5])
     /PPROPERTIES &x LABEL='3+4' HIDESOURCECATS=YES FORMAT=COUNT F8.2
-    /PPROPERTIES &y LABEL='4+5'
+    /PPROPERTIES &y LABEL=')LABEL[5]+)LABEL[6]'
     /TABLE=qn105ba BY qns1
     /CATEGORIES VARIABLES=qns1 [1, 2, SUBTOTAL, 3, 4, 5, &x, &y, SUBTOTAL]
 ]])
@@ -2149,7 +2150,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 +2255,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],
@@ -2960,16 +3228,91 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [dnl
 AT_CLEANUP
 
 
-AT_SETUP([CTABLES scale summary functions - assertion failure])
+AT_SETUP([CTABLES hidden scale VLABELS])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
+CTABLES
+    /TABLE region BY qn19a + qn35
+    /SLABELS POSITION=ROW.
 CTABLES
     /VLABELS VARIABLE=qn19a DISPLAY=NONE
-    /TABLE region BY qn19a
-    /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
+    /TABLE region BY qn19a + qn35
+    /SLABELS POSITION=ROW.
+CTABLES
+    /VLABELS VARIABLE=qn35 DISPLAY=NONE
+    /TABLE region BY qn19a + qn35
+    /SLABELS POSITION=ROW.
+
+* This one in particular caused a crash because no categories were
+  created on the column axis, so passing in 0 for the index was still
+  too big for that number of categories.  It was fixed by creating a
+  name-only category for each variable despite the "NONE" request,
+  then hiding the entire dimension's labels if all its labels were
+  set to "NONE".
+CTABLES
+    /VLABELS VARIABLE=qn19a qn35 DISPLAY=NONE
+    /TABLE region BY qn19a + qn35
     /SLABELS POSITION=ROW.
 ]])
-AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [0], [])
+AT_CHECK([pspp ctables.sps -O box=unicode], [0], [dnl
+                                 Custom Tables
+╭──────────────┬────────────────────────────┬─────────────────────────────────╮
+│              │ 19a. About how old were you│ 35. In the past thirty days, how│
+│              │   when you first starting  │   many times have you driven a  │
+│              │    drinking alcohol, not   │  motor vehicle WITHIN TWO HOURS │
+│              │  counting small tastes or  │     AFTER drinking alcoholic    │
+│              │      sips of alcohol.      │            beverages?           │
+├──────────────┼────────────────────────────┼─────────────────────────────────┤
+│Region NE Mean│                       19.33│                                2│
+│      ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│       MW Mean│                       19.83│                                2│
+│      ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│       S  Mean│                       20.29│                                2│
+│      ╶───────┼────────────────────────────┼─────────────────────────────────┤
+│       W  Mean│                       19.87│                                2│
+╰──────────────┴────────────────────────────┴─────────────────────────────────╯
+
+                                 Custom Tables
+╭──────────────┬─────┬────────────────────────────────────────────────────────╮
+│              │     │  35. In the past thirty days, how many times have you  │
+│              │     │ driven a motor vehicle WITHIN TWO HOURS AFTER drinking │
+│              │QN19A│                  alcoholic beverages?                  │
+├──────────────┼─────┼────────────────────────────────────────────────────────┤
+│Region NE Mean│19.33│                                                       2│
+│      ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│       MW Mean│19.83│                                                       2│
+│      ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│       S  Mean│20.29│                                                       2│
+│      ╶───────┼─────┼────────────────────────────────────────────────────────┤
+│       W  Mean│19.87│                                                       2│
+╰──────────────┴─────┴────────────────────────────────────────────────────────╯
+
+                                 Custom Tables
+╭──────────────┬─────────────────────────────────────────────────────────┬────╮
+│              │   19a. About how old were you when you first starting   │    │
+│              │  drinking alcohol, not counting small tastes or sips of │    │
+│              │                         alcohol.                        │qn35│
+├──────────────┼─────────────────────────────────────────────────────────┼────┤
+│Region NE Mean│                                                    19.33│   2│
+│      ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│       MW Mean│                                                    19.83│   2│
+│      ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│       S  Mean│                                                    20.29│   2│
+│      ╶───────┼─────────────────────────────────────────────────────────┼────┤
+│       W  Mean│                                                    19.87│   2│
+╰──────────────┴─────────────────────────────────────────────────────────┴────╯
+
+      Custom Tables
+╭──────────────┬───────╮
+│Region NE Mean│19.33 2│
+│      ╶───────┼───────┤
+│       MW Mean│19.83 2│
+│      ╶───────┼───────┤
+│       S  Mean│20.29 2│
+│      ╶───────┼───────┤
+│       W  Mean│19.87 2│
+╰──────────────┴───────╯
+])
 AT_CLEANUP