See Getting started with dashboard commands for more information.
<Analysis type> FOR <variable alias> [hide, rename, sort/order, color, etc.] BY <variable alias> [hide, rename, sort/order, color, etc.] (TABBED BY <variable alias>)? [FILTERED BY "public filter name" | filter_value(<alias>,value)] [WEIGHTED BY <weight alias>] [INCLUDE EMPTY] <display> [display options vary for tables, graphs, etc.]
In general, analyses are aggregations over rows of the underlying data, optionally weighted and filtered. The most common aggregation is weighted counts described as either a frequency (for one variable) or a crosstab for two or three variables. The counts can be displayed as they are or as percentages, in a table or a graph. Finally, numeric summary will return numeric aggregations such as mean, standard deviation, and sum, in addition to underlying valid counts, for numeric variables, numeric arrays, as well as categorical scales and categorical arrays, based on the “scale value” assigned to each category.
Array variables present their “subvariables” together to facilitate comparisons. Multiple response variables can present some challenges as they have some features of categories and others shared with arrays, discussed in the second below on identifying dimensions and applying any relevant transformations.
Analyses (aggregations) vary mainly in terms of the number of variables or dimensions involved, up to three. Most variables have a so-called dimension consisting of their categories.
Array variables are referred to by their alias first, and carry a special "SUBVARIABLES" name which is used to hide, rename, color, or sort the items along the "subvariables" axis rather than categories (for a categorical array). Numeric arrays also have a subvariables axis to provide the same element transformations.
This is the workhorse of dashboard analysis tiles. One-way frequencies (optionally weighted and filtered) describe the distribution of most variables in Crunch, either categorical or multiple response.
Use case 1
TILE "fav pet" WIDTH 2 HEIGHT 3 # using each of these options. FREQUENCY FOR x FREQUENCY FOR x DISPLAY DONUT VALUE COUNT FREQUENCY FOR x DISPLAY TABLE
These options each would result in the following:
The one-way frequency for a categorical variable or multiple-response variable is shown as percentages in a vertical bar plot (categories are mapped to the x axis, values to y). Other available displays are AS HORIZONTAL BARS, DONUT, or TABLE.
The VALUES keyword selects a measure that is bound to the values displayed (either the bar value or table cell values). Available measures are only COUNT and PERCENTS.
A crosstab (another name for a contingency table) shows the conditional counts in cells defined by two dimensions, "rows" and "columns". The rows variable is typically the primary variable of interest, sometimes called the dependent variable, while the columns variable is the explanatory or "independent" variable. Typically, columns are demographic or segmentation variables, or period or geography variables such as wave and country. Crosstabs display grouped vertical bar plots by default.
Use case 2
CROSSTAB FOR x BY education CROSSTAB FOR x BY country
As with frequencies, crosstabs can be displayed as horizontal or vertical bars, or as a time plot if the BY variable has dates associated with its categories, or is a binned "rolled-up" datetime variable. (We recommend whenever possible to use categorical variables to represent survey waves.)
Use case 3
CROSSTAB FOR x BY wave DISPLAY AS TIMEPLOT VALUES COL PERCENT
When used with a categorical array variable as the first (rows) variable in a crosstab, you must indicate a category to ‘select’. The application will display the result with the categories as ‘tabs’ and the items or ‘subvariables’ of the array as the rows, crossed by your column variable.
Crossed by Country
Requires 'select' to indicate which category you’re comparing for each item in the array. You could also think of it as selecting the numerator in a percentage where all valid categories comprise the base for each item.
This allows you to select categories of an array to collapse its categories dimension, showing each subvariable as a dichotomous selection (as if it were multiple response). This is useful for presenting comparisons between subvariables, selecting similar categories such as “Somewhat agree” and “Strongly agree” to present a summary view of agreement with a series of statements.
Occasionally it is useful to add a third layer to tables or displayed values. In dashboards this is presented as a dropdown menu; in the web application it is a series of tabs across the top of the table. For such a three-way table the dropdown or tabs represent a ‘slice’ or a quick way to filter the table or graph. To add this type of filtering control indicate that the analysis is a tabbed crosstab, and then add a TABBED BY <alias> dimension after rows and columns.
Use case 4
TABBED CROSSTAB FOR x BY wave TABBED BY country
To work with arrays, both categorical or numeric, the array keyword is added to indicate that the aggregation is to be done for each subvariable, and allows you to position the categories or values of the results as rows or columns by referring to keywords ‘subvariables’ or ‘categories’.
- FREQUENCY ARRAY — the one-way frequency of each subvariable. These are commonly shown as tables or a series of stacked bars because each one sums to 100%. By default, if you specify just the frequency array, the system would present categories in a row, with a row for each item or subvariable in the array. To reverse this, you can swap the keywords `categories by subvariables` to line up each item in a series of columns, with their categories as rows.
- CROSSTAB ARRAY — cross each subvariable by another variable, to show breakdowns of each subvariable by the other crossing variable. This presents subvariables as tabs by default, showing the categories of each split by your other variable as columns. To compare items in the array, you may want to use SELECT on the array with a regular crosstab to present a simplified (dichotomized) comparison between items.
- TABBED FREQUENCY ARRAY — display the subvariables and categories of an array for each where your other variable is acts equivalently to a filter.
- FUSED SCORECARD — Show several multiple response variables side-by-side where they share a set of subvariables. This can show a ‘grid’ of multiple-response items and attributes together. Currently, such scorecards are only displayed as tables. Here, FOR takes a list of the multiple-response variables. Their item or subvariable labels will be matched using exact string matching.
All analyses must include their own filter and weight; there is no global or tab-level setting (filter, weight, and include empty):
- FILTERED BY — Allows you to indicate a FILTER_NAME(string) or FILTER_VALUE(variable, values) to indicate a filter to use.
- WEIGHTED BY <alias> — Requires a numeric variable alias to assign the filter to use.
- INCLUDE EMPTY — Prior to transforming elements, this removes rows or columns that are "empty", meaning that they have 0 marginal base.
'Groups' dynamic filters
dashboard groups — GROUPS MULTI? VARIABLES <comma separated aliases>.
- Allows you to configure the left sidebar filters. The optional MULTI keyword means that for each group you can pick multiple choices instead of just one.
- The aliases indicated are limited to categorical or multiple responses.