1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2021 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU 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, see <http://www.gnu.org/licenses/>. */
19 #include "language/command.h"
20 #include "language/lexer/lexer.h"
21 #include "libpspp/hmap.h"
22 #include "libpspp/message.h"
23 #include "output/pivot-table.h"
25 #include "gl/xalloc.h"
28 #define _(msgid) gettext (msgid)
32 struct pivot_table_look *look;
34 /* If this is NULL, zeros are displayed using the normal print format.
35 Otherwise, this string is displayed. */
38 /* If this is NULL, missing values are displayed using the normal print
39 format. Otherwise, this string is displayed. */
42 /* Contains "struct ctables_vlabel" structs. */
45 bool mrsets_count_duplicates; /* MRSETS. */
46 bool smissing_listwise; /* SMISSING. */
47 struct variable *base_weight; /* WEIGHT. */
48 double hide_threshold; /* HIDESMALLCOUNTS. */
50 struct ctables_table *tables;
56 struct hmap_node hmap_node; /* In struct ctables's 'vlabels' hmap. */
57 const char *name; /* Variable name. */
59 /* SETTINGS_VALUE_SHOW_DEFAULT is interpreted as "none". */
60 enum settings_value_show show;
63 struct ctables_postcompute
65 struct hmap_node hmap_node; /* In struct ctables's 'pcompute' hmap. */
66 const char *name; /* Name, without leading &. */
68 struct ctables_postcompute_expr *expr;
71 bool hide_source_cats;
74 struct ctables_postcompute_expr
76 enum ctables_postcompute_op
84 /* XXX SUBTOTAL and HSUBTOTAL */
97 /* CTPO_CAT_NUMBER, CTPO_NUMBER. */
102 XXX what about string ranges? */
105 double low; /* -DBL_MAX for LO. */
106 double high; /* DBL_MAX for HIGH. */
110 /* CTPO_ADD, CTPO_SUB, CTPO_MUL, CTPO_DIV, CTPO_POW. */
111 struct ctables_postcompute_expr *subs[2];
117 struct ctables_axis *axes[PIVOT_N_AXES];
143 struct variable *var;
148 struct ctables_summary *summaries;
153 struct ctables_axis *subs[2];
157 struct ctables_summary
159 enum ctables_summary_function
167 CTSF_SUBTABLEPCT_COUNT,
169 CTSF_LAYERROWPCT_COUNT,
170 CTSF_LAYERCOLPCT_COUNT,
173 CTSF_TABLEPCT_VALIDN,
174 CTSF_SUBTABLEPCT_VALIDN,
175 CTSF_LAYERPCT_VALIDN,
176 CTSF_LAYERROWPCT_VALIDN,
177 CTSF_LAYERCOLPCT_VALIDN,
180 CTSF_TABLEPCT_TOTALN,
181 CTSF_SUBTABLEPCT_TOTALN,
182 CTSF_LAYERPCT_TOTALN,
183 CTSF_LAYERROWPCT_TOTALN,
184 CTSF_LAYERCOLPCT_TOTALN,
186 /* Scale variables, totals, and subtotals. */
206 CTSF_SUBTABLEPCT_SUM,
208 CTSF_LAYERROWPCT_SUM,
209 CTSF_LAYERCOLPCT_SUM,
211 /* Multiple response sets. */
212 CTSF_ROWPCT_RESPONSES,
213 CTSF_COLPCT_RESPONSES,
214 CTSF_TABLEPCT_RESPONSES,
215 CTSF_SUBTABLEPCT_RESPONSES,
216 CTSF_LAYERPCT_RESPONSES,
217 CTSF_LAYERROWPCT_RESPONSES,
218 CTSF_LAYERCOLPCT_RESPONSES,
219 CTSF_ROWPCT_RESPONSES_COUNT,
220 CTSF_COLPCT_RESPONSES_COUNT,
221 CTSF_TABLEPCT_RESPONSES_COUNT,
222 CTSF_SUBTABLEPCT_RESPONSES_COUNT,
223 CTSF_LAYERPCT_RESPONSES_COUNT,
224 CTSF_LAYERROWPCT_RESPONSES_COUNT,
225 CTSF_LAYERCOLPCT_RESPONSES_COUNT,
226 CTSF_ROWPCT_COUNT_RESPONSES,
227 CTSF_COLPCT_COUNT_RESPONSES,
228 CTSF_TABLEPCT_COUNT_RESPONSES,
229 CTSF_SUBTABLEPCT_COUNT_RESPONSES,
230 CTSF_LAYERPCT_COUNT_RESPONSES,
231 CTSF_LAYERROWPCT_COUNT_RESPONSES,
232 CTSF_LAYERCOLPCT_COUNT_RESPONSES,
237 struct fmt_spec format; /* XXX extra CTABLES formats */
241 cmd_ctables (struct lexer *lexer, struct dataset *ds)