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/alloc.h>
28 #include <libpspp/hash.h>
29 #include <libpspp/message.h>
32 #define _(msgid) gettext (msgid)
39 +format=lab:!labels/nolabels/nocatlabs,
43 missing=miss:!table/include/dependent;
44 +cells[cl_]=default,count,sum,mean,stddev,variance,all;
45 +statistics[st_]=anova,linearity,all,none.
50 /* TABLES: Variable lists for each dimension. */
51 static int n_dim; /* Number of dimensions. */
52 static size_t *nv_dim; /* Number of variables in each dimension. */
53 static const struct variable ***v_dim; /* Variables in each dimension. */
55 /* VARIABLES: List of variables. */
56 static struct variable **v_var;
58 /* Parses and executes the T-TEST procedure. */
60 cmd_means (struct lexer *lexer, struct dataset *ds)
63 int success = CMD_FAILURE;
70 if (!parse_means (lexer, ds, &cmd, NULL))
76 for (i = 0; i < MNS_CL_count; i++)
79 if (i >= MNS_CL_count)
80 cmd.a_cells[MNS_CL_ALL] = 1;
83 cmd.a_cells[MNS_CL_DEFAULT] = 1;
84 if (cmd.a_cells[MNS_CL_DEFAULT] || cmd.a_cells[MNS_CL_ALL])
85 cmd.a_cells[MNS_CL_MEAN] = cmd.a_cells[MNS_CL_STDDEV] = cmd.a_cells[MNS_CL_COUNT] = 1;
86 if (cmd.a_cells[MNS_CL_ALL])
87 cmd.a_cells[MNS_CL_SUM] = cmd.a_cells[MNS_CL_VARIANCE] = 1;
89 if (cmd.sbc_statistics)
91 if (!cmd.a_statistics[MNS_ST_ANOVA] && !cmd.a_statistics[MNS_ST_LINEARITY])
92 cmd.a_statistics[MNS_ST_ANOVA] = 1;
93 if (cmd.a_statistics[MNS_ST_ALL])
94 cmd.a_statistics[MNS_ST_ANOVA] = cmd.a_statistics[MNS_ST_LINEARITY] = 1;
99 msg (SE, _("Missing required subcommand TABLES."));
103 success = CMD_SUCCESS;
109 for (i = 0; i < n_dim; i++)
119 /* Parses the TABLES subcommand. */
121 mns_custom_tables (struct lexer *lexer, struct dataset *ds, struct cmd_means *cmd, void *aux UNUSED)
123 struct const_var_set *var_set;
125 if (!lex_match_id (lexer, "TABLES")
126 && (lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
127 && lex_token (lexer) != T_ALL)
129 lex_match (lexer, '=');
133 msg (SE, _("TABLES subcommand may not appear more "
138 var_set = const_var_set_create_from_dict (dataset_dict (ds));
139 assert (var_set != NULL);
144 const struct variable **vl;
146 if (!parse_const_var_set_vars (lexer, var_set, &vl, &nvl,
147 PV_NO_DUPLICATE | PV_NO_SCRATCH))
151 nv_dim = xnrealloc (nv_dim, n_dim, sizeof *nv_dim);
152 v_dim = xnrealloc (v_dim, n_dim, sizeof *v_dim);
154 nv_dim[n_dim - 1] = nvl;
155 v_dim[n_dim - 1] = vl;
157 while (lex_match (lexer, T_BY));
159 const_var_set_destroy (var_set);
163 const_var_set_destroy (var_set);