Helping creating new variable from others

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

karen_g
Posts: 2
Joined: Mon Jan 18, 2016 4:36 pm

Helping creating new variable from others

Postby karen_g » Mon Jan 18, 2016 4:49 pm

Hi there,

I'm having trouble creating a new variable from others. Basically my survey had skip patterns and so had agreement statements that hours of operation were convenient at 9 different locations. These variables are all mutually exclusive (i.e. each respondent answers question for 1 location only). I want to create a single variable that merges the data from each of these 9 variables. I have tried compute (var1+var2+var3. etc.) but I seem to end up with all missing values this way. Help please!
Erikyo
Posts: 28
Joined: Mon Mar 30, 2009 8:20 pm

Re: Helping creating new variable from others

Postby Erikyo » Mon Jan 18, 2016 6:15 pm

Hi,

I know that the "+" command doesn't do the job !

Try with SUM !

For example : SUM (var1, var2, var3).
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Helping creating new variable from others

Postby GerineL » Tue Jan 19, 2016 9:28 am

Sum also doesn't work.
You could do this:

Code: Select all

compute sum = mean (v1,v2,v3,v4,v5,v6,v7,v8,v9) * 9.
execute.
alternatively, you can set the missing values to 0 and compute a sum with those included.
Whether either of these methods make sense for your data is not possible for me to determine without knowing more about your data.
karen_g
Posts: 2
Joined: Mon Jan 18, 2016 4:36 pm

Re: Helping creating new variable from others

Postby karen_g » Wed Jan 20, 2016 8:00 pm

Thank you so much, GerineL! That code (without the *9) did exactly what I had been hoping. Appreciate it!

Who is online

Users browsing this forum: No registered users and 1 guest

cron