1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000 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/>. */
22 #include <data/dictionary.h>
23 #include <data/procedure.h>
24 #include <data/variable.h>
25 #include <language/command.h>
26 #include <language/lexer/lexer.h>
27 #include <libpspp/hash.h>
28 #include <libpspp/message.h>
33 #define _(msgid) gettext (msgid)
40 +format=lab:!labels/nolabels/nocatlabs,
44 missing=miss:!table/include/dependent;
45 +cells[cl_]=default,count,sum,mean,stddev,variance,all;
46 +statistics[st_]=anova,linearity,all,none.
51 /* TABLES: Variable lists for each dimension. */
52 static int n_dim; /* Number of dimensions. */
53 static size_t *nv_dim; /* Number of variables in each dimension. */
54 static const struct variable ***v_dim; /* Variables in each dimension. */
56 /* VARIABLES: List of variables. */
57 static struct variable **v_var;
59 /* Parses and executes the T-TEST procedure. */
61 cmd_means (struct lexer *lexer, struct dataset *ds)
64 int success = CMD_FAILURE;
71 if (!parse_means (lexer, ds, &cmd, NULL))
77 for (i = 0; i < MNS_CL_count; i++)
80 if (i >= MNS_CL_count)
81 cmd.a_cells[MNS_CL_ALL] = 1;
84 cmd.a_cells[MNS_CL_DEFAULT] = 1;
85 if (cmd.a_cells[MNS_CL_DEFAULT] || cmd.a_cells[MNS_CL_ALL])
86 cmd.a_cells[MNS_CL_MEAN] = cmd.a_cells[MNS_CL_STDDEV] = cmd.a_cells[MNS_CL_COUNT] = 1;
87 if (cmd.a_cells[MNS_CL_ALL])
88 cmd.a_cells[MNS_CL_SUM] = cmd.a_cells[MNS_CL_VARIANCE] = 1;
90 if (cmd.sbc_statistics)
92 if (!cmd.a_statistics[MNS_ST_ANOVA] && !cmd.a_statistics[MNS_ST_LINEARITY])
93 cmd.a_statistics[MNS_ST_ANOVA] = 1;
94 if (cmd.a_statistics[MNS_ST_ALL])
95 cmd.a_statistics[MNS_ST_ANOVA] = cmd.a_statistics[MNS_ST_LINEARITY] = 1;
100 msg (SE, _("Missing required subcommand TABLES."));
104 success = CMD_SUCCESS;
110 for (i = 0; i < n_dim; i++)
120 /* Parses the TABLES subcommand. */
122 mns_custom_tables (struct lexer *lexer, struct dataset *ds, struct cmd_means *cmd, void *aux UNUSED)
124 struct const_var_set *var_set;
126 if (!lex_match_id (lexer, "TABLES")
127 && (lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
128 && lex_token (lexer) != T_ALL)
130 lex_match (lexer, '=');
134 msg (SE, _("TABLES subcommand may not appear more "
139 var_set = const_var_set_create_from_dict (dataset_dict (ds));
140 assert (var_set != NULL);
145 const struct variable **vl;
147 if (!parse_const_var_set_vars (lexer, var_set, &vl, &nvl,
148 PV_NO_DUPLICATE | PV_NO_SCRATCH))
152 nv_dim = xnrealloc (nv_dim, n_dim, sizeof *nv_dim);
153 v_dim = xnrealloc (v_dim, n_dim, sizeof *v_dim);
155 nv_dim[n_dim - 1] = nvl;
156 v_dim[n_dim - 1] = vl;
158 while (lex_match (lexer, T_BY));
160 const_var_set_destroy (var_set);
164 const_var_set_destroy (var_set);