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"
24 #include "file-handle.h"
30 #include "debug-print.h"
35 struct variable **v1, **v2;
39 struct cor_set *cor_list, *cor_last;
41 struct file_handle *matrix_file;
43 static void free_correlations_state (void);
44 static int internal_cmd_correlations (void);
47 cmd_correlations (void)
49 int result = internal_cmd_correlations ();
50 free_correlations_state ();
55 "CORRELATIONS" (cor_):
57 +missing=miss:!pairwise/listwise,
59 +print=tail:!twotail/onetail,
61 +format=fmt:!matrix/serial;
63 +statistics[st_]=descriptives,xprod,all.
69 internal_cmd_correlations (void)
71 struct cmd_correlations cmd;
73 cor_list = cor_last = NULL;
76 if (!parse_correlations (&cmd))
78 free_correlations (&cmd);
84 cor_custom_variables (struct cmd_correlations *cmd UNUSED)
86 struct variable **v1, **v2;
90 /* Ensure that this is a VARIABLES subcommand. */
91 if (!lex_match_id ("VARIABLES")
92 && (token != T_ID || dict_lookup_var (default_dict, tokid) != NULL)
97 if (!parse_variables (default_dict, &v1, &nv1,
98 PV_NO_DUPLICATE | PV_NUMERIC))
101 if (lex_match (T_WITH))
103 if (!parse_variables (default_dict, &v2, &nv2,
104 PV_NO_DUPLICATE | PV_NUMERIC))
116 cor = xmalloc (sizeof *cor);
123 cor_last = cor_last->next = cor;
125 cor_list = cor_last = cor;
131 cor_custom_matrix (struct cmd_correlations *cmd UNUSED)
133 if (!lex_force_match ('('))
140 matrix_file = fh_parse ();
141 if (matrix_file == NULL)
145 if (!lex_force_match (')'))
152 free_correlations_state (void)
154 struct cor_set *cor, *next;
156 for (cor = cor_list; cor != NULL; cor = next)
159 if (cor->v1 != cor->v2)