+ for (int l = 0; l < mt->n_layers; ++l)
+ {
+ const struct layer *layer = mt->layers[l];
+ const struct variable *ctrl_var = layer->factor_vars[lindexes[l]];
+ if (l > 0)
+ ds_put_cstr (c_des, " * ");
+ ds_put_cstr (c_des, var_get_name (ctrl_var));
+ }
+}
+
+static void
+populate_case_processing_summary (struct pivot_category *pc,
+ const struct mtable *mt,
+ const int *lindexes)
+{
+ struct string ds;
+ ds_init_empty (&ds);
+ int l = 0;
+ for (l = 0; l < mt->n_layers; ++l)
+ {
+ const struct layer *layer = mt->layers[l];
+ const struct variable *ctrl_var = layer->factor_vars[lindexes[l]];
+ if (l > 0)
+ ds_put_cstr (&ds, " * ");
+ ds_put_cstr (&ds, var_get_name (ctrl_var));
+ }
+ for (int dv = 0; dv < mt->n_dep_vars; ++dv)
+ {
+ struct string dss;
+ ds_init_empty (&dss);
+ ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv]));
+ if (mt->n_layers > 0)
+ {
+ ds_put_cstr (&dss, " * ");
+ ds_put_substring (&dss, ds.ss);
+ }
+ pivot_category_create_leaf (pc,
+ pivot_value_new_text (ds_cstr (&dss)));
+ ds_destroy (&dss);
+ }
+
+ ds_destroy (&ds);
+}
+
+/* Create the "Case Processing Summary" table. */
+static void
+means_case_processing_summary (const struct mtable *mt)
+{
+ struct pivot_table *pt = pivot_table_create (N_("Case Processing Summary"));
+
+ struct pivot_dimension *dim_cases =
+ pivot_dimension_create (pt, PIVOT_AXIS_COLUMN, N_("Cases"));
+ dim_cases->root->show_label = true;
+
+ struct pivot_category *cats[3];
+ cats[0] = pivot_category_create_group (dim_cases->root,
+ N_("Included"), NULL);
+ cats[1] = pivot_category_create_group (dim_cases->root,
+ N_("Excluded"), NULL);
+ cats[2] = pivot_category_create_group (dim_cases->root,
+ N_("Total"), NULL);
+ for (int i = 0; i < 3; ++i)
+ {
+ pivot_category_create_leaf_rc (cats[i],
+ pivot_value_new_text (N_("N")),
+ PIVOT_RC_COUNT);
+ pivot_category_create_leaf_rc (cats[i],
+ pivot_value_new_text (N_("Percent")),
+ PIVOT_RC_PERCENT);
+ }
+
+ struct pivot_dimension *rows =
+ pivot_dimension_create (pt, PIVOT_AXIS_ROW, N_("Variables"));
+
+ for (int cmb = 0; cmb < mt->n_combinations; ++cmb)
+ {
+ const struct workspace *ws = mt->ws + cmb;
+ populate_case_processing_summary (rows->root, mt, ws->control_idx);
+ for (int dv = 0; dv < mt->n_dep_vars; ++dv)
+ {
+ int idx = cmb * mt->n_dep_vars + dv;
+ const struct summary *summ = mt->summ + idx;
+ double n_included = summ->n_total - summ->n_missing;
+ pivot_table_put2 (pt, 5, idx,
+ pivot_value_new_number (100.0 * summ->n_total / summ->n_total));
+ pivot_table_put2 (pt, 4, idx,
+ pivot_value_new_number (summ->n_total));
+
+ pivot_table_put2 (pt, 3, idx,
+ pivot_value_new_number (100.0 * summ->n_missing / summ->n_total));
+ pivot_table_put2 (pt, 2, idx,
+ pivot_value_new_number (summ->n_missing));
+
+ pivot_table_put2 (pt, 1, idx,
+ pivot_value_new_number (100.0 * n_included / summ->n_total));
+ pivot_table_put2 (pt, 0, idx,
+ pivot_value_new_number (n_included));
+ }
+ }
+
+ pivot_table_submit (pt);
+}
+
+static void
+means_shipout_single (const struct mtable *mt, const struct means *means,
+ const struct workspace *ws)
+{
+ struct pivot_table *pt = pivot_table_create (N_("Report"));