## Again - Combining Multiple Variables into One

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

Lars
Posts: 2
Joined: Fri Jul 11, 2008 5:17 pm

### Again - Combining Multiple Variables into One

Ok, I know this has been covered, but I can't seem to make it work. I have some multiple choice data where each response was coded into a separate variable. I need to get them combined into one variable. Each response was coded as 1 or blank. I've tried the following syntax without success. WU1 is the "new" variable I need to create and V14-V20 are the existing variables... I think you can see what I was trying to do here.

Code: Select all

``````compute WU1=V14
IF (V15=1) WU1=2
IF (v16=1) WU1=3
IF (V17=1) WU1=4
IF (V18=1) WU1=5
IF (V19=1) WU1=6
IF (V20=1) WU1=7.

``````
statman
Posts: 2700
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA
Nope but!

If you had 4 variables v1 to v4 that might be labeled as car1, car2, to car4 and if I have car1 & car3 then there is a '1' noted else blank the do your multiple response with dichotomies and count variable = 1

OK?
See the note below

Statman
Statistical Services
Lars
Posts: 2
Joined: Fri Jul 11, 2008 5:17 pm
Hmm... let me try again

I have 4 variables lets call them V1-V4. They are the response options for one multiple choice question, so one person would only recieve a "1" for one of the 4 variables. The other three variables would be blank. What I'd like to be able to do is recode these 4 variables into 1 variable. The trick to it is if the person has a 1 for V1, I'd like it to appear in the new variable as a 1. But, if they have a 1 for V2 it would need to be recoded as a 2, V3 as a 3, V4 as a 4 and so on. I think I found a way around it by recoding the variables first, and then using the following syntax:

Code: Select all

``COMPUTE WU1=MAX(V1A, V1B, V1C, V1D).``

### Who is online

Users browsing this forum: No registered users and 1 guest