Beginner: New Variables

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

Posts: 6
Joined: Thu Jul 23, 2015 6:03 pm

Beginner: New Variables

Postby MeganD » Tue Sep 15, 2015 5:09 pm

I am a new SPSS user (previously used STATA). I am working with a survey that was deployed online using survey monkey, which is great because survey monkey can export directly into SPSS. I had questions in the survey that were "select all that apply" and Survey monkey has exported them all as dichotomous variables with 1 or 0 for each option (so for one question I have upwards of 10 variables). Is there an easy way to make categorical variables from these dichotomous variables I have now? I have attached an example of the dataset for further clarification. Ideally I would like five "Q5" variables with the different possible responses as categories.
You do not have the required permissions to view the files attached to this post.
Posts: 117
Joined: Wed May 25, 2011 7:07 am

Re: Beginner: New Variables

Postby JonPedersen » Thu Sep 17, 2015 7:09 am

One way to do it is to use a macro. A relatively simple minded version is the following code:

Code: Select all

 variable labels !NEWVAR !LAB .
 value labels !NEWVAR 1 "Inpatient" 2 "Outpatient" 3 "Both inpatient and outpatient"
   4 "No answer". 

MAKEONE PREFIX=q0005_0001_000 NEWVAR=Substance LAB="Substance use disorders".
MAKEONE PREFIX=q0005_0002_000 NEWVAR=Mental LAB "Mental disorders".
freq Substance mental.
The code assumes that all of your variables follow the same pattern, but should be easy to change for other patterns.You execute the macro definition once, and then the macro for each variable group. I have illustrated with the two first in your example file. (One can also make the whole thing in one go, making a loop for the variable group number, but if one wants to make it super-fancy it is probably better to use Python because you can then pick up the variable lables more eaisly).
Posts: 6
Joined: Thu Jul 23, 2015 6:03 pm

Re: Beginner: New Variables

Postby MeganD » Fri Sep 25, 2015 1:21 pm

Will this work for a response that may have selected more than one answer option?

Who is online

Users browsing this forum: No registered users and 1 guest