## Combined selected variables HELP!

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

peacenowar1
Posts: 7
Joined: Wed May 23, 2012 1:32 pm

### Combined selected variables HELP!

Say I have 3 variable, those who like A, B and C for people to choose.

So I have A 1:Yes 2:No
B 1:Yes 2:No
C 1:Yes 2:No

where the variable is in numeric, 1 is labeled yes and 2 is labeled no

I can show individually the frequency of people choosing A, people choosing B and C.

My question is how do I make SPSS show the frequency of those who chose A & B at the same time, or those who chose A only without the B and C?
Thanks people~ Hope you guys can kindly help
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

### Re: Combined selected variables HELP!

By "of those who chose A & B at the same time, or those who chose A only without the B and C" do you mean:
1) having chosen "Yes"? OR
2) having chosen either "Yes" or "No" and not a missing?
peacenowar1
Posts: 7
Joined: Wed May 23, 2012 1:32 pm

### Re: Combined selected variables HELP!

Penguin_Knight wrote:By "of those who chose A & B at the same time, or those who chose A only without the B and C" do you mean:
1) having chosen "Yes"? OR
2) having chosen either "Yes" or "No" and not a missing?
Its 1)
They choose yes for A & B but no for C...
I assumed missing is = no
kirhill
Posts: 1
Joined: Thu May 24, 2012 3:10 am

### Re: Combined selected variables HELP!

I have a similar question about combining variables. I transformed my database such that I have one string or index variable and the second variable is the count of the index variable. For example, my index variable is an identification of the species I found, it is on the same row of variables that identify where and when those species were found. In the second variable (species count) is the list of the total number of that species I found for that case (and index variable). I would like to be able to combine these two separate variables into one so that for each count of a species I instead have one case. So if I had 2 ants listed on one row, instead of having one column that states that I have two ants, I would like to have two rows, one for each ant. Can you please tell me how I can do this other than to manually add in rows for each separate insect?

Basically, I want SPSS to recognize the total count and make one row each for the total number listed in each case of the index variable.
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

### Re: Combined selected variables HELP!

peacenowar1 wrote: Its 1)
They choose yes for A & B but no for C...
I assumed missing is = no
You may use Compute to make a new variable that is = 1 if both A & B are 1 and C = 0. For the second scenario, you can make a variable = 1 when A = 1 and B and C = 2. This syntax should do:

COMPUTE NewVar1 = (A = 1 & B = 1 & C = 2) .
COMPUTE NewVar2 = (A = 1 & B = 2 & C = 2) .
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

### Re: Combined selected variables HELP!

kirhill wrote:I have a similar question about combining variables. I transformed my database such that I have one string or index variable and the second variable is the count of the index variable. For example, my index variable is an identification of the species I found, it is on the same row of variables that identify where and when those species were found. In the second variable (species count) is the list of the total number of that species I found for that case (and index variable). I would like to be able to combine these two separate variables into one so that for each count of a species I instead have one case. So if I had 2 ants listed on one row, instead of having one column that states that I have two ants, I would like to have two rows, one for each ant. Can you please tell me how I can do this other than to manually add in rows for each separate insect?

Basically, I want SPSS to recognize the total count and make one row each for the total number listed in each case of the index variable.
In this case, you can simply use "Frequency Weight".

1) Go to Data > Weight Cases
2) Check "Weight Cases By"
3) From the menu, bring your count variable into the panel at the right hand side.
4) Click "OK".
5) Check if the lower right corner of SPSS says "Weight On", if so, you did that correctly.

From this point and on all your cases are weighted by frequency, your one row that has 2 ants will be treated as two cases. No real change to your data would be made, SPSS just does all the duplication in the background.

When you're done with it, you'll need to turn off this weight function:

1) Go to Data > Weight Cases
2) Check "Do Not Weight Cases"
3) Click "OK".
4) Check if the lower right corner of SPSS no longer says "Weight On".
peacenowar1
Posts: 7
Joined: Wed May 23, 2012 1:32 pm

### Re: Combined selected variables HELP!

Penguin_Knight wrote:
peacenowar1 wrote: Its 1)
They choose yes for A & B but no for C...
I assumed missing is = no
You may use Compute to make a new variable that is = 1 if both A & B are 1 and C = 0. For the second scenario, you can make a variable = 1 when A = 1 and B and C = 2. This syntax should do:

COMPUTE NewVar1 = (A = 1 & B = 1 & C = 2) .
COMPUTE NewVar2 = (A = 1 & B = 2 & C = 2) .
Thanks! work like a charm
peacenowar1
Posts: 7
Joined: Wed May 23, 2012 1:32 pm

### Re: Combined selected variables HELP!

Hi guys, the previous method really help me a lot. Sincerely thanks for that.

Now here comes another problem where I now have like 7 options A B C D E F G where the possibilities of choosing either or is much more with just 2 options A & B.

Now I would like to see how many people chose A only, B only, A + B without the rest, A + B +C without the rest etc etc.....(all possibilities available....
)
Is there any faster way to compute to get such a result?

many thanks again!
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

### Re: Combined selected variables HELP!

peacenowar1 wrote:Hi guys, the previous method really help me a lot. Sincerely thanks for that.

Now here comes another problem where I now have like 7 options A B C D E F G where the possibilities of choosing either or is much more with just 2 options A & B.

Now I would like to see how many people chose A only, B only, A + B without the rest, A + B +C without the rest etc etc.....(all possibilities available....
)
Is there any faster way to compute to get such a result?

many thanks again!
Compute a variable that is:
A*1000000 + B*100000 + C*10000 + D*1000 + E*100 + F*10 + G

Then run a frequency with it. Whoever only picked A will have a 1222222; B would be 2122222; A & B would then be 1122222, so on so forth.

### Who is online

Users browsing this forum: No registered users and 1 guest