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
22 #include <libpspp/alloc.h>
23 #include <libpspp/compiler.h>
24 #include <data/dictionary.h>
25 #include <data/file-handle-def.h>
26 #include <language/data-io/file-handle.h>
27 #include <language/command.h>
28 #include <language/lexer/lexer.h>
29 #include <data/variable.h>
32 #include <libpspp/debug-print.h>
37 struct variable **v1, **v2;
41 struct cor_set *cor_list, *cor_last;
43 struct file_handle *matrix_file;
45 static void free_correlations_state (void);
46 static int internal_cmd_correlations (void);
49 cmd_correlations (void)
51 int result = internal_cmd_correlations ();
52 free_correlations_state ();
57 "CORRELATIONS" (cor_):
59 +missing=miss:!pairwise/listwise,
61 +print=tail:!twotail/onetail,
63 +format=fmt:!matrix/serial;
65 +statistics[st_]=descriptives,xprod,all.
71 internal_cmd_correlations (void)
73 struct cmd_correlations cmd;
75 cor_list = cor_last = NULL;
78 if (!parse_correlations (&cmd))
80 free_correlations (&cmd);
86 cor_custom_variables (struct cmd_correlations *cmd UNUSED)
88 struct variable **v1, **v2;
92 /* Ensure that this is a VARIABLES subcommand. */
93 if (!lex_match_id ("VARIABLES")
94 && (token != T_ID || dict_lookup_var (default_dict, tokid) != NULL)
99 if (!parse_variables (default_dict, &v1, &nv1,
100 PV_NO_DUPLICATE | PV_NUMERIC))
103 if (lex_match (T_WITH))
105 if (!parse_variables (default_dict, &v2, &nv2,
106 PV_NO_DUPLICATE | PV_NUMERIC))
118 cor = xmalloc (sizeof *cor);
125 cor_last = cor_last->next = cor;
127 cor_list = cor_last = cor;
133 cor_custom_matrix (struct cmd_correlations *cmd UNUSED)
135 if (!lex_force_match ('('))
142 matrix_file = fh_parse (FH_REF_FILE);
143 if (matrix_file == NULL)
147 if (!lex_force_match (')'))
154 free_correlations_state (void)
156 struct cor_set *cor, *next;
158 for (cor = cor_list; cor != NULL; cor = next)
161 if (cor->v1 != cor->v2)