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., 59 Temple Place - Suite 330, Boston, MA
23 #include "dictionary.h"
34 #include "debug-print.h"
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 int n_dim; /* Number of dimensions. */
52 int *nv_dim; /* Number of variables in each dimension. */
53 struct variable ***v_dim; /* Variables in each dimension. */
55 /* VARIABLES: List of variables. */
57 struct variable **v_var;
59 /* Parses and executes the T-TEST procedure. */
64 int success = CMD_FAILURE;
71 if (!parse_means (&cmd))
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 cmd_means *cmd)
124 struct var_set *var_set;
126 if (!lex_match_id ("TABLES")
127 && (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
134 msg (SE, _("TABLES subcommand may not appear more "
139 var_set = var_set_create_from_dict (default_dict);
140 assert (var_set != NULL);
145 struct variable **vl;
147 if (!parse_var_set_vars (var_set, &vl, &nvl,
148 PV_NO_DUPLICATE | PV_NO_SCRATCH))
152 nv_dim = xrealloc (nv_dim, n_dim * sizeof (int));
153 v_dim = xrealloc (v_dim, n_dim * sizeof (struct variable **));
155 nv_dim[n_dim - 1] = nvl;
156 v_dim[n_dim - 1] = vl;
158 while (lex_match (T_BY));
160 var_set_destroy (var_set);
164 var_set_destroy (var_set);