See Crunch Automation basics for more information.
When you create new variables based on existing dataset variables or other computed variables using Crunch Automation or the Crunch application, they are stored as a “formula” that expresses the logic you describe. The MATERIALIZE command evaluates computed expressions, such as case statements or recodes, and saves the values to the dataset. The result no longer depends on the input variables and will not change if the inputs or their data are changed or updated.
This MATERIALIZE command will not raise an error, but will not change anything if the variables mentioned are already material.
In general, Crunch recommends that data processing teams materialize the transformations and calculated variables that they create, so that they can be certain that the values will not change due to any upstream dependency in the logic they express. Materialization may be required to align datasets to ensure that variable schemas are compatible.
MATERIALIZE VARIABLES alias, ..., alias;
As elsewhere, the alias list may use convenience functions such as numeric sequence expansion with ..., string matching functions such as startswith and all().
CREATE NUMERIC 2022 - birthyr AS age; CREATE CATGORICAL CUT as age4 BREAKS MIN, 30, 45, 65, MAX LABELS "Under 30" CODE 1, "30–44" CODE 2, "45–64" CODE 3, "65+" CODE 4 AS age4; MATERIALIZE VARIABLES birthyr; # no effect; data is collected as birthyr. MATERIALIZE VARIABLES age; # age4 still depends on age, but no longer on birthyr MATERIALIZE VARIABLES age4;