## how to generate list of combinations of income, state and age group

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

nonstop5000
Posts: 2
Joined: Fri Apr 08, 2016 8:14 pm

### how to generate list of combinations of income, state and age group

I have three variables: income (with 5 possible values); state (with 50 possible values), and age group (with 7 possible values).

5x50x7 = 1,750 so this means there are 1,750 possible combinations of these variables.

I need to create a list of all 1,750 of these possible combinations. For example:

incomegroup #1 "<\$10,000/year", state #1 ("Alabama"), agegroup #1 (age 0-9)
incomegroup #1 "<\$10,000/year", state #1 ("Alabama"), agegroup #2 (age 10-19)
incomegroup #1 "<\$10,000/year", state #1 ("Alabama"), agegroup #3 (age 20-29)
incomegroup #1 "<\$10,000/year", state #1 ("Alabama"), agegroup #4 (age 30-39)
incomegroup #1 "<\$10,000/year", state #1 ("Alabama"), agegroup #5 (age 40 or older)

incomegroup #1 "<\$10,000/year", state #1 ("Alaska"), agegroup #1 (age 0-9)
incomegroup #1 "<\$10,000/year", state #1 ("Alaska"), agegroup #2 (age 10-19)
incomegroup #1 "<\$10,000/year", state #1 ("Alaska"), agegroup #3 (age 20-29)
incomegroup #1 "<\$10,000/year", state #1 ("Alaska"), agegroup #4 (age 30-39)
incomegroup #1 "<\$10,000/year", state #1 ("Alaska"), agegroup #5 (age 40 or older)

incomegroup #1 "<\$10,000/year", state #1 ("Arizona"), agegroup #1 (age 0-9)
incomegroup #1 "<\$10,000/year", state #1 ("Arizona"), agegroup #2 (age 10-19)
incomegroup #1 "<\$10,000/year", state #1 ("Arizona"), agegroup #3 (age 20-29)
incomegroup #1 "<\$10,000/year", state #1 ("Arizona"), agegroup #4 (age 30-39)
etc etc etc until the last (#1750) possible combination.

Is there a way to do this using a macro in SPSS? A macro of some sort with looping.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

### Re: how to generate list of combinations of income, state and age group

Simple solution:

1. Recode incomegroup, state and agegroup into numeric values (if it is not already numeric).
2. assuming they are all numeric:

Code: Select all

``````compute combined = ((incomegroup * 1000 ) + (state*10) + agegroup).
execute.
``````
3. if you want them in order, just use the automatic recode variable again.
nonstop5000
Posts: 2
Joined: Fri Apr 08, 2016 8:14 pm

### Re: how to generate list of combinations of income, state and age group

Thank you for your response.

Perhaps I should clarify: I am starting with no data collected yet. Eventually when I begin collecting data for the survey, I will have a dataset of responses but not yet. So there is no data in the dataset against which "compute" would execute.

My objective as described in the original post is to create a list which displays every possible combination of the values of these three variables. The generated list will have 1,750 rows because there are 1,750 possible combinations of these three variables.

"compute" is for the purpose of creating a new variable. In your code, it would calculate the product (mutliplication) of the three variables. But since the dataset currently has no values, the outcome of "compute" is zero. Also, if I do the survey and only get 50 responses then "compute" will only generate 50 values -- not the list of 1,750 possible combinations which I am trying to see.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

### Re: how to generate list of combinations of income, state and age group

okay to be honest I would do this in excel in like five minutes and then open it in spss. Be patient for an answer involving only spss.

### Who is online

Users browsing this forum: No registered users and 2 guests