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 "file-handle.h"
29 #include "debug-print.h"
34 struct variable **v1, **v2;
38 struct cor_set *cor_list, *cor_last;
40 struct file_handle *matrix_file;
42 static void free_correlations_state (void);
43 static int internal_cmd_correlations (void);
46 cmd_correlations (void)
48 int result = internal_cmd_correlations ();
49 free_correlations_state ();
54 "CORRELATIONS" (cor_):
56 +missing=miss:!pairwise/listwise,
58 +print=tail:!twotail/onetail,
60 +format=fmt:!matrix/serial;
62 +statistics[st_]=descriptives,xprod,all.
68 internal_cmd_correlations (void)
70 struct cmd_correlations cmd;
72 cor_list = cor_last = NULL;
75 lex_match_id ("PEARSON");
76 lex_match_id ("CORRELATIONS");
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") && (token != T_ID || !is_varname (tokid))
98 if (!parse_variables (&default_dict, &v1, &nv1,
99 PV_NO_DUPLICATE | PV_NUMERIC))
102 if (lex_match (T_WITH))
104 if (!parse_variables (&default_dict, &v2, &nv2,
105 PV_NO_DUPLICATE | PV_NUMERIC))
117 cor = xmalloc (sizeof *cor);
124 cor_last = cor_last->next = cor;
126 cor_list = cor_last = cor;
132 cor_custom_matrix (struct cmd_correlations *cmd unused)
134 if (!lex_force_match ('('))
138 matrix_file = inline_file;
140 matrix_file = fh_parse_file_handle ();
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)