1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <data/dictionary.h>
25 #include <data/procedure.h>
26 #include <data/variable.h>
27 #include <language/command.h>
28 #include <language/lexer/lexer.h>
29 #include <libpspp/alloc.h>
30 #include <libpspp/hash.h>
31 #include <libpspp/magic.h>
32 #include <libpspp/message.h>
35 #define _(msgid) gettext (msgid)
42 +format=lab:!labels/nolabels/nocatlabs,
46 missing=miss:!table/include/dependent;
47 +cells[cl_]=default,count,sum,mean,stddev,variance,all;
48 +statistics[st_]=anova,linearity,all,none.
53 /* TABLES: Variable lists for each dimension. */
54 static int n_dim; /* Number of dimensions. */
55 static size_t *nv_dim; /* Number of variables in each dimension. */
56 static struct variable ***v_dim; /* Variables in each dimension. */
58 /* VARIABLES: List of variables. */
59 static struct variable **v_var;
61 /* Parses and executes the T-TEST procedure. */
63 cmd_means (struct lexer *lexer, struct dataset *ds)
66 int success = CMD_FAILURE;
73 if (!parse_means (lexer, ds, &cmd, NULL))
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 lexer *lexer, struct dataset *ds, struct cmd_means *cmd, void *aux UNUSED)
126 struct var_set *var_set;
128 if (!lex_match_id (lexer, "TABLES")
129 && (lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
130 && lex_token (lexer) != T_ALL)
132 lex_match (lexer, '=');
136 msg (SE, _("TABLES subcommand may not appear more "
141 var_set = var_set_create_from_dict (dataset_dict (ds));
142 assert (var_set != NULL);
147 struct variable **vl;
149 if (!parse_var_set_vars (lexer, 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 (lexer, T_BY));
162 var_set_destroy (var_set);
166 var_set_destroy (var_set);