+static void
+normality_report (const struct examine *cmd, int iact_idx)
+{
+ struct pivot_table *table = pivot_table_create (N_("Tests of Normality"));
+ table->omit_empty = true;
+
+ struct pivot_dimension *test =
+ pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Shapiro-Wilk"),
+ N_("Statistic"),
+ N_("df"), PIVOT_RC_COUNT,
+ N_("Sig."));
+
+ test->root->show_label = true;
+
+ const struct interaction *iact = cmd->iacts[iact_idx];
+ struct pivot_footnote *missing_footnote = create_missing_footnote (table);
+ create_interaction_dimensions (table, cmd->cats, iact, missing_footnote);
+
+ struct pivot_dimension *dep_dim = pivot_dimension_create (
+ table, PIVOT_AXIS_ROW, N_("Dependent Variables"));
+
+ size_t *indexes = xnmalloc (table->n_dimensions, sizeof *indexes);
+
+ size_t n_cats = categoricals_n_count (cmd->cats, iact_idx);
+ for (size_t v = 0; v < cmd->n_dep_vars; ++v)
+ {
+ indexes[table->n_dimensions - 1] =
+ pivot_category_create_leaf (dep_dim->root, pivot_value_new_variable (cmd->dep_vars[v]));
+
+ for (size_t i = 0; i < n_cats; ++i)
+ {
+ indexes[1] = i;
+
+ const struct exploratory_stats *es
+ = categoricals_get_user_data_by_category_real (
+ cmd->cats, iact_idx, i);
+
+ struct shapiro_wilk *sw = es[v].shapiro_wilk;
+
+ if (sw == NULL)
+ continue;
+
+ double w = shapiro_wilk_calculate (sw);
+
+ int j = 0;
+ indexes[0] = j;
+
+ pivot_table_put (table, indexes, table->n_dimensions,
+ pivot_value_new_number (w));
+
+ indexes[0] = ++j;
+ pivot_table_put (table, indexes, table->n_dimensions,
+ pivot_value_new_number (sw->n));
+
+ indexes[0] = ++j;
+ pivot_table_put (table, indexes, table->n_dimensions,
+ pivot_value_new_number (shapiro_wilk_significance (sw->n, w)));
+ }
+ }
+
+ free (indexes);
+
+ pivot_table_submit (table);
+}
+
+