See Crunch Automation basics for more information.
The CREATE CATEGORICAL INTERACTION command creates a new categorical variable with categories resulting from the cartesian product of the input categorical variables. For example, if you are creating an interaction of Gender (2 categories) and Age Group (4 categories), you would end up with 8 categories in the derived variable.
You need to specify either two or three input categorical variables and the output alias. In the web app, you can only interact two variables at a time. With Crunch Automation, you can interact up to three.
If you’re looking to combine categories and/or set categories to missing, you may prefer to use CREATE CATEGORICAL CASE instead of this command.
Optional arguments
The WITH argument allows you to combine categories in the process. For example, if you have 4 categories in an Age Group variable (“18-29”, “30-39”, “40-49”, and “50+”), you may only want two in the interaction (e.g., “Under 40” and “40+”). When interacting with Gender (2 categories), you would end up with 4 categories (rather than 8): (“Male Under 40”, “Male 40+”, “Female Under 40”, and “Female 40+”). This is illustrated in the following example:
CREATE CATEGORICAL INTERACTION alias_A, alias_B
[WITH
(code, ..., code) INTO "label" CODE code,
...
(code, ..., code) INTO "label" CODE code]
AS alias
[TITLE "string"]
[DESCRIPTION "string"]
[NOTES "string"];
Use case
The following example uses the 2019 Mobile Technology and Home Broadband 2019 example. We have the variables Gender and Age as per the following, and we want to make an interaction (perhaps to insert into a multitable):
CREATE CATEGORICAL INTERACTION Age, Gender
sex, age_3cat
AS gender_age
TITLE "Gender x Age";
The above script results in the following derived variable:
You can be more explicit with the scripting to define specific categories, as see in the following, which creates an interaction at three levels and thus uses 3 aliases (including the language of interview now):
CREATE CATEGORICAL INTERACTION
sex, age_3cat, lang
WITH
(1,1,1) INTO "Male 18-34 English" CODE 101,
(1,1,2) INTO "Male 18-34 Spanish" CODE 102,
(1,2,1) INTO "Male 35-49 English" CODE 103,
(1,2,2) INTO "Male 35-49 Spanish" CODE 104,
(1,3,1) INTO "Male 50+ English" CODE 105,
(1,3,2) INTO "Male 50+ Spanish" CODE 106,
(2,1,1) INTO "Female 18-34 English" CODE 107,
(2,1,2) INTO "Female 18-34 Spanish" CODE 108,
(2,2,1) INTO "Female 35-49 English" CODE 109,
(2,2,2) INTO "Female 35-49 Spanish" CODE 110,
(2,3,1) INTO "Female 50+ English" CODE 111,
(2,3,2) INTO "Female 50+ Spanish" CODE 112
AS gender_age_lang
TITLE "Gender x Age x Language";