CHANGE command
See Crunch Automation basics for more information.
The CHANGE command allows you to change the title, notes, and description for a list of variable aliases. Additionally, it lets you set the labels of the subvariables on categorical arrays and dichotomous arrays via the CHANGE LABELS syntax. It is possible to modify only a subset of an array's subvariables using the SUBVARIABLES modifier, and when present, only one array can be altered.
See functions that operate on attributes to learn more.
CHANGE (NOTES|TITLE|DESCRIPTION) IN alias, ..., alias WITH ("string", ..., "string"|function());
CHANGE LABELS IN alias, ..., alias [SUBVARIABLES subvariable_code, ..., subvariable_code|function()] WITH ("string", ..., "string"|function());
CHANGE (NOTES|TITLE|DESCRIPTION) IN alias, ..., alias FROM alias, ..., alias;
CHANGE (NOTES|TITLE|DESCRIPTION)
SET "string" ON alias, ..., alias
...
SET "string" ON alias, ..., alias;Examples
When applying changes to multiple variables, the WITH syntax requires the same number of labels as variables being updated. If you would like to set multiple variables to have the same text, you can use the following syntax WITH REPEAT("Updated text"). If that is not included, the command will only update the first variable it finds.
# Overwrite variables' titles with their descriptions.
CHANGE TITLE IN ALL() WITH COPY(DESCRIPTION);
CHANGE TITLE IN q1...q10 WITH COPY(DESCRIPTION);
CHANGE TITLE IN Age WITH "Respondent Age";
CHANGE DESCRIPTION
SET "Main variables" ON q1...q5
SET "subvariables" ON q6...q10;
CHANGE DESCRIPTION IN var1, var2 WITH LIKE_REPLACE(DESCRIPTION, "Remove me", "Changed");
CHANGE DESCRIPTION IN var1, var2 WITH LIKE_REPLACE(DESCRIPTION, "%begin", "begin");
CHANGE DESCRIPTION IN var1, var2 WITH REGEX_REPLACE(DESCRIPTION, "[abc]", "+");
CHANGE DESCRIPTION IN var1, var2 WITH REGEX_REPLACE(DESCRIPTION, "last.*", "last");
# Overwrite variables' descriptions/notes with the same text.
CHANGE DESCRIPTION IN ALL() WITH REPEAT("Same Description for All");
CHANGE DESCRIPTION IN var1,var2,var3 WITH REPEAT("Updated Description");
CHANGE NOTES SET "System variables" ON random,pk,starttime;
CHANGE NOTES ON var1, var2 FROM var3, va4;
CHANGE DESCRIPTION ON var5, var6 FROM var7, var8;
CHANGE LABELS IN array1...array5 WITH "Like", "Neutral", "Dislike";
CHANGE LABELS IN array1, array2 WITH REMOVE_COMMON_SUFFIX();
CHANGE LABELS IN array1, array2 WITH REGEX_REPLACE("A (\d)", "\1 A");