1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include <data/dictionary.h>
26 #include <data/procedure.h>
27 #include <data/variable.h>
28 #include <language/command.h>
29 #include <language/lexer/lexer.h>
30 #include <libpspp/alloc.h>
31 #include <libpspp/hash.h>
32 #include <libpspp/magic.h>
33 #include <libpspp/message.h>
36 #define _(msgid) gettext (msgid)
43 +format=lab:!labels/nolabels/nocatlabs,
47 missing=miss:!table/include/dependent;
48 +cells[cl_]=default,count,sum,mean,stddev,variance,all;
49 +statistics[st_]=anova,linearity,all,none.
54 /* TABLES: Variable lists for each dimension. */
55 static int n_dim; /* Number of dimensions. */
56 static size_t *nv_dim; /* Number of variables in each dimension. */
57 static struct variable ***v_dim; /* Variables in each dimension. */
59 /* VARIABLES: List of variables. */
60 static struct variable **v_var;
62 /* Parses and executes the T-TEST procedure. */
64 cmd_means (struct lexer *lexer, struct dataset *ds)
67 int success = CMD_FAILURE;
74 if (!parse_means (lexer, ds, &cmd, NULL))
80 for (i = 0; i < MNS_CL_count; i++)
83 if (i >= MNS_CL_count)
84 cmd.a_cells[MNS_CL_ALL] = 1;
87 cmd.a_cells[MNS_CL_DEFAULT] = 1;
88 if (cmd.a_cells[MNS_CL_DEFAULT] || cmd.a_cells[MNS_CL_ALL])
89 cmd.a_cells[MNS_CL_MEAN] = cmd.a_cells[MNS_CL_STDDEV] = cmd.a_cells[MNS_CL_COUNT] = 1;
90 if (cmd.a_cells[MNS_CL_ALL])
91 cmd.a_cells[MNS_CL_SUM] = cmd.a_cells[MNS_CL_VARIANCE] = 1;
93 if (cmd.sbc_statistics)
95 if (!cmd.a_statistics[MNS_ST_ANOVA] && !cmd.a_statistics[MNS_ST_LINEARITY])
96 cmd.a_statistics[MNS_ST_ANOVA] = 1;
97 if (cmd.a_statistics[MNS_ST_ALL])
98 cmd.a_statistics[MNS_ST_ANOVA] = cmd.a_statistics[MNS_ST_LINEARITY] = 1;
103 msg (SE, _("Missing required subcommand TABLES."));
107 success = CMD_SUCCESS;
113 for (i = 0; i < n_dim; i++)
123 /* Parses the TABLES subcommand. */
125 mns_custom_tables (struct lexer *lexer, struct dataset *ds, struct cmd_means *cmd, void *aux UNUSED)
127 struct var_set *var_set;
129 if (!lex_match_id (lexer, "TABLES")
130 && (lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
131 && lex_token (lexer) != T_ALL)
133 lex_match (lexer, '=');
137 msg (SE, _("TABLES subcommand may not appear more "
142 var_set = var_set_create_from_dict (dataset_dict (ds));
143 assert (var_set != NULL);
148 struct variable **vl;
150 if (!parse_var_set_vars (lexer, var_set, &vl, &nvl,
151 PV_NO_DUPLICATE | PV_NO_SCRATCH))
155 nv_dim = xnrealloc (nv_dim, n_dim, sizeof *nv_dim);
156 v_dim = xnrealloc (v_dim, n_dim, sizeof *v_dim);
158 nv_dim[n_dim - 1] = nvl;
159 v_dim[n_dim - 1] = vl;
161 while (lex_match (lexer, T_BY));
163 var_set_destroy (var_set);
167 var_set_destroy (var_set);