Creating a grouping variable

#1
I am trying to create a grouping variable (1, 2, 3, or 4) from the median split of two other variables (job and life satisfaction). So the new variable will be a 1 if life is above 16 and job is above 19, a 2 if both are below, a 3 if life is above and job is below, and a 4 if life is below and job is above.


I haven't been able to figure out how to write the compute new variable in SPSS or even how to write an IF function in excel to create the new grouping variable. I'm sure it's something easy, but I am drawing a blank. Any help is appreciated.


Thank you,


Andy
 
#3
In SPSS 15 (and other recent versions), the Recode command is actually under the Transform menu. Make sure you "Recode into different variables" instead of "Recode into the same variables" so that you can preserve your original data. You will create the name of an Output variable (this is your new grouped variable) and use the Old and New Values button to specify the old and new values.

However, if I am reading your question correctly, it sounds to me like you should not use Recode if you are grouping based on 2 variables. In this case, you should go to the Data menu, click Select Cases, and then choose If. This allows you to select cases if, for example, job > or = 16 & life > or = 19. Use & to include values on 2 variables. This doesn't create a grouping variable per se, but it creates a filter so that only those cases that meet the criteria are used in a given analysis. When you want all the data, just go back into the select cases menu and choose "All Cases."

Good luck.
 

mp83

TS Contributor
#4
Right it's under Transform (I don't have SPSS installed on my PC after a recent format).

I would recommend creating this indicator variables (and then use the filter depending on their value) though as it will save you time when you decide to run the analysis again (I'd bet on that!).
 
#5
What I ended up doing, in case anyone is interested or if anyone has had a similar issue, is using the if function in excel (twice).

I copied my two columns of data into excel. Then created four if function columns, one for job > 19, one for life > 16, one for job <= 19, and one for life <= 16. Now I have four columns for each pair of data with two ones and two zeros in each column depending on the original value in the data.

Next I made four more columns of if functions. The first one represented the high/high condition where those two columns added together to equal 2 (here the true condition was represented by a 1. The second one represented the low/low condition where those two columns added together to equal 2 (here the true condition was represented by a 2). Hopefully the pattern is clear at this point. The result of these four columns is that if the data represent the high/high condition, then there is a 1 in the first of these four columns and the rest are zeros. If the data represent the low/low condition, then there is a 2 in the second of these four columns, etc.

Finally I did a sum function with the end result being one column with either a 1, 2, 3, or 4 (where the 1 is the high/high, 2 is the low/low, 3 is the high/low, and 4 is the low/high. Now I have my grouping variable in one column and can run a discriminant analysis.

I'm sure there was an easier way, but this is how I did it.

Andy