1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "data/case.h"
20 #include "data/casegrouper.h"
21 #include "data/casereader.h"
22 #include "data/dataset.h"
23 #include "data/dictionary.h"
24 #include "data/format.h"
25 #include "data/variable.h"
27 #include "language/command.h"
28 #include "language/lexer/lexer.h"
29 #include "language/lexer/variable-parser.h"
31 #include "libpspp/misc.h"
32 #include "libpspp/pool.h"
34 #include "math/categoricals.h"
35 #include "math/interaction.h"
36 #include "math/moments.h"
38 #include "output/tab.h"
43 #define _(msgid) gettext (msgid)
44 #define N_(msgid) (msgid)
56 typedef void *stat_create (struct pool *pool);
57 typedef void stat_update (void *stat, double w, double x);
58 typedef double stat_get (const struct per_var_data *, void *aux);
62 /* Printable title for output */
65 /* Keyword for syntax */
80 harmonic_create (struct pool *pool)
82 struct harmonic_mean *hm = pool_alloc (pool, sizeof *hm);
92 harmonic_update (void *stat, double w, double x)
94 struct harmonic_mean *hm = stat;
101 harmonic_get (const struct per_var_data *pvd UNUSED, void *stat)
103 struct harmonic_mean *hm = stat;
105 return hm->n / hm->rsum;
110 struct geometric_mean
118 geometric_create (struct pool *pool)
120 struct geometric_mean *gm = pool_alloc (pool, sizeof *gm);
130 geometric_update (void *stat, double w, double x)
132 struct geometric_mean *gm = stat;
133 gm->prod *= pow (x, w);
139 geometric_get (const struct per_var_data *pvd UNUSED, void *stat)
141 struct geometric_mean *gm = stat;
143 return pow (gm->prod, 1.0 / gm->n);
149 sum_get (const struct per_var_data *pvd, void *stat UNUSED)
153 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
160 n_get (const struct per_var_data *pvd, void *stat UNUSED)
164 moments1_calculate (pvd->mom, &n, 0, 0, 0, 0);
170 arithmean_get (const struct per_var_data *pvd, void *stat UNUSED)
174 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
180 variance_get (const struct per_var_data *pvd, void *stat UNUSED)
182 double n, mean, variance;
184 moments1_calculate (pvd->mom, &n, &mean, &variance, 0, 0);
191 stddev_get (const struct per_var_data *pvd, void *stat)
193 return sqrt (variance_get (pvd, stat));
200 skew_get (const struct per_var_data *pvd, void *stat UNUSED)
204 moments1_calculate (pvd->mom, NULL, NULL, NULL, &skew, 0);
210 sekurt_get (const struct per_var_data *pvd, void *stat UNUSED)
214 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
216 return calc_sekurt (n);
220 seskew_get (const struct per_var_data *pvd, void *stat UNUSED)
224 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
226 return calc_seskew (n);
230 kurt_get (const struct per_var_data *pvd, void *stat UNUSED)
234 moments1_calculate (pvd->mom, NULL, NULL, NULL, NULL, &kurt);
240 semean_get (const struct per_var_data *pvd, void *stat UNUSED)
244 moments1_calculate (pvd->mom, &n, NULL, &var, NULL, NULL);
246 return sqrt (var / n);
252 min_create (struct pool *pool)
254 double *r = pool_alloc (pool, sizeof *r);
262 min_update (void *stat, double w UNUSED, double x)
271 min_get (const struct per_var_data *pvd UNUSED, void *stat)
279 max_create (struct pool *pool)
281 double *r = pool_alloc (pool, sizeof *r);
289 max_update (void *stat, double w UNUSED, double x)
298 max_get (const struct per_var_data *pvd UNUSED, void *stat)
314 range_create (struct pool *pool)
316 struct range *r = pool_alloc (pool, sizeof *r);
325 range_update (void *stat, double w UNUSED, double x)
327 struct range *r = stat;
337 range_get (const struct per_var_data *pvd UNUSED, void *stat)
339 struct range *r = stat;
341 return r->max - r->min;
347 last_create (struct pool *pool)
349 double *l = pool_alloc (pool, sizeof *l);
355 last_update (void *stat, double w UNUSED, double x)
363 last_get (const struct per_var_data *pvd UNUSED, void *stat)
372 first_create (struct pool *pool)
374 double *f = pool_alloc (pool, sizeof *f);
382 first_update (void *stat, double w UNUSED, double x)
391 first_get (const struct per_var_data *pvd UNUSED, void *stat)
405 /* Table of cell_specs */
406 static const struct cell_spec cell_spec[] = {
407 {N_("Mean"), "MEAN", NULL, NULL, arithmean_get},
408 {N_("N"), "COUNT", NULL, NULL, n_get},
409 {N_("Std. Deviation"), "STDDEV", NULL, NULL, stddev_get},
411 {N_("Median"), "MEDIAN", NULL, NULL, NULL},
412 {N_("Group Median"), "GMEDIAN", NULL, NULL, NULL},
414 {N_("S.E. Mean"), "SEMEAN", NULL, NULL, semean_get},
415 {N_("Sum"), "SUM", NULL, NULL, sum_get},
416 {N_("Min"), "MIN", min_create, min_update, min_get},
417 {N_("Max"), "MAX", max_create, max_update, max_get},
418 {N_("Range"), "RANGE", range_create, range_update, range_get},
419 {N_("Variance"), "VARIANCE", NULL, NULL, variance_get},
420 {N_("Kurtosis"), "KURT", NULL, NULL, kurt_get},
421 {N_("S.E. Kurt"), "SEKURT", NULL, NULL, sekurt_get},
422 {N_("Skewness"), "SKEW", NULL, NULL, skew_get},
423 {N_("S.E. Skew"), "SESKEW", NULL, NULL, seskew_get},
424 {N_("First"), "FIRST", first_create, first_update, first_get},
425 {N_("Last"), "LAST", last_create, last_update, last_get},
427 {N_("Percent N"), "NPCT", NULL, NULL, NULL},
428 {N_("Percent Sum"), "SPCT", NULL, NULL, NULL},
430 {N_("Harmonic Mean"), "HARMONIC", harmonic_create, harmonic_update, harmonic_get},
431 {N_("Geom. Mean"), "GEOMETRIC", geometric_create, geometric_update, geometric_get}
434 #define n_C (sizeof (cell_spec) / sizeof (struct cell_spec))
440 casenumber non_missing;
446 size_t n_factor_vars;
447 const struct variable **factor_vars;
450 /* The thing parsed after TABLES= */
454 const struct variable **dep_vars;
457 struct layer *layers;
459 struct interaction **interactions;
460 struct summary *summary;
464 struct categoricals *cats;
469 const struct dictionary *dict;
471 struct mtable *table;
474 /* Missing value class for categorical variables */
475 enum mv_class exclude;
477 /* Missing value class for dependent variables */
478 enum mv_class dep_exclude;
480 bool listwise_exclude;
482 /* an array indicating which statistics are to be calculated */
488 /* Pool on which cell functions may allocate data */
494 run_means (struct means *cmd, struct casereader *input,
495 const struct dataset *ds);
500 parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, struct mtable *table)
504 table->layers = NULL;
505 table->interactions = NULL;
507 /* Dependent variable (s) */
508 if (!parse_variables_const_pool (lexer, cmd->pool, cmd->dict,
509 &table->dep_vars, &table->n_dep_vars,
510 PV_NO_DUPLICATE | PV_NUMERIC))
513 /* Factor variable (s) */
514 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
516 if (lex_match (lexer, T_BY))
520 pool_realloc (cmd->pool, table->layers,
521 sizeof (*table->layers) * table->n_layers);
523 if (!parse_variables_const_pool
524 (lexer, cmd->pool, cmd->dict,
525 &table->layers[table->n_layers - 1].factor_vars,
526 &table->layers[table->n_layers - 1].n_factor_vars,
533 /* There is always at least one layer.
534 However the final layer is the total, and not
535 normally considered by the user as a
541 pool_realloc (cmd->pool, table->layers,
542 sizeof (*table->layers) * table->n_layers);
543 table->layers[table->n_layers - 1].factor_vars = NULL;
544 table->layers[table->n_layers - 1].n_factor_vars = 0;
550 If the match succeeds, the variable will be placed in VAR.
551 Returns true if successful */
553 lex_is_variable (struct lexer *lexer, const struct dictionary *dict,
557 if (lex_next_token (lexer, n) != T_ID)
560 tstr = lex_next_tokcstr (lexer, n);
562 if (NULL == dict_lookup_var (dict, tstr) )
570 cmd_means (struct lexer *lexer, struct dataset *ds)
576 bool more_tables = true;
578 means.pool = pool_create ();
580 means.exclude = MV_ANY;
581 means.dep_exclude = MV_ANY;
582 means.listwise_exclude = false;
586 means.dict = dataset_dict (ds);
589 means.cells = pool_calloc (means.pool, means.n_cells, sizeof (*means.cells));
592 /* The first three items (MEAN, COUNT, STDDEV) are the default */
593 for (i = 0; i < 3; ++i)
597 /* Optional TABLES = */
598 if (lex_match_id (lexer, "TABLES"))
600 lex_force_match (lexer, T_EQUALS);
605 /* Parse the "tables" */
609 means.table = pool_realloc (means.pool, means.table, means.n_tables * sizeof (*means.table));
611 if (! parse_means_table_syntax (lexer, &means,
612 &means.table[means.n_tables - 1]))
617 /* Look ahead to see if there are more tables to be parsed */
619 if ( T_SLASH == lex_next_token (lexer, 0) )
621 if (lex_is_variable (lexer, means.dict, 1) )
624 lex_force_match (lexer, T_SLASH);
629 /* /MISSING subcommand */
630 while (lex_token (lexer) != T_ENDCMD)
632 lex_match (lexer, T_SLASH);
634 if (lex_match_id (lexer, "MISSING"))
637 If no MISSING subcommand is specified, each combination of
638 a dependent variable and categorical variables is handled
641 lex_match (lexer, T_EQUALS);
642 if (lex_match_id (lexer, "INCLUDE"))
645 Use the subcommand "/MISSING=INCLUDE" to include user-missing
646 values in the analysis.
649 means.exclude = MV_SYSTEM;
650 means.dep_exclude = MV_SYSTEM;
652 else if (lex_match_id (lexer, "TABLE"))
654 This is the default. (I think).
655 Every case containing a complete set of variables for a given
656 table. If any variable, categorical or dependent for in a table
657 is missing (as defined by what?), then that variable will
658 be dropped FOR THAT TABLE ONLY.
661 means.listwise_exclude = true;
663 else if (lex_match_id (lexer, "DEPENDENT"))
665 Use the command "/MISSING=DEPENDENT" to
666 include user-missing values for the categorical variables,
667 while excluding them for the dependent variables.
669 Cases are dropped only when user-missing values
670 appear in dependent variables. User-missing
671 values for categorical variables are treated according to
674 Cases are ALWAYS dropped when System Missing values appear
675 in the categorical variables.
678 means.dep_exclude = MV_ANY;
679 means.exclude = MV_SYSTEM;
683 lex_error (lexer, NULL);
687 else if (lex_match_id (lexer, "CELLS"))
689 lex_match (lexer, T_EQUALS);
691 /* The default values become overwritten */
693 while (lex_token (lexer) != T_ENDCMD
694 && lex_token (lexer) != T_SLASH)
697 if (lex_match (lexer, T_ALL))
701 pool_realloc (means.pool, means.cells,
702 (means.n_cells += n_C) * sizeof (*means.cells));
704 for (x = 0; x < n_C; ++x)
705 means.cells[means.n_cells - (n_C - 1 - x) - 1] = x;
707 else if (lex_match_id (lexer, "NONE"))
711 else if (lex_match_id (lexer, "DEFAULT"))
714 pool_realloc (means.pool, means.cells,
715 (means.n_cells += 3) * sizeof (*means.cells));
717 means.cells[means.n_cells - 2 - 1] = MEANS_MEAN;
718 means.cells[means.n_cells - 1 - 1] = MEANS_N;
719 means.cells[means.n_cells - 0 - 1] = MEANS_STDDEV;
725 if (lex_match_id (lexer, cell_spec[k].keyword))
728 pool_realloc (means.pool, means.cells,
729 ++means.n_cells * sizeof (*means.cells));
731 means.cells[means.n_cells - 1] = k;
738 lex_error (lexer, NULL);
745 lex_error (lexer, NULL);
752 for (t = 0; t < means.n_tables; ++t)
754 struct mtable *table = &means.table[t];
756 table->interactions =
757 pool_calloc (means.pool, table->n_layers, sizeof (*table->interactions));
760 pool_calloc (means.pool, table->n_dep_vars * table->n_layers, sizeof (*table->summary));
762 for (l = 0; l < table->n_layers; ++l)
765 const struct layer *lyr = &table->layers[l];
766 const int n_vars = lyr->n_factor_vars;
767 table->interactions[l] = interaction_create (NULL);
768 for (v = 0; v < n_vars ; ++v)
770 interaction_add_variable (table->interactions[l],
771 lyr->factor_vars[v]);
777 struct casegrouper *grouper;
778 struct casereader *group;
781 grouper = casegrouper_create_splits (proc_open (ds), means.dict);
782 while (casegrouper_get_next_group (grouper, &group))
784 run_means (&means, group, ds);
786 ok = casegrouper_destroy (grouper);
787 ok = proc_commit (ds) && ok;
790 for (t = 0; t < means.n_tables; ++t)
793 struct mtable *table = &means.table[t];
794 if (table->interactions)
795 for (l = 0; l < table->n_layers; ++l)
797 interaction_destroy (table->interactions[l]);
801 pool_destroy (means.pool);
806 for (t = 0; t < means.n_tables; ++t)
809 struct mtable *table = &means.table[t];
810 if (table->interactions)
811 for (l = 0; l < table->n_layers; ++l)
813 interaction_destroy (table->interactions[l]);
817 pool_destroy (means.pool);
823 is_missing (const struct means *cmd,
824 const struct variable *dvar,
825 const struct interaction *iact,
826 const struct ccase *c)
828 if ( interaction_case_is_missing (iact, c, cmd->exclude) )
832 if (var_is_value_missing (dvar,
840 static void output_case_processing_summary (const struct mtable *);
842 static void output_report (const struct means *, int, const struct mtable *);
847 struct per_var_data *pvd;
854 destroy_n (const void *aux1 UNUSED, void *aux2, void *user_data)
856 struct mtable *table = aux2;
858 struct per_cat_data *per_cat_data = user_data;
859 struct per_var_data *pvd = per_cat_data->pvd;
861 for (v = 0; v < table->n_dep_vars; ++v)
863 struct per_var_data *pp = &pvd[v];
864 moments1_destroy (pp->mom);
869 create_n (const void *aux1, void *aux2)
872 const struct means *means = aux1;
873 struct mtable *table = aux2;
874 struct per_cat_data *per_cat_data = pool_malloc (means->pool, sizeof *per_cat_data);
876 struct per_var_data *pvd = pool_calloc (means->pool, table->n_dep_vars, sizeof *pvd);
878 for (v = 0; v < table->n_dep_vars; ++v)
880 enum moment maxmom = MOMENT_KURTOSIS;
881 struct per_var_data *pp = &pvd[v];
883 pp->cell_stats = pool_calloc (means->pool, means->n_cells, sizeof *pp->cell_stats);
886 for (i = 0; i < means->n_cells; ++i)
888 int csi = means->cells[i];
889 const struct cell_spec *cs = &cell_spec[csi];
892 pp->cell_stats[i] = cs->sc (means->pool);
895 pp->mom = moments1_create (maxmom);
899 per_cat_data->pvd = pvd;
900 per_cat_data->warn = true;
905 update_n (const void *aux1, void *aux2, void *user_data, const struct ccase *c, double weight)
909 const struct means *means = aux1;
910 struct mtable *table = aux2;
911 struct per_cat_data *per_cat_data = user_data;
913 for (v = 0; v < table->n_dep_vars; ++v)
915 struct per_var_data *pvd = &per_cat_data->pvd[v];
917 const double x = case_data (c, table->dep_vars[v])->f;
919 for (i = 0; i < table->n_layers; ++i)
921 if ( is_missing (means, table->dep_vars[v],
922 table->interactions[i], c))
926 for (i = 0; i < means->n_cells; ++i)
928 const int csi = means->cells[i];
929 const struct cell_spec *cs = &cell_spec[csi];
933 cs->su (pvd->cell_stats[i],
937 moments1_add (pvd->mom, x, weight);
945 calculate_n (const void *aux1, void *aux2, void *user_data)
949 struct per_cat_data *per_cat_data = user_data;
950 const struct means *means = aux1;
951 struct mtable *table = aux2;
953 for (v = 0; v < table->n_dep_vars; ++v)
955 struct per_var_data *pvd = &per_cat_data->pvd[v];
956 for (i = 0; i < means->n_cells; ++i)
958 int csi = means->cells[i];
959 const struct cell_spec *cs = &cell_spec[csi];
962 cs->sd (pvd, pvd->cell_stats[i]);
968 run_means (struct means *cmd, struct casereader *input,
969 const struct dataset *ds UNUSED)
972 const struct variable *wv = dict_get_weight (cmd->dict);
974 struct casereader *reader;
976 struct payload payload;
977 payload.create = create_n;
978 payload.update = update_n;
979 payload.calculate = calculate_n;
980 payload.destroy = destroy_n;
982 for (t = 0; t < cmd->n_tables; ++t)
984 struct mtable *table = &cmd->table[t];
986 = categoricals_create (table->interactions,
987 table->n_layers, wv, cmd->dep_exclude, cmd->exclude);
989 categoricals_set_payload (table->cats, &payload, cmd, table);
993 (c = casereader_read (reader)) != NULL; case_unref (c))
995 for (t = 0; t < cmd->n_tables; ++t)
997 bool something_missing = false;
999 struct mtable *table = &cmd->table[t];
1001 for (v = 0; v < table->n_dep_vars; ++v)
1004 for (i = 0; i < table->n_layers; ++i)
1006 const bool missing =
1007 is_missing (cmd, table->dep_vars[v],
1008 table->interactions[i], c);
1011 something_missing = true;
1012 table->summary[v * table->n_layers + i].missing++;
1015 table->summary[v * table->n_layers + i].non_missing++;
1018 if ( something_missing && cmd->listwise_exclude)
1021 categoricals_update (table->cats, c);
1024 casereader_destroy (reader);
1026 for (t = 0; t < cmd->n_tables; ++t)
1028 struct mtable *table = &cmd->table[t];
1030 categoricals_done (table->cats);
1034 for (t = 0; t < cmd->n_tables; ++t)
1037 const struct mtable *table = &cmd->table[t];
1039 output_case_processing_summary (table);
1041 for (i = 0; i < table->n_layers; ++i)
1043 output_report (cmd, i, table);
1045 categoricals_destroy (table->cats);
1053 output_case_processing_summary (const struct mtable *table)
1056 const int heading_columns = 1;
1057 const int heading_rows = 3;
1058 struct tab_table *t;
1060 const int nr = heading_rows + table->n_layers * table->n_dep_vars;
1063 t = tab_create (nc, nr);
1064 tab_title (t, _("Case Processing Summary"));
1066 tab_headers (t, heading_columns, 0, heading_rows, 0);
1068 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1070 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1071 tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
1074 tab_joint_text (t, heading_columns, 0,
1075 nc - 1, 0, TAB_CENTER | TAT_TITLE, _("Cases"));
1077 tab_joint_text (t, 1, 1, 2, 1, TAB_CENTER | TAT_TITLE, _("Included"));
1078 tab_joint_text (t, 3, 1, 4, 1, TAB_CENTER | TAT_TITLE, _("Excluded"));
1079 tab_joint_text (t, 5, 1, 6, 1, TAB_CENTER | TAT_TITLE, _("Total"));
1081 tab_hline (t, TAL_1, heading_columns, nc - 1, 1);
1082 tab_hline (t, TAL_1, heading_columns, nc - 1, 2);
1085 for (i = 0; i < 3; ++i)
1087 tab_text (t, heading_columns + i * 2, 2, TAB_CENTER | TAT_TITLE,
1089 tab_text (t, heading_columns + i * 2 + 1, 2, TAB_CENTER | TAT_TITLE,
1093 for (v = 0; v < table->n_dep_vars; ++v)
1095 const struct variable *var = table->dep_vars[v];
1096 const char *dv_name = var_to_string (var);
1097 for (i = 0; i < table->n_layers; ++i)
1099 const int row = v * table->n_layers + i;
1100 const struct interaction *iact = table->interactions[i];
1104 ds_init_cstr (&str, dv_name);
1105 ds_put_cstr (&str, ": ");
1107 interaction_to_string (iact, &str);
1109 tab_text (t, 0, row + heading_rows,
1110 TAB_LEFT | TAT_TITLE, ds_cstr (&str));
1113 n_total = table->summary[row].missing +
1114 table->summary[row].non_missing;
1116 tab_double (t, 1, row + heading_rows,
1117 0, table->summary[row].non_missing, &F_8_0);
1119 tab_text_format (t, 2, row + heading_rows,
1121 table->summary[row].non_missing / (double) n_total * 100.0);
1124 tab_double (t, 3, row + heading_rows,
1125 0, table->summary[row].missing, &F_8_0);
1128 tab_text_format (t, 4, row + heading_rows,
1130 table->summary[row].missing / (double) n_total * 100.0);
1133 tab_double (t, 5, row + heading_rows,
1134 0, table->summary[row].missing +
1135 table->summary[row].non_missing, &F_8_0);
1137 tab_text_format (t, 6, row + heading_rows,
1139 n_total / (double) n_total * 100.0);
1151 output_report (const struct means *cmd, int iact_idx,
1152 const struct mtable *table)
1157 const struct interaction *iact = table->interactions[iact_idx];
1159 const int heading_columns = 1 + iact->n_vars;
1160 const int heading_rows = 1;
1161 struct tab_table *t;
1163 const int n_cats = categoricals_n_count (table->cats, iact_idx);
1165 const int nr = n_cats * table->n_dep_vars + heading_rows;
1167 const int nc = heading_columns + cmd->n_cells;
1169 t = tab_create (nc, nr);
1170 tab_title (t, _("Report"));
1172 tab_headers (t, heading_columns, 0, heading_rows, 0);
1174 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1176 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1177 tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
1179 for (i = 0; i < iact->n_vars; ++i)
1181 tab_text (t, 1 + i, 0, TAB_CENTER | TAT_TITLE,
1182 var_to_string (iact->vars[i]));
1185 for (i = 0; i < cmd->n_cells; ++i)
1187 tab_text (t, heading_columns + i, 0,
1188 TAB_CENTER | TAT_TITLE,
1189 gettext (cell_spec[cmd->cells[i]].title));
1193 for (i = 0; i < n_cats; ++i)
1196 const struct ccase *c =
1197 categoricals_get_case_by_category_real (table->cats, iact_idx, i);
1199 for (dv = 0; dv < table->n_dep_vars; ++dv)
1202 heading_rows + dv * n_cats,
1203 TAB_RIGHT | TAT_TITLE,
1204 var_to_string (table->dep_vars[dv])
1208 tab_hline (t, TAL_1, 0, nc - 1, heading_rows + dv * n_cats);
1210 for (v = 0; v < iact->n_vars; ++v)
1212 const struct variable *var = iact->vars[v];
1213 const union value *val = case_data (c, var);
1215 ds_init_empty (&str);
1216 var_append_value_name (var, val, &str);
1218 tab_text (t, 1 + v, heading_rows + dv * n_cats + i,
1219 TAB_RIGHT | TAT_TITLE, ds_cstr (&str));
1226 for (grp = 0; grp < n_cats; ++grp)
1229 struct per_cat_data *per_cat_data =
1230 categoricals_get_user_data_by_category_real (table->cats, iact_idx, grp);
1232 for (dv = 0; dv < table->n_dep_vars; ++dv)
1234 const struct per_var_data *pvd = &per_cat_data->pvd[dv];
1235 for (i = 0; i < cmd->n_cells; ++i)
1237 const int csi = cmd->cells[i];
1238 const struct cell_spec *cs = &cell_spec[csi];
1240 double result = cs->sd (pvd, pvd->cell_stats[i]);
1242 tab_double (t, heading_columns + i,
1243 heading_rows + grp + dv * n_cats,