Creating a new variable depending on several other variables

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

abans
Posts: 3
Joined: Fri Oct 25, 2013 1:09 pm

Creating a new variable depending on several other variables

Postby abans » Fri Oct 25, 2013 1:57 pm

Dear all,

I want to create a new variable which forms itself out of the answers from 14 other variables.
Basically I want to know: How many times people answered 14 with "yes", how many 13 times and so on.
So I guess I have to form a new variable with 14 labels.

I found out how to create a new variable out another, but not out of several others.

Would be so great if somebody can help - with this new data I could so much more!
Unfortunately I am not familiar with syntax, so it would be great if you can help me with some menu - commands.

Thank you in advance, sheers,

Franziska
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Creating a new variable depending on several other varia

Postby GerineL » Fri Oct 25, 2013 2:15 pm

so if I understand correctly, you have a number of cases (lines), and you want to know how many of those cases answered a certain variable with "yes", correct?

What you could do is recode your 14 variables into new variables that have a 1 if they answered with "yes".
then use aggregate to create a sum score for each of these variables.

if this is not what you need, please give more details about what it is you want.
abans
Posts: 3
Joined: Fri Oct 25, 2013 1:09 pm

Re: Creating a new variable depending on several other varia

Postby abans » Fri Oct 25, 2013 3:23 pm

Sorry, I wasn't precise enough :/

I don't want to know how many people answered "yes" for a certain question but how many questions a certain person answered with yes.

It's a question about environmental activities in companies - I want to have a new variable, which indicates the number of "green" activities in each company.

RIght now the variables are coded like this:
[Question: Is the measure xx applied in your company?] [xx= 1,...,14]
1 = yes
2 = no
8 = prefer not to say
9 = I don't know

I would like to have a new variable looking like that
[How many measures are applied in this company?]
0 = 0
1 = 1
2 = 3
...
14 = 14

In this way I could examine later on if there is a connection with amount of measures and other variables.

Maybe you already gave me the right answer and I wasn't able to aggregate correct. But I ended up with the total numbers of "yes", not separated by samples. Thank you for the help!
pythonforspss.org
Posts: 116
Joined: Sat Oct 06, 2012 6:21 am

Re: Creating a new variable depending on several other varia

Postby pythonforspss.org » Sat Oct 26, 2013 5:04 am

First and foremost, start working from syntax. See http://www.spss-tutorials.com/the-six-g ... ss-syntax/.

Second, use the COUNT function like so:

Code: Select all

COUNT number_of_green_choices = v1 to v14 (1).
exe.
This will count how many times each case has a '1' across variables v1 through v14. The new variable (holding values from 0 through 14) is called 'number_of_green_choices' in this case.
Kind regards,

Ruben Geert van den Berg
http://www.spss-tutorials.com
abans
Posts: 3
Joined: Fri Oct 25, 2013 1:09 pm

Re: Creating a new variable depending on several other varia

Postby abans » Sat Oct 26, 2013 1:41 pm

It works! Thank you!

Is there an overview for syntax commands for recoding variables that you can recommend?
It seems it saves a lot of time, especially if it is some repeating code.

Who is online

Users browsing this forum: No registered users and 1 guest

cron