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 <data/dictionary.h>
24 #include <libpspp/message.h>
25 #include <libpspp/alloc.h>
26 #include <language/command.h>
27 #include <libpspp/hash.h>
28 #include <language/lexer/lexer.h>
29 #include <libpspp/message.h>
30 #include <libpspp/magic.h>
31 #include <data/variable.h>
34 #define _(msgid) gettext (msgid)
41 +format=lab:!labels/nolabels/nocatlabs,
45 +missing=miss:!table/include/dependent;
46 +cells[cl_]=default,count,sum,mean,stddev,variance,all;
47 +statistics[st_]=anova,linearity,all,none.
52 /* TABLES: Variable lists for each dimension. */
53 int n_dim; /* Number of dimensions. */
54 size_t *nv_dim; /* Number of variables in each dimension. */
55 struct variable ***v_dim; /* Variables in each dimension. */
57 /* VARIABLES: List of variables. */
59 struct variable **v_var;
61 /* Parses and executes the T-TEST procedure. */
66 int success = CMD_FAILURE;
73 if (!parse_means (&cmd))
79 for (i = 0; i < MNS_CL_count; i++)
82 if (i >= MNS_CL_count)
83 cmd.a_cells[MNS_CL_ALL] = 1;
86 cmd.a_cells[MNS_CL_DEFAULT] = 1;
87 if (cmd.a_cells[MNS_CL_DEFAULT] || cmd.a_cells[MNS_CL_ALL])
88 cmd.a_cells[MNS_CL_MEAN] = cmd.a_cells[MNS_CL_STDDEV] = cmd.a_cells[MNS_CL_COUNT] = 1;
89 if (cmd.a_cells[MNS_CL_ALL])
90 cmd.a_cells[MNS_CL_SUM] = cmd.a_cells[MNS_CL_VARIANCE] = 1;
92 if (cmd.sbc_statistics)
94 if (!cmd.a_statistics[MNS_ST_ANOVA] && !cmd.a_statistics[MNS_ST_LINEARITY])
95 cmd.a_statistics[MNS_ST_ANOVA] = 1;
96 if (cmd.a_statistics[MNS_ST_ALL])
97 cmd.a_statistics[MNS_ST_ANOVA] = cmd.a_statistics[MNS_ST_LINEARITY] = 1;
102 msg (SE, _("Missing required subcommand TABLES."));
106 success = CMD_SUCCESS;
112 for (i = 0; i < n_dim; i++)
122 /* Parses the TABLES subcommand. */
124 mns_custom_tables (struct cmd_means *cmd)
126 struct var_set *var_set;
128 if (!lex_match_id ("TABLES")
129 && (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
136 msg (SE, _("TABLES subcommand may not appear more "
141 var_set = var_set_create_from_dict (default_dict);
142 assert (var_set != NULL);
147 struct variable **vl;
149 if (!parse_var_set_vars (var_set, &vl, &nvl,
150 PV_NO_DUPLICATE | PV_NO_SCRATCH))
154 nv_dim = xnrealloc (nv_dim, n_dim, sizeof *nv_dim);
155 v_dim = xnrealloc (v_dim, n_dim, sizeof *v_dim);
157 nv_dim[n_dim - 1] = nvl;
158 v_dim[n_dim - 1] = vl;
160 while (lex_match (T_BY));
162 var_set_destroy (var_set);
166 var_set_destroy (var_set);