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
23 #include "dictionary.h"
34 #define _(msgid) gettext (msgid)
38 #include "debug-print.h"
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 int n_dim; /* Number of dimensions. */
56 int *nv_dim; /* Number of variables in each dimension. */
57 struct variable ***v_dim; /* Variables in each dimension. */
59 /* VARIABLES: List of variables. */
61 struct variable **v_var;
63 /* Parses and executes the T-TEST procedure. */
68 int success = CMD_FAILURE;
75 if (!parse_means (&cmd))
81 for (i = 0; i < MNS_CL_count; i++)
84 if (i >= MNS_CL_count)
85 cmd.a_cells[MNS_CL_ALL] = 1;
88 cmd.a_cells[MNS_CL_DEFAULT] = 1;
89 if (cmd.a_cells[MNS_CL_DEFAULT] || cmd.a_cells[MNS_CL_ALL])
90 cmd.a_cells[MNS_CL_MEAN] = cmd.a_cells[MNS_CL_STDDEV] = cmd.a_cells[MNS_CL_COUNT] = 1;
91 if (cmd.a_cells[MNS_CL_ALL])
92 cmd.a_cells[MNS_CL_SUM] = cmd.a_cells[MNS_CL_VARIANCE] = 1;
94 if (cmd.sbc_statistics)
96 if (!cmd.a_statistics[MNS_ST_ANOVA] && !cmd.a_statistics[MNS_ST_LINEARITY])
97 cmd.a_statistics[MNS_ST_ANOVA] = 1;
98 if (cmd.a_statistics[MNS_ST_ALL])
99 cmd.a_statistics[MNS_ST_ANOVA] = cmd.a_statistics[MNS_ST_LINEARITY] = 1;
104 msg (SE, _("Missing required subcommand TABLES."));
108 success = CMD_SUCCESS;
114 for (i = 0; i < n_dim; i++)
124 /* Parses the TABLES subcommand. */
126 mns_custom_tables (struct cmd_means *cmd)
128 struct var_set *var_set;
130 if (!lex_match_id ("TABLES")
131 && (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
138 msg (SE, _("TABLES subcommand may not appear more "
143 var_set = var_set_create_from_dict (default_dict);
144 assert (var_set != NULL);
149 struct variable **vl;
151 if (!parse_var_set_vars (var_set, &vl, &nvl,
152 PV_NO_DUPLICATE | PV_NO_SCRATCH))
156 nv_dim = xrealloc (nv_dim, n_dim * sizeof (int));
157 v_dim = xrealloc (v_dim, n_dim * sizeof (struct variable **));
159 nv_dim[n_dim - 1] = nvl;
160 v_dim[n_dim - 1] = vl;
162 while (lex_match (T_BY));
164 var_set_destroy (var_set);
168 var_set_destroy (var_set);