CREATE CATEGORICAL ARRAY CASE command
See Crunch Automation basics for more information.
The CREATE CATEGORICAL ARRAY CASE command allows you to create a new array variable based on a number of conditions similar to a CASE variable.
All expressions MUST evaluate to boolean conditions, and all must result in arrays of the same number of subvariables as the input.
CREATE CATEGORICAL ARRAY CASE FROM alias,...,alias
WHEN expression THEN "label" CODE int [NUMERIC VALUE <float>] [MISSING]
...
WHEN expression THEN label" CODE int [NUMERIC VALUE <float>] [MISSING]
END
AS alias, ..., alias
[TITLE "string", ..., "string"| function]
[DESCRIPTION "string", ..., "string" | function]
[NOTES "string", ..., "string" | function];
Example
Building on the example from command CREATE CATEGORICAL ARRAY recode "Less often" as missing.
CREATE CATEGORICAL ARRAY CASE
FROM sns2_cat
WHEN (sns2_cat = 5) THEN "Recoded" CODE 0 MISSING
END
TITLE "Frequency of Social Media (recoded)"
AS sns2_cat_recoded;