Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Combine Two or More Categorical Variables into One in SPSS

56,888 views
Skip to first unread message

southernpsy

unread,
May 29, 2009, 2:08:48 PM5/29/09
to
I am an SPSS novice, and I found this group recently when I was trying
to determine how to combine two categorical into one variable in SPSS.
I did not find an answer online, but I did eventually figure out how
to do it. I decided to post it here to the benefit of others.

I had one variable for Sex (1: Male; 2: Female) and one variable for
Self-Identified Gender Expression (1: Masculine; 2: Equally or Neither
Masculine Nor Feminine; 3: Feminine). I wanted to be able to compare
Masculine Males, et cetera in post hoc analyses.

Here is a template of the syntax that worked for me:

IF ((var1 = 1) & (var2 = 1)) newvar= 1.
EXECUTE.
IF ((var1 = 1) & (var2 = 2)) newvar= 2.
EXECUTE.
IF ((var1 = 1) & (var2 = 3)) newvar= 3.
EXECUTE.
IF ((var1 = 2) & (var2 = 1)) newvar= 4.
EXECUTE.
IF ((var1 = 2) & (var2 = 2)) newvar= 5.
EXECUTE.
IF ((var1 = 2) & (var2 = 3)) newvar= 6.
EXECUTE.

Ben Pfaff

unread,
May 29, 2009, 2:22:08 PM5/29/09
to
southernpsy <dent...@gmail.com> writes:

> Here is a template of the syntax that worked for me:
>
> IF ((var1 = 1) & (var2 = 1)) newvar= 1.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 2)) newvar= 2.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 3)) newvar= 3.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 1)) newvar= 4.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 2)) newvar= 5.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 3)) newvar= 6.
> EXECUTE.

You don't need all those EXECUTE commands. One at the end, at
most, should be enough.

If you know that var1 is always 1 or 2 (or missing) and var2 is
always 1, 2, or 3 (or missing), this is equivalent:

COMPUTE newvar = (var1 - 1) * 3 + (var2 - 1) + 1.
EXECUTE.

If you don't know that:

DO IF ANY(var1, 1, 2) AND ANY(var2, 4, 5, 6).
COMPUTE newvar = (var1 - 1) * 3 + (var2 - 1) + 1.
END IF.
EXECUTE.

In each case, again, the EXECUTE is probably not needed.
--
Ben Pfaff
http://benpfaff.org

bonn...@careercouture.com.au

unread,
Dec 4, 2012, 2:40:33 AM12/4/12
to
Thank you for sharing! This was really helpful!!!

claire...@gmail.com

unread,
May 29, 2013, 8:28:00 AM5/29/13
to
Op vrijdag 29 mei 2009 20:08:48 UTC+2 schreef southernpsy het volgende:
thank you very much for sharing, I was trying for hours and it's finally done! TXS :D!!!!

dang...@dangerousenterprises.com

unread,
May 30, 2013, 12:24:05 AM5/30/13
to
When writing code, my primary concern is clarity of expression. For that reason, I tend to prefer Southernpsy's style. Ben's version is more concise, but I find it less obvious.

An alternative would be to consider using the DO IF command and formatting the code with some indentation, like this:


DO IF (var1 = 1).
IF (var2 = 1) newvar = 1.
IF (var2 = 2) newvar = 2.
IF (var2 = 3) newvar = 3.
ELSE IF (var1 = 2).
IF (var2 = 1) newvar = 4.
IF (var2 = 2) newvar = 5.
IF (var2 = 3) newvar = 6.
END IF.


As Ben points out, you only need one EXECUTE, and even that is not really required.

Welcome to the world of SPSS, Southernpsy. Have fun!


Regards,

Paul Cook
http://dangerousenterprises.com

Rich Ulrich

unread,
May 30, 2013, 1:24:16 AM5/30/13
to
On Wed, 29 May 2013 21:24:05 -0700 (PDT),
dang...@dangerousenterprises.com wrote:

>When writing code, my primary concern is clarity of expression. For that reason, I tend to prefer Southernpsy's style. Ben's version is more concise, but I find it less obvious.
>
>An alternative would be to consider using the DO IF command and formatting the code with some indentation, like this:
>
>
>DO IF (var1 = 1).
> IF (var2 = 1) newvar = 1.
> IF (var2 = 2) newvar = 2.
> IF (var2 = 3) newvar = 3.
>ELSE IF (var1 = 2).
> IF (var2 = 1) newvar = 4.
> IF (var2 = 2) newvar = 5.
> IF (var2 = 3) newvar = 6.
>END IF.
>
>
>As Ben points out, you only need one EXECUTE, and even that is not really required.
>

When you know that there are only valid values, it is safe
and concise to write

COMPUTE newvar= 3*(var1-1) + var2.

It is less concise, but also safe (and it has useful variations)
to write

COMPUTE newvar= 10*var1 + var2.
RECODE newvar(11=1)(12=2)(13=3)(21=4)(22=5)(23=6)(ELSE= 0)

--
Rich Ulrich

Art Kendall

unread,
May 30, 2013, 8:43:08 AM5/30/13
to
vertical alignment also help clarity. Vertical alignment does not do
much in this small example but a fixed font and a few extra blank spaces
can often help readability

YMMV but over the years I have found that many people find the
conventional operators clearer than the symbolic operators. The one
that seems to cause the most confusion is that equal sign can be both a
logical operator and an assignment operator.
DO IF (var1 = 1).
IF (var2 eq 1) newvar = 1.
IF (var2 eq 2) newvar = 2.
IF (var2 eq 3) newvar = 3.
ELSE IF (var1 eq 2).
IF (var2 eq 1) newvar = 4.
IF (var2 eq 2) newvar = 5.
IF (var2 eq 3) newvar = 6.
ELSE.
COMPUTE newvar = -1.
END IF.
MISSING VALUES newvar(-1).
VALUE LABELS newvar
-1 'not assigned'
1 ' . . .

providing an ELSE command checks the completeness of your logic, and
avoids falsely assigned sysmis values.
A good rule of thumb for QA is that syntax should be elaborated until it
does not produce any sysmis values. I.E., that the syntax give no
instructions that the computer is unable to follow.

Art Kendall
Social Research Consultants

adolf...@gmail.com

unread,
Dec 14, 2013, 5:42:54 PM12/14/13
to
Just wanted to thank you! this is from a long time ago and it just helped me a bunch!

rezvan.ab...@gmail.com

unread,
Dec 20, 2013, 9:20:10 AM12/20/13
to
Very useful, Thank you very much

herr...@gmail.com

unread,
Jan 8, 2014, 12:52:51 PM1/8/14
to
i second that. thanks a lot guys.. just read hours through german statistics boards. your posts were the first ones that did not go miles into ops specific problems with one case.

greetings

Art Kendall

unread,
Jan 8, 2014, 4:44:39 PM1/8/14
to
depending on what type of analysis you plan, consider crossing the two
variables, e.g., in anova, regression, etc.

Art Kendall
Social Research Consultants

research

unread,
Jan 15, 2014, 6:44:32 AM1/15/14
to
I have a question on similar, but different grounds.

There are 7 different variables in our survey: 1)contacted a politician, government, or local government official?, 2)worked in a political party or action group?, 3)worked in another political organisation or association?, 4)worn or displayed a campaign sticker/ badge?, 5)signed a petition?, 6)taken part in lawful public demonstration?, 7)boycotted certain products?.

The response categories are: yes, no, i don't remember.

We want to create two new variables. The first one will be called "Institutionalized Political Trust" (IPP) and the second one "non-Institutionalized Political Trust" (NIPP).

Can we recode into different variables (SPSS) in order to create the IPP variable out of the 4 initial variables and the NIPP variable out of the e remaining initial variables? So, IPP should be a new variable including initial variables 1-4 and the INPP should be a second new variable including initial variables 5-7.

If yes, how can we do that?

Thank you!

Art Kendall

unread,
Jan 15, 2014, 8:35:46 AM1/15/14
to
assuming 'yes' is coded as 1 use
count IPP = var1 to var4(1).


Art Kendall
Social Research Consultants

Art Kendall

unread,
Jan 15, 2014, 11:27:26 AM1/15/14
to
a variable list names the variables you want to work with.
Use the actual variable names, not their relative position in the file.

Art Kendall
Social Research Consultants

Art Kendall
Social Research Consultants

On 1/15/2014 9:01 AM, Natalia Kavourinou wrote:
> Hey,
>
> I did not understand.. I open a new syntax file and type in:
> count IPP = var1 to var4(1)
>
> Is this supposed to find all variables in your database from the 1st
> to the 4th? If for example the specific variables are the 20th to the
> 24th I should type instead:
> IPP = var20 to var24(1) and hit run?
>
> Because I tried both and got this:
>
> GET
> FILE='C:\Users\gebruiker\Desktop\SPF\Weekly Schedule\Week 6-10
> Jan\Monday\Analysis 2nd
> Survey\Second_CleanData\Second_Survey_CleanDara.sav'.
> DATASET NAME DataSet1 WINDOW=FRONT.
> count IPP = var1 to var4(1).
>
> >Error # 4285 in column 13. Text: var1
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> >Execution of this command stops.
>
> >Error # 4285 in column 21. Text: var4
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> count IPP = var451 to var48(1).
>
> >Error # 4285 in column 13. Text: var451
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> >Execution of this command stops.
>
> >Error # 4285 in column 23. Text: var48
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> count IPP = var45 to var48(1).
>
> >Error # 4285 in column 13. Text: var45
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> >Execution of this command stops.
>
> >Error # 4285 in column 22. Text: var48
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> count IPP = var45 to var48(1).
>
> >Error # 4285 in column 13. Text: var45
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.
> >Execution of this command stops.
>
> >Error # 4285 in column 22. Text: var48
> >Incorrect variable name: either the name is more than 64 characters,
> or it is
> >not defined by a previous command.

brend...@gmail.com

unread,
Feb 27, 2014, 3:10:57 PM2/27/14
to
You have no idea how much you have helped me! Thank you so much!! I have been trying to figure this out for the last 4 hours, and this did it! Bless you brilliant brain!

Art Kendall

unread,
Mar 3, 2014, 11:22:05 AM3/3/14
to
Why not use both variables as predictors? for example if you have a DV
which is not very discrepant from interval level of measurement that
would be 2way ANOVA.

Art Kendall
Social Research Consultants

ross.hunte...@gmail.com

unread,
Mar 11, 2014, 5:12:47 AM3/11/14
to
This thread has been really useful for me. I've encountered somewhat of another problem similar to the others but I don't know how I can rectify it.

The question is: Which - if any - of these drugs have you used in the last 6 months? there are 12 categories. Helpfully, the dataset I am using has decided to count each category as a separate variable.

when I try do the following:
COMPUTE drugsused = q0012_0001.
IF (q0012_0002 = 1) drugsused = 2.
IF (q0012_0003 = 1) drugsused = 3.
IF (q0012_0004 = 1) drugsused = 4.
IF (q0012_0005 = 1) drugsused = 5.
IF (q0012_0006 = 1) drugsused = 6.
IF (q0012_0007 = 1) drugsused = 7.
IF (q0012_0008 = 1) drugsused = 8.
IF (q0012_0009 = 1) drugsused = 9.
IF (q0012_0010 = 1) drugsused = 10.
IF (q0012_0011 = 1) drugsused = 11.
IF (q0012_0012 = 1) drugsused = 12.
VARIABLE LABELS drugsused 'Drugs Used in the Last 6 Months'.
VALUE LABELS drugsused 1 'Ketamine (K)' 2 'GBL/GBH' 3 'MDMA' 4 'Speed' 5 'Mephadrone' 6 'Crystal Meth (Tina)' 7 'Cocaine' 8 'Cannabis' 9 'Acid' 10 'Legal Highs' 11 'Steroids' 12 'Other' -1 'missing values'.
EXECUTE .

There are loads of missing data because people obviously double/triple up on drugs.

Is there a way I can separate out all the responses that have 2 or more drugs in their responses?
Or is there a way I can capture the groups of drugs they are using?

Thanks!

Art Kendall

unread,
Mar 11, 2014, 8:48:02 AM3/11/14
to
It is better to create a new thread when introducing a new topic.

type
MULT RESPONSE.
into a syntax window.
With your mouse place the cursor on that text.
click the <f1> key [IIRC <Help> on a MAC.]

Art Kendall
Social Research Consultants

Rich Ulrich

unread,
Mar 11, 2014, 6:39:05 PM3/11/14
to
On Tue, 11 Mar 2014 02:12:47 -0700 (PDT),
ross.hunte...@gmail.com wrote:

>This thread has been really useful for me. I've encountered somewhat of another problem similar to the others but I don't know how I can rectify it.
>
>The question is: Which - if any - of these drugs have you used in the last 6 months? there are 12 categories. Helpfully, the dataset I am using has decided to count each category as a separate variable.
>
>when I try do the following:
>COMPUTE drugsused = q0012_0001.
>IF (q0012_0002 = 1) drugsused = 2.
>IF (q0012_0003 = 1) drugsused = 3.
>IF (q0012_0004 = 1) drugsused = 4.
>IF (q0012_0005 = 1) drugsused = 5.
>IF (q0012_0006 = 1) drugsused = 6.
>IF (q0012_0007 = 1) drugsused = 7.
>IF (q0012_0008 = 1) drugsused = 8.
>IF (q0012_0009 = 1) drugsused = 9.
>IF (q0012_0010 = 1) drugsused = 10.
>IF (q0012_0011 = 1) drugsused = 11.
>IF (q0012_0012 = 1) drugsused = 12.
>VARIABLE LABELS drugsused 'Drugs Used in the Last 6 Months'.
>VALUE LABELS drugsused 1 'Ketamine (K)' 2 'GBL/GBH' 3 'MDMA' 4 'Speed' 5 'Mephadrone' 6 'Crystal Meth (Tina)' 7 'Cocaine' 8 'Cannabis' 9 'Acid' 10 'Legal Highs' 11 'Steroids' 12 'Other' -1 'missing values'.
>EXECUTE .
>
>There are loads of missing data because people obviously double/triple up on drugs.
>
>Is there a way I can separate out all the responses that have 2 or more drugs in their responses?
>Or is there a way I can capture the groups of drugs they are using?
>

Separate out the ones...?
You can Count the number of responses
COUNT numdr= COUNT( q0012_0001 to q00_0012) .

and Crosstab by that, or filter, or whatever.

--
Rich Ulrich

angela....@gmail.com

unread,
Apr 6, 2014, 12:35:08 AM4/6/14
to
I have six variables and want to create a new variable that will be "yes" if any 5 of the 6 original variables are "yes". I'm not sure how to create the syntax for this. If anyone has a solution, thanks in advance.

Art Kendall

unread,
Apr 6, 2014, 8:46:49 AM4/6/14
to
Assuming you want a numeric variable whose value labs are 1 for yes and
0 for no.
If your variables are 1 "yes" and 0 'no" something like this (untested)
should work
compute Any5Yes = sum(var1 to var6) eq 5.
compute Any5or6Yes = sum(var1 to var6) ge 5.

otherwise something like this should work (assuming yes is 2).
count KountYes = var1 to var6 (2).
compute Any5Yes = KountYes eq 5.
compute Any5or6Yes = KountYes ge 5.



Art Kendall
Social Research Consultants

Rich Ulrich

unread,
Apr 6, 2014, 4:26:28 PM4/6/14
to
On Sun, 06 Apr 2014 08:46:49 -0400, Art Kendall <A...@DrKendall.org>
wrote:

>Assuming you want a numeric variable whose value labs are 1 for yes and
>0 for no.
>If your variables are 1 "yes" and 0 'no" something like this (untested)
>should work
>compute Any5Yes = sum(var1 to var6) eq 5.
>compute Any5or6Yes = sum(var1 to var6) ge 5.
>
>otherwise something like this should work (assuming yes is 2).
>count KountYes = var1 to var6 (2).
>compute Any5Yes = KountYes eq 5.
>compute Any5or6Yes = KountYes ge 5.
>

Or you could "yes" if that is the value, or 1 or 2 for a
numeric, in a line like --

COMPUTE Any5yes= any("yes", var1 to var6).

- which results in 1=yes, 0=no for when the first
term matches the subsequent arguments.

- ANY( ) also works with a VAR first, followed by values -
COMPUTE AnyOdd= any(var1, 1,3,5,7).

--
Rich Ulrich

karenlynn...@gmail.com

unread,
Apr 15, 2014, 3:57:06 PM4/15/14
to

yoyor...@gmail.com

unread,
Apr 22, 2014, 8:07:45 PM4/22/14
to
Thank you so much for this!! You are a life saver!!

David Marso

unread,
Apr 23, 2014, 4:45:18 AM4/23/14
to
COMMENTS:
1. Get rid of the EXECUTE statements.
They are unnecessary and result in inefficient processing (particularly if you have a large file). In fact you might want to go to Edit>Options, enter the Data tab and tap the radial button which says calculate values before used.

2. Those six IF statements (sh|c)ould be written as a single line of code.
COMPUTE newvar=(var1-1)*3 + var2.

soetewey....@gmail.com

unread,
May 18, 2014, 5:53:51 AM5/18/14
to
I did something wrong when creating my websurvey.
I have four variables, all coding 0=no 1=yes
and i would like to create one categorical variable grouping the four variables.
It would be like this
var1 = 1, var2 = 0, var3 = 0, var4 = 0 ==> newvar = 1
var1 = 0, var2 = 1, var3 = 0, var4 = 0 ==> newvar = 2
...

Any expert here that could help me?

David Marso

unread,
May 18, 2014, 6:45:21 AM5/18/14
to
IF NOT(var3 OR var4) newvar = var1 + 2*var2.
Don't know what you want for other possibilities.

David Marso

unread,
May 18, 2014, 12:43:46 PM5/18/14
to
I suggest you study the following and apply it to your specifics.

DATA LIST / x1 TO x4 (4F1).
BEGIN DATA
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
END DATA.
COMPUTE new=SUM(8*x1,4*x2,2*x3,x4,1).
FORMATS ALL (F2.0).
LIST.

x1 x2 x3 x4 new

0 0 0 0 1
0 0 0 1 2
0 0 1 0 3
0 0 1 1 4
0 1 0 0 5
0 1 0 1 6
0 1 1 0 7
0 1 1 1 8
1 0 0 0 9
1 0 0 1 10
1 0 1 0 11
1 0 1 1 12
1 1 0 0 13
1 1 0 1 14
1 1 1 0 15
1 1 1 1 16


Number of cases read: 16 Number of cases listed: 16

mariafrance...@gmail.com

unread,
Jun 19, 2014, 11:43:17 PM6/19/14
to
On Friday, May 29, 2009 11:08:48 AM UTC-7, southernpsy wrote:
> I am an SPSS novice, and I found this group recently when I was trying
> to determine how to combine two categorical into one variable in SPSS.
> I did not find an answer online, but I did eventually figure out how
> to do it. I decided to post it here to the benefit of others.
>
> I had one variable for Sex (1: Male; 2: Female) and one variable for
> Self-Identified Gender Expression (1: Masculine; 2: Equally or Neither
> Masculine Nor Feminine; 3: Feminine). I wanted to be able to compare
> Masculine Males, et cetera in post hoc analyses.
>
> Here is a template of the syntax that worked for me:
>
> IF ((var1 = 1) & (var2 = 1)) newvar= 1.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 2)) newvar= 2.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 3)) newvar= 3.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 1)) newvar= 4.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 2)) newvar= 5.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 3)) newvar= 6.
> EXECUTE.

Hello,
I am in the same boat where I am trying to merge 2 categorical variables into 1 where, one variable takes precedence over the other. I cannot find anything on the web either. They are string variables for example- email. Any advice as how to handle this?
Totally lost.
Thanks!

Bruce Weaver

unread,
Jun 20, 2014, 4:09:02 PM6/20/14
to
I assume this is the same question you posted to the SPSSX-L mailing
list. Please see the responses that have been posted there.

http://spssx-discussion.1045642.n5.nabble.com/Merging-string-variables-help-td5726556.html

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

samtei...@gmail.com

unread,
Jun 25, 2014, 4:46:11 PM6/25/14
to
My issue is similar to this but with a little more detail.

I have 2 dichotomous variables that I want to combine into one variable (coded 0 for no and 1 for yes). There are some missing cases (coded -3, -2, -1). If either of the variables are coded 1, I would like the new variable to be coded as 1. I would like it to be coded as 0 if either variable is coded 0 (and neither are coded as 1). I'd like it coded missing only if both are missing. Help! Thanks :)

David Marso

unread,
Jun 25, 2014, 5:21:30 PM6/25/14
to
Look up the MAX function in the ever helpful FM.

Bruce Weaver

unread,
Jun 25, 2014, 5:50:43 PM6/25/14
to
Usually there are several ways to get the job done. Here are a couple
ways I was considering before I saw David's MAX suggestion (which is
also included below). Method 1 is ~probably~ the most transparent of
the 3 (especially for less experienced SPSSers); methods 2 and 3 have
brevity on their side.

* Generate some sample data.
NEW FILE.
DATASET CLOSE all.
DATA LIST free / v1 v2 (2f2.0).
BEGIN DATA
0 0
0 1
1 0
1 1
0 -1
1 -1
-1 0
-1 1
-1 -1
END DATA.

MISSING VALUES v1 v2 (-1 -2 -3).

* Method 1.
IF NVALID(v1,v2) GT 0 new1 = 0.
IF ANY(1,v1,v2) new1 = 1.

* Method 2.
COMPUTE new2 = ANY(1,v1,v2).

* Method 3 - suggested by David Marso.
COMPUTE new3 = MAX(v1,v2).

FORMATS new1 to new3 (f1).
LIST.

OUTPUT:

v1 v2 new1 new2 new3
0 0 0 0 0
0 1 1 1 1
1 0 1 1 1
1 1 1 1 1
0 -1 0 0 0
1 -1 1 1 1
-1 0 0 0 0
-1 1 1 1 1
-1 -1 . . .

Number of cases read: 9 Number of cases listed: 9


Method 2 takes advantage of a very nice feature of SPSS. For COMPUTE
statements that have this form...

COMPUTE NewVar = {some condition -- e.g., ANY(1,v1,v2)}.

...NewVar is set to 1 if the condition on the right is TRUE, and to 0 if
the condition is FALSE.

HTH.

samtei...@gmail.com

unread,
Jun 25, 2014, 6:12:25 PM6/25/14
to
THANKS! Though I still haven't figured out exactly how to get the missing data codes to show up properly, I do have the correct n for cases that should be coded as 1 so that's a start!

Rich Ulrich

unread,
Jun 25, 2014, 11:38:01 PM6/25/14
to
On Wed, 25 Jun 2014 15:12:25 -0700 (PDT), samtei...@gmail.com
wrote:

>THANKS! Though I still haven't figured out exactly how to get the missing data codes to show up properly, I do have the correct n for cases that should be coded as 1 so that's a start!

?

The "." is how SPSS shows you the System-missing value, so all three
of the solutions shown by Bruce give you Missing "properly" unless you
want to preserve your -1, -2, -3 by some rule.

Using MAX will preserve the highest value if you turn turn off the
MISSING specification (i.e., -1 is greater than -3).

MISSING VALUES v1 v2 v3 ( ).

--
Rich Ulrich

David Marso

unread,
Jun 26, 2014, 9:03:49 AM6/26/14
to
Or don't turn them off and use VALUE function.
COMPUTE newvar=MAX(VALUE(v1),VALUE(v2),VALUE(v3)).
MISSING VALUES newvar(-3,-2,-1).

marisol...@gmail.com

unread,
Jul 28, 2014, 3:56:40 PM7/28/14
to
I am trying to recode (SPSS) 6 race variables that are dichotomous into 1 race variable(with values, nonwhite and white) I am running into some problems. Each variable is 0=unchecked and 1=checked. The only white variable is Race___4. I don't know what I am doing wrong.

Compute racerecategory = race___0, race___1, race___2, race___3, race___4, race___5, race___6.
If ((race___0=0) and (race___1=0) and (race___2=0) and (race___3=0) and (race___4=1) and (race___5=0) and (race___6=0)) White=1.
If ((race___0=1) and (race___1=1) and (race___2=1) and (race___3=1) and (race___4=0) and (race___5=1) and (race___6=0)) Nonwhite=2.
Execute.
value labels racerecategory
1 'White'
2 'Nonwhite'.
Execute.

Can someone help! thanks (:

Bruce Weaver

unread,
Jul 28, 2014, 6:29:22 PM7/28/14
to
On 28/07/2014 3:56 PM, marisol...@gmail.com wrote:
> I am trying to recode (SPSS) 6 race variables that are dichotomous into 1 race variable(with values, nonwhite and white) I am running into some problems. Each variable is 0=unchecked and 1=checked. The only white variable is Race___4. I don't know what I am doing wrong.

Presumably, Race___4 = 1 for those who are white, and 0 for those who
are not white. Right? So I think you already have "1 race
variable(with values, nonwhite and white)". :-|

>
> Compute racerecategory = race___0, race___1, race___2, race___3, race___4, race___5, race___6.

That is not a valid COMPUTE statement. What are you trying to do there?

> If ((race___0=0) and (race___1=0) and (race___2=0) and (race___3=0) and (race___4=1) and (race___5=0) and (race___6=0)) White=1.
> If ((race___0=1) and (race___1=1) and (race___2=1) and (race___3=1) and (race___4=0) and (race___5=1) and (race___6=0)) Nonwhite=2.

There is more than one problem here.

1) You are computing two new variables called White and Nonwhite, not
one variable called RaceCategory.

2) I suspect you wanted to use OR rather than AND in the second IF line.

But you don't need two IF lines anyway. Assuming you do want a new
variable called RaceCategory (rather than just using Race___4), why not
just do this?

COMPUTE RaceCategory = Race___4.

> Execute.
> value labels racerecategory
> 1 'White'
> 2 'Nonwhite'.
> Execute.
>
> Can someone help! thanks (:
>


albanysaf...@gmail.com

unread,
Aug 7, 2014, 4:07:17 PM8/7/14
to
I am struggling to combine two dichotomous variables. The variables are coded (0/1) where 1 indicates an unintended pregnancy and 0 is intended. I have data on multiple pregnancies and want to count each individual data point, but when I create my new variable if a person has had two '1' scores, the overlap is not counted. In my syntax I see why I am not getting both unintended pregnancies for each respondent but don't know how to get around it. HELP!!!!

Rich Ulrich

unread,
Aug 7, 2014, 7:03:10 PM8/7/14
to
On Thu, 7 Aug 2014 13:07:17 -0700 (PDT), albanysaf...@gmail.com
wrote:
So: You have data on 2 (or sometimes just one?) pregnancy, marked in
two variables.

If everyone has two pregnancies, then you apparently want the sum
of "unintended", which would be var1+var2.

It has to be more complicated if you want all possibilities when there
may be only one pregnancy... and var2 is "Missing" when there was
only one. The simpler thing is probably to use two *different*
variables than the ones you started with -- the count of Unintended,
and the count of Valid responses. For one case, you then may say
that "1 out of 1" was unintended, or "0 out of 2" was unintended

If you have that sort of missing and you want just one variable,
then you need to decide what codes you want to use in order to
indicate all the possibilities.
Unintended: 0 of 1; 1 of 1; 0 of 2; 1 of 2; 2 of 2.

--
Rich Ulrich

David Marso

unread,
Aug 7, 2014, 8:52:20 PM8/7/14
to
"In my syntax I see why I am not getting both unintended pregnancies for each respondent but don't know how to get around it. HELP!!!! "
Unfortunately we can't because you didn't bother to post it along with representative data and desired outcome!
Perhaps you would care to remedy that oversight and not rely on our psychic powers!
------

patric...@gmail.com

unread,
Dec 10, 2014, 3:45:12 PM12/10/14
to
On Friday, 29 May 2009 19:08:48 UTC+1, southernpsy wrote:
> I am an SPSS novice, and I found this group recently when I was trying
> to determine how to combine two categorical into one variable in SPSS.
> I did not find an answer online, but I did eventually figure out how
> to do it. I decided to post it here to the benefit of others.
>
> I had one variable for Sex (1: Male; 2: Female) and one variable for
> Self-Identified Gender Expression (1: Masculine; 2: Equally or Neither
> Masculine Nor Feminine; 3: Feminine). I wanted to be able to compare
> Masculine Males, et cetera in post hoc analyses.
>
> Here is a template of the syntax that worked for me:
>
> IF ((var1 = 1) & (var2 = 1)) newvar= 1.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 2)) newvar= 2.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 3)) newvar= 3.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 1)) newvar= 4.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 2)) newvar= 5.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 3)) newvar= 6.
> EXECUTE.

Hi there,
I tried this, and a few of the other recommendations didnt work for me. I have 8 categorical variables all coded 1 or blank. I simply want a new variable coding answers 1-8 instead. That it is actually this difficult is beyond belief!

Many thanks in advance,

Patrick

David Marso

unread,
Dec 11, 2014, 12:46:50 AM12/11/14
to
" That it is actually this difficult is beyond belief!"
I find it 'beyond belief' that you don't post an example of your data fields along with an example of the desired outcome ;-)

Rich Ulrich

unread,
Dec 11, 2014, 12:03:30 PM12/11/14
to
On Wed, 10 Dec 2014 12:45:10 -0800 (PST), patric...@gmail.com
wrote:
[snip]
>
>Hi there,
>I tried this, and a few of the other recommendations didnt work for me. I have 8 categorical variables all coded 1 or blank. I simply want a new variable coding answers 1-8 instead. That it is actually this difficult is beyond belief!
>

COMMENT pick up the last item-number scored as a '1' rather than ' '.
COMPUTE newvar= 0.
DO REPEAT dum1= item1 to item8/ dum2= 1 to 8.
IF (dum1 eq '1') newvar= dum2.
END REPEAT.

--
Rich Ulrich

fur...@mail.gvsu.edu

unread,
Dec 11, 2014, 12:05:51 PM12/11/14
to
I am just to get back into SPSS after a few years of not using it. So, I apologize in advance if this question is easily solved. I am trying to combine responses for one eventual variable, asked many times so input into numerous variables. It is data from the National Survey of Adolescents. Say, for example, they asked "Where did violence happen?" With that question they allowed for numerous responses, each response assigned a nominal code. I have recoded so that I have the following

1.00 = "Home"
2.00 = "School"
3.00 = "Neighborhood"
4.00 = "Somewhere Else"
5.00 = "Unknown"

Since this question was asked 6 times, with each instance of it being asked entered as a different variable, can I get each of these responses into one variable rather than 6? I tried compute and rather than giving me how many times each respondent experienced each event, it totaled everything. I practiced this with my thesis chair, using only two responses (1 and 2, and 0 for system missing) and it worked. Of course, now that I am doing it on my own it isn't.

For example, this was the syntax I used to create the variables.

RECODE QD1 (1=Copy) (2=Copy) (3=Copy) (4=Copy) (5 thru 9=5) INTO WhereViolence1.
VARIABLE LABELS WhereViolence1 'Where violence happened 1'.
EXECUTE.

VALUE LABELS
WhereViolence1
1 'Home'
2 'School'
3 'Neighborhood'
4 'Somewhere Else'
5 'Unknown'.
EXECUTE.

FREQUENCIES VARIABLES=WhereViolence1
/ORDER=ANALYSIS.

RECODE QD2 (1=Copy) (2=Copy) (3=Copy) (4=Copy) (5 thru 9=5) INTO WhereViolence2.
VARIABLE LABELS WhereViolence2 'Where violence happened 2'.
EXECUTE.

VALUE LABELS
WhereViolence2
1 'Home'
2 'School'
3 'Neighborhood'
4 'Somewhere Else'
5 'Unknown'.
EXECUTE.

Then continued this through the six variables.

When I try to compute to add the variables together to see which one was experienced by each individual

COMPUTE WhereViolenceHappenedTotal=WhereViolence1 + WhereViolence2 + WhereViolence3 +
WhereViolence4 + WhereViolence5 + WhereViolence6.
EXECUTE.

This is what my output looks like:

Statistics
WhereViolenceHappenedTotal
N Valid 4023
Missing 0

WhereViolenceHappenedTotal
Frequency Percent Valid Percent Cumulative Percent
Valid 14.00 2 .0 .0 .0
16.00 2 .0 .0 .1
17.00 5 .1 .1 .2
18.00 11 .3 .3 .5
19.00 23 .6 .6 1.1
20.00 39 1.0 1.0 2.0
21.00 97 2.4 2.4 4.4
22.00 99 2.5 2.5 6.9
23.00 134 3.3 3.3 10.2
24.00 355 8.8 8.8 19.1
25.00 235 5.8 5.8 24.9
26.00 339 8.4 8.4 33.3
27.00 1069 26.6 26.6 59.9
28.00 325 8.1 8.1 68.0
29.00 199 4.9 4.9 72.9
30.00 1089 27.1 27.1 100.0
Total 4023 100.0 100.0








It does not work. I will not even pretend that I know what I am doing anymore (I took some time off to have children.) I have emailed my thesis chair (who is obviously familiar with what I am doing) but I would love to be able to figure this out. It is embarrassing how bad I am at this now! Is it just not possible to do what I want? Does it need to be broken down some more? For example, I am really interested in whether or not violence in witnessed in the home. Should I change this to a "yes" violence in the home or "no" no violence in the home. I would ideally like to have the greater variation in responses, just to try to control for more, but if that won't work then whatever will.

Thanks to anyone who can help.

Message has been deleted

patric...@gmail.com

unread,
Dec 11, 2014, 1:12:25 PM12/11/14
to
Thanks Rich, I tried that and this is the response:

IF (empstatusfulltime eq '1') newvar= empstatusParttime.

>Error # 4305 in column 32. Text: )
>A relational operator may have two numeric operands or two character string
>operands. To compare a character string to a numeric quantity, consider using
>the STRING or NUMBER function.
>Execution of this command stops.

David, data fields are empstatusfulltime =1 or ., Empstatuspartime =1 or . etc. 8 in total. Desired outcome one variable Employment Status with 1 = Fulltime, 2 = parttime, 8= Other. Just starting to use syntax so if I need to do anything other than change variable names please let me know!

Many thanks,

Patrick

Ki

unread,
Dec 11, 2014, 2:23:24 PM12/11/14
to
If I understand well, you cannot use "COMPUTE" as a sum of the new variables because the responses are nominal (locations). As you compute a violence in "School" is 'equivalent' to 2 times "Home."

You could use COUNT if you are willing to create how many of these 6 questions had the response option "1". Yet, I am not sure if this is the way to go since I don't have idea why did they ask 6 Questions to start with.

David Marso

unread,
Dec 11, 2014, 4:54:48 PM12/11/14
to
Given the error message, it seems that Rick thought your variables were STRING rather than NUMERIC.
You still have not provided sufficient information as to how your 8 variables should be combined to result in a single new variable. You really need to be quite specific with an ACTUAL EXAMPLE of exact inputs and desired outputs.
Lay out several sample records with the 8 variables along with the desired result and the logic which leads to that conclusion.
We are not mind readers!

patric...@gmail.com

unread,
Dec 11, 2014, 5:22:07 PM12/11/14
to
Ok, apologies, I'll try to be as clear as I can. So there are 8 nominal numeric variables. Each is refers to 1 item only. Where this item is present in each variable, a 1 is recorded, not present = . What I'id like to do is create a new variable (employmentstatus) where value 1 = the total scores of variable 1, value 2= total scores of variable 2, etc, up to value 8 = total scores of var 8. Hope that's clearer and many thanks!

patric...@gmail.com

unread,
Dec 11, 2014, 5:25:17 PM12/11/14
to
On Thursday, 11 December 2014 22:22:07 UTC, patric...@gmail.com wrote:
> Ok, apologies, I'll try to be as clear as I can. So there are 8 nominal numeric variables. Each is refers to 1 item only. Where this item is present in each variable, a 1 is recorded, not present = . What I'id like to do is create a new variable (employmentstatus) where value 1 = the total scores of variable 1, value 2= total scores of variable 2, etc, up to value 8 = total scores of var 8. Hope that's clearer and many thanks!

And sorry, I don't know enough about syntax to be able to write the command of what I would like! Although you'd think this is relatively common?

fur...@mail.gvsu.edu

unread,
Dec 11, 2014, 6:58:56 PM12/11/14
to
Ki,




I have been wondering that same question. It is a secondary data analysis so I have to try and make what they asked work. Basically, rather than asking what the respondents have experienced and checking them off, the respondents were asked to recall individual events with follow-up questions that were event specific. So, if they reported violence happening at home the follow up would be who did it happen to and who did it? Again, separate variables for all of those. It is a huge pain. I know the information I want is there, it is just a matter of making it usable.

How would I go about using count? I searched after you wrote this and found this problem, which is similar to what I want to accomplish, and uses count but is only looking for "yes" or "no," would the basic procedure be the same?

http://www.yac.com.pl/mt.texts.spss-count.en.html

David Marso

unread,
Dec 11, 2014, 9:21:47 PM12/11/14
to
Knowledge of syntax is not necessary for you to provide an actual example of the data fields and what your result should look like!

Rich Ulrich

unread,
Dec 11, 2014, 11:50:06 PM12/11/14
to
Okay. So you get 6 separate variables with values of
1-5, not counting the original Missing. What do you want
to do with them? (Or did missing get counted as Unknown? - which
is what it looks like from the Total you give for 6.)

The way you get a single variable, with a single one of those
values, is to place some logical condition on what you have.

Do you want the first one reported? Do you want the
lowest of those numerical values? - It looks like a large
fraction had 6 values of 5. Does that indicate that
there were 6 events, or (maybe) that there were no
events reported.

What do you want to do, by hand?

--
Rich Ulrich

Rich Ulrich

unread,
Dec 11, 2014, 11:58:43 PM12/11/14
to
On Thu, 11 Dec 2014 10:12:24 -0800 (PST), patric...@gmail.com
wrote:

>On Thursday, 11 December 2014 17:03:30 UTC, Rich Ulrich wrote:
>> On Wed, 10 Dec 2014 12:45:10 -0800 (PST), patric...@gmail.com
>> wrote:
>> [snip]
>> >
>> >Hi there,
>> >I tried this, and a few of the other recommendations didnt work for me. I have 8 categorical variables all coded 1 or blank. I simply want a new variable coding answers 1-8 instead. That it is actually this difficult is beyond belief!
>> >
>>
>> COMMENT pick up the last item-number scored as a '1' rather than ' '.
>> COMPUTE newvar= 0.
>> DO REPEAT dum1= item1 to item8/ dum2= 1 to 8.
>> IF (dum1 eq '1') newvar= dum2.
>> END REPEAT.
>>
>> --
>> Rich Ulrich
>
>Thanks Rich, I tried that and this is the response:
>
>IF (empstatusfulltime eq '1') newvar= empstatusParttime.
>
>>Error # 4305 in column 32. Text: )
>>A relational operator may have two numeric operands or two character string
>>operands. To compare a character string to a numeric quantity, consider using
>>the STRING or NUMBER function.
>>Execution of this command stops.

Well, gee, you said you had BLANK, which is alpha.
As David says.

To avoid problems that sometimes happen when you
compare something with Sysmiss values, you might want
to recode all the variables (Sysmis=0) or some such.

And then test against 1 instead of '1' .

Setting the newvar to empstatusParttime sounds like you
are doing a different problem, now, than the one that you
originally described. - If I were assigning values of 1-8 in
order, I would use a name like DUM2 or something that
suggests dummy values.


--
Rich Ulrich

Rich Ulrich

unread,
Dec 12, 2014, 12:09:29 AM12/12/14
to
On Thu, 11 Dec 2014 09:57:58 -0800 (PST), VonLuck
<patric...@gmail.com> wrote:

>
>
>Hi there,
>
>I have tried a few of these syntax commands and none have worked. I'm looking to collapse 8 numerical categorical variables scored 1 or missing, into one variable of 1-8. Can anyone help? Have spent hours on this!
>Thanks,

See: What I just described, in this thread.

Or, otherwise,

COMPUTE newvar= SUM.1(1*item1, 2*item2, 3*item3, 4*item4,
5*item5, 6*item6, 7*item7, 8*item8).

That takes advantage of the fact that SUM.1( ) returns the
sum, even when all but one of the values may be Missing.

Of course, you will get something unwanted if more than
one of the values are Valid. But if that is true, then you can't
do the simple collapse that you want, anyway.

You can collapse with 8 actual values to 0-511 by
replacing the multipliers with the powers of 2:
1, 2, 4, 8, 16, 32, 64, 128, 256. (Replace Missing with 0.)

For other strategies, you will need to describe in more detail....


--
Rich Ulrich

fur...@mail.gvsu.edu

unread,
Dec 12, 2014, 8:44:07 AM12/12/14
to
You are correct in guessing that I counted system missing as unknown. Without doing that I had only a few hundred valid responses (and it was what my chair and I had done with other variables). Basically, I realize that I can run the analyses I want with all of these variables as individuals; however, that is making my data set huge and messy and it seems like it would be more efficient to have them all as one variable, since they as the same thing with the same potential responses, particularly for presentation of the data. Each question gets to a different mention of where violence occurred. I would like a new variable that takes all of these separate instances and combines them so I can see, in one variable, where each respondent has witnessed violence. So, the ideal variable would account for all places an individual has witnessed violence.

I also considered just coding to Witnessed Violence at Home? Yes or no, then continuing that for all the other areas (school, etc.) But, I still run into the problem of great, I know for that one question whether or not they have witnessed violence, but what about in total?

Actually, I just reread what you wrote "It looks like a large fraction had six values of five" How do you know that? It is completely correct--those would be the system missing data (recoded to unknown), which means they did not witness violence. I am assuming you divided 30 by 6 which gives the value of 5, which allows us to determine pretty easily that those respondents did not witness violence. The rest I cannot do that with because there is a great variety of potential responses that would provide that outcome, right?

Is there a way to get each individuals response from each variable added together (not computed with addition like I have done) but rather experienced 1, 2, 3, 4, or 5. Then just a combined variable for each of those. Say for variable one, if 1 is yes = something, if 2 is yes = something, if 3 is yes= something, if 4 is yes = something, if 5 is yes = something; then for variable two, do the same thing (through variable 6), then turn these responses into the final variable.



David Marso

unread,
Dec 12, 2014, 9:39:17 AM12/12/14
to
Ir seems to me that we still don't know what in the hell the data actually look like or what the actual required result should be (despite my asking nicely twice). I think any code suggestion here is premature!

David Marso

unread,
Dec 12, 2014, 9:49:31 AM12/12/14
to
In fact there are TWO different threads going on here (both of which are a hijacking of a topic which began in 2009). It would best serve if each of these were started again in their OWN topics with a concise summary of the issues AND illustrative data WITH desired result! Learn how to use the NEW TOPIC feature!

fur...@mail.gvsu.edu

unread,
Dec 12, 2014, 10:00:40 AM12/12/14
to
David, really, you do not have to reply to this. Rich is being helpful and you do not have to receive notifications of the topic. Some of us are just trying to get by. Rich has managed to respectfully respond. I put the data I am using in above comments, and Rich figured out what I was doing and is in the process of trying to help. He is asking questions that help get to the intended outcome, not belittling those of us who are actually confused. If we knew everything that you do, we would not be on here. The questions you ask assume we know exactly what we are doing, which is not the case. I feel bad for Patrick who is struggling not only with the syntax but even the terminology in general, as am I. What do you mean by data? We cannot post a data set here that I can see, so what exactly do you want? We are people trying our best, there is no need to be rude about any of it. And posting on the same thread does help people with similar questions that are trying to get to the same point, but there is a little variation in everything. Going through the different solutions has helped my understanding to some degree. You both have a wealth of knowledge, which is amazing, but there is a definite different in approach to asking questions.

David Marso

unread,
Dec 12, 2014, 11:21:54 AM12/12/14
to
"What do you mean by data? We cannot post a data set here that I can see, so what exactly do you want?"
Go to the data editor, highlight several rows of relevant data.
Copy> Goto message, PASTE, then describe what the numbers are and what they need to end up becoming. How hard is that?
Re hijacking an original thread which is unrelated to the current issue aside from the nebulous term 'How to combine variables...". It takes a LONG time to load all 58 of the mostly irrelevant posts and likewise to maintain focus on 2 rather different vaguely described topics.
I'm happy Rich is helping. His ESP must be far superior to my own.
--

patric...@gmail.com

unread,
Dec 12, 2014, 12:36:06 PM12/12/14
to
Hi Rich,
Many thanks for you help. I tried the sysmis=0 and that converted all cells with . to .00, whilst keeping a 1 to indicate variable is present. When I tried then to compute these variables into a new var of total scores it only recorded . Same when I tried your syntax solution. I think the problem may be with the missing data field?

Here is the best example I can give of how the variable data files look, with the last variable demonstrating what I would like. In reality there are 8 variables, not 4. I'm sorry I can't make it any clearer without screen grabs which this thread won't seem to support.

Fulltime parttime self unemp Totalemp
1 .00 .00 .00 1 = total counts (3) of Fulltime
.00 1 .00 .00 2 = total counts (1) of parttime
1 .00 .00 .00 3 = total counts (2) of self
1 .00 .00 .00 4 = total counts (0) of unemp etc
.00 .00 1 .00
.00 .00 1 .00

Really hope that is clearer! Thanks, Patrick

David Marso

unread,
Dec 12, 2014, 3:10:18 PM12/12/14
to
An example is worth a thousand words!
You are doing CROSS CASE calculations ergo COMPUTE will get you nowhere!
You require AGGREGATE:
eg:

DATA LIST LIST /Fulltime parttime self unemp .
BEGIN DATA
1.00 .00 .00 .00
.00 1.00 .00 .00
1.00 .00 .00 .00
1.00 .00 .00 .00
.00 .00 1.00 .00
.00 .00 1.00 .00
END DATA.
/* Omit above data list etc...*/.

DATASET DECLARE tmp.
AGGREGATE OUTFILE tmp
/ BREAK
/ Fulltime parttime self unemp =SUM(Fulltime parttime self unemp ).
DATASET ACTIVATE tmp.
LIST.

Fulltime parttime self unemp

3.00 1.00 2.00 .00


Number of cases read: 1 Number of cases listed: 1

David Marso

unread,
Dec 12, 2014, 3:54:32 PM12/12/14
to
On Friday, December 12, 2014 12:36:06 PM UTC-5, patric...@gmail.com wrote:
You can't use COMPUTE for this purpose. Look at AGGREGATE.

fur...@mail.gvsu.edu

unread,
Dec 12, 2014, 3:54:55 PM12/12/14
to
Thank you for being specific. I mistakenly assumed before that the syntax I provided with the variables and their identification would be sufficient to show what the data might represent.




1=Home, 2=School, 3=Neighborhood, 4=Somewhere Else, 5=Unknown (including system missing data, which would have been did not witness)




Event1 Event2 Event3 Event4 Event5 Event6

Respondent 1 3.00 2.00 5.00 5.00 5.00 5.00
Respondent 2 5.00 5.00 5.00 5.00 5.00 5.00
Respondent 3 5.00 3.00 3.00 5.00 5.00 5.00
Respondent 4 2.00 5.00 5.00 5.00 5.00 5.00




I want to know, is there any way I can get each of the above events into one variable. I know that respondent 1 witnessed violence at school and in the neighborhood. Can I get that information into one variable to account for all types of witnessed violence. I feel like this must be an easy fix that I am just missing.

The reason I want to make the dataset smaller is (1) for analysis likely with logistic regression and (2) 466+ variables is a lot to work with. I also have a number of variables that are like this (e.g. who injured, who did you tell) and each does represent an important control factor.

Rich Ulrich

unread,
Dec 12, 2014, 4:39:07 PM12/12/14
to
On Fri, 12 Dec 2014 05:44:04 -0800 (PST), fur...@mail.gvsu.edu wrote:


> .... I would like a new variable that takes all of these separate instances and combines them so I can see, in one variable, where each respondent has witnessed violence. So, the ideal variable would account for all places an individual has witnessed violence.

One thing that has not been mentioned is
VarsToCases -- You can convert one record to
several records, and then you can separately
tabulate the number of EVENTS, as distinct from
the number of PEOPLE.

You can get some of that same functionality without
using VarsToCases by using the MULTRESPONSE
procedure. Actually, MULTRESPONSE can use the
separate Yes/No variables, if you only want a certain
sort of simple tabulations.

Another variation on EVENTS is to count and report
the number of "different EVENTS" reported. That is,
if one person had 4 events but 3 of them were at home,
then their data could be reduced, first, to "the first
event at each location"; then the tabulation would use
only 3 different events for that person. For that, I am
thinkingn of the VarsToCases, followed by AGGREGATE
which takes only the first one for a unique ID/EventCode.



[snip]
>
>Is there a way to get each individuals response from each variable added together (not computed with addition like I have done) but rather experienced 1, 2, 3, 4, or 5.

From MultResponse, you can get the count of which Events
co-existed for Persons. Does that help?

Sometimes it is possible and useful to write a report that describes
"Persons with one event"; "persons with two events" -- and use the
crosstabulation of two events to find a few categories that are most
numerous, and lump al the rest as "other"; and "Three or more
events". Thus you might have a variabe where 1-4 represent
the 1-event people; 5-10 (say) represent the 2-event people;
and 11 represents the 3-6 event people, if you don't decide to
break out any separate categories for them.


> Then just a combined variable for each of those. Say for variable one, if 1 is yes = something, if 2 is yes = something, if 3 is yes= something, if 4 is yes = something, if 5 is yes = something; then for variable two, do the same thing (through variable 6), then turn these responses into the final variable.
>


I don't follow what the final step might be. What do you want
to be able to write in a report? What can you imagine someone
writing in a report from similar data? What sort of data record
is needed to create that write-up?

--
Rich Ulrich

Rich Ulrich

unread,
Dec 12, 2014, 4:49:21 PM12/12/14
to
On Fri, 12 Dec 2014 09:36:03 -0800 (PST), patric...@gmail.com
wrote:
" ... it only recorded." What does that mean?

If you merely recoded the Sysmis to 0, then you no longer have
a Missing Data field; avoiding potential gripes about Missing is the
reason to do that.




>
>Here is the best example I can give of how the variable data files look, with the last variable demonstrating what I would like. In reality there are 8 variables, not 4. I'm sorry I can't make it any clearer without screen grabs which this thread won't seem to support.
>
>Fulltime parttime self unemp Totalemp
>1 .00 .00 .00 1 = total counts (3) of Fulltime
>.00 1 .00 .00 2 = total counts (1) of parttime
>1 .00 .00 .00 3 = total counts (2) of self
>1 .00 .00 .00 4 = total counts (0) of unemp etc
>.00 .00 1 .00
>.00 .00 1 .00
>
>Really hope that is clearer! Thanks, Patrick


I presume that the case does have a ID.

If you want to collect the total counts for Fulltime, etc., you
can use Aggregate in order to count the sums of 1 for the ID;
and you can add a new variable for each Type to the end of the
file: That must be a new variable for each type, if you intend
to keep them separate, like Totalemp1 to Totalemp4.

--
Rich Ulrich


David Marso

unread,
Dec 12, 2014, 5:13:31 PM12/12/14
to
I suggest you look at the VARSTOCASES command. OTOH, I would have some concerns about lack of independence of the observations if you are going for LOGREG.

fur...@mail.gvsu.edu

unread,
Dec 12, 2014, 7:58:59 PM12/12/14
to
Thanks for your help Rich and David. I was trying what you two mentioned and tried the multiple response. It was able to give me the people who experienced violence in the home. I think I am just going to simplify things, and only do violence in the home since that is the variable I truly want. I am testing Hirschi's Social Control theory using numerous variables, this was just one. By counting the variables for '1', am I doing what I think I am--getting the numbers for what people experienced violence in the home and how many times? If so, I am done and this will meet my needs. I can just recode these to "yes" and "no." If it is necessary I can also COUNT the rest of the situations as well and go from there. This seems to have done what I want insofar as determining who experienced what across variables. Sorry if I was not clear in presenting questions. I have truly been back into this for less than a week after 5 years off.

COUNT ViolenceAtHome=WhereViolence1 WhereViolence2 WhereViolence3 WhereViolence4 WhereViolence5
WhereViolence6(1).
EXECUTE.
FREQUENCIES VARIABLES=ViolenceAtHome
/ORDER=ANALYSIS.


Statistics
ViolenceAtHome
N Valid 4023
Missing 0


ViolenceAtHome
Frequency Percent Valid Percent Cumulative Percent
Valid .00 3922 97.5 97.5 97.5
1.00 91 2.3 2.3 99.8
2.00 8 .2 .2 100.0
3.00 1 .0 .0 100.0
4.00 1 .0 .0 100.0
Total 4023 100.0 100.0

Ki

unread,
Dec 13, 2014, 5:03:09 PM12/13/14
to
If you code all "yes-house" as 1 and everything else "no-house" as 0, then the sum of the variables will be only yes values. Perhaps, this is why this approached worked when you did with your advisor. However, it is still unclear to me the computed values will mean. For instance, a person with 6 -which means 6 "yes"- has different level of exposure of violence at home. We will need more information to guide what you want to do with your result.

Ki

fur...@mail.gvsu.edu

unread,
Dec 13, 2014, 5:19:43 PM12/13/14
to
You are right, not accounting for the number of expolsures will be a limitation to my research. I don't want to put my entire thesis idea out there, but basically I will be looking at how different variables influence likelihood in adolescent substance use with intervening variables. Since prior research looks at exposure to violence as a potential factor, I just want to make sure that will not be throwing off my results. In addition, I will be looking at abuse, parental use, as well as indicators of good parental attachment or complying with school rules.

Given that the vast majority of the sample did not experience any violence within the home, I am still thinking a "yes" "no" will provide valuable information. If not, or if my chair decides something more detailed is necessary, then I will go from there. I have saved the multiple response variable, which does show me all incidents of all locations. Perhaps my chair will know what to do with that, or guide me a little better, than I am able to do. It probably doesn't sound too original, but the factor I am really looking at isn't mentioned intentionally (not that you would all really care, anyway).

Truly, your ideas have helped immensely in narrowing down what I wanted to do. And provided a basis for being able to do more if I work with SPSS a little bit more and become more comfortable to be able to execute the ideas properly. Thank you!

Ki

unread,
Dec 13, 2014, 5:32:17 PM12/13/14
to
Sorry that I didn't see you COUNT syntax posted yesterday. This is 'only' 2.5% of your sample, so you do not have much room to create different level of exposure of violence at home. It would be almost "any-violence-at-home" variable.

Ki

Julie Hao

unread,
May 29, 2015, 9:12:49 PM5/29/15
to
Hello there. I randomly came into this group and I am crying for help T.T


I am now working on writing a syntax to merge multiple categorical variables into one. There is a variable asking about the status of children. The variable name is CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03. 01 means the first child, 02 means the second child, and 3 means the third child. The values of this variables are: 1 adopted out 2 deceased 3 non-resident and 4 resident with respondent


Here is what I want to do: I want to create a new variable to merge these variables (CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03 ) answered with the same value into one variable. For example, I want to merge all the variables that were answered with 1 into a new variable called adoptout_total. Merge all the variables that the answer values are 2 into a new variable called deceased_total, merge all the variables that were answered with value 3 into a new variable named nonresident_total, merge all the variables that were answered with a value 4 into a new variable named resident_total.

Hope it's clear enough to you. Basically I want to add up all the cases that have their children adopted out, all the cases that their children were deceased, all the cases that have their children not resident with respondents, and all the cases that have their children living in the household.

How to write a syntax to achieve this? Thank you sooooooo much! Could you please give me an example using the variables that I listed? Thank you!!!

Julie




My question is: how to write a syntax to create a new variable to merge all the father involvement variables across years(2000-2011) into one variable called"fatherinvolvement1"?

Bruce Weaver

unread,
May 30, 2015, 7:41:59 AM5/30/15
to
On 29/05/2015 9:12 PM, Julie Hao wrote:
> Hello there. I randomly came into this group and I am crying for help T.T
>
>
> I am now working on writing a syntax to merge multiple categorical variables into one. There is a variable asking about the status of children. The variable name is CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03. 01 means the first child, 02 means the second child, and 3 means the third child. The values of this variables are: 1 adopted out 2 deceased 3 non-resident and 4 resident with respondent
>
>
> Here is what I want to do: I want to create a new variable to merge these variables (CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03 ) answered with the same value into one variable. For example, I want to merge all the variables that were answered with 1 into a new variable called adoptout_total. Merge all the variables that the answer values are 2 into a new variable called deceased_total, merge all the variables that were answered with value 3 into a new variable named nonresident_total, merge all the variables that were answered with a value 4 into a new variable named resident_total.
>
> Hope it's clear enough to you. Basically I want to add up all the cases that have their children adopted out, all the cases that their children were deceased, all the cases that have their children not resident with respondents, and all the cases that have their children living in the household.
>
> How to write a syntax to achieve this? Thank you sooooooo much! Could you please give me an example using the variables that I listed? Thank you!!!
>
> Julie

Look up the COUNT command.

COUNT
adoptout_total =
CV_CHILD_STATUS_01
CV_CHILD_STATUS_02
CV_CHILD_STATUS_03 (1) /
deceased_total =
CV_CHILD_STATUS_01
CV_CHILD_STATUS_02
CV_CHILD_STATUS_03 (2) /
nonresident_total =
CV_CHILD_STATUS_01
CV_CHILD_STATUS_02
CV_CHILD_STATUS_03 (3) /
resident_total =
CV_CHILD_STATUS_01
CV_CHILD_STATUS_02
CV_CHILD_STATUS_03 (4).


I don't have SPSS on this machine, so cannot test, but I *suspect* you
could also stick this inside a DO-REPEAT structure. Something like:

DO REPEAT
V = adoptout_total deceased_total nonresident_total resident_total /
TestVal = 1 2 3 4.
COUNT V =
CV_CHILD_STATUS_01
CV_CHILD_STATUS_02
CV_CHILD_STATUS_03 (TestVal).
END REPEAT.


>
> My question is: how to write a syntax to create a new variable to merge all the father involvement variables across years(2000-2011) into one variable called"fatherinvolvement1"?
>

You've not given any detail about the father involvement variables. But
if it is the same as above, use COUNT again.

HTH.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

Julie Hao

unread,
May 30, 2015, 4:07:16 PM5/30/15
to
Hey Bruce,

Thank you very much for your response.

However, I don't think it's the right syntax. I ran the syntax you gave to me, and it said that On the COUNT command, the variable list was not followed by the value list enclosed in parentheses.

And I want to be clear that I only want to add up all the cases that answered 1 in the variable CV_CHILD_STATUS_01, because there are 4 possible values. I want to add up all the cases that answered 1 into a new variable called adoptout_total, and add up all the cases that answered 2 into a new variable called deceased_total, add up all the cases that with a value 3 into a new variable called nonresident_total, and add up all the cases that with a value 4 answer into a new variable called resident_total. I want to add them together separately. Please help!!! Thank you a loooooot!!!

Julie

Julie Hao

unread,
May 30, 2015, 4:52:51 PM5/30/15
to
Hey Bruce,

I tried the syntax again. and It worked. Sorry it was my typo before. Please forget my previous post.

However, now I have another issue.I should have the new variable called nonresident_total with a value 3 because we want to merge all the cases that answered 3 into this new variable. But I have the nonresident_total variable with value 2, 3 and 4 when I run the frequency analysis. The same with resident_total variable. Do you know why and how to fix it?

Thank you again!!

Julie


On Saturday, May 30, 2015 at 7:41:59 AM UTC-4, Bruce Weaver wrote:

Bruce Weaver

unread,
May 30, 2015, 7:49:35 PM5/30/15
to
On 30/05/2015 4:52 PM, Julie Hao wrote:
> Hey Bruce,
>
> I tried the syntax again. and It worked. Sorry it was my typo before. Please forget my previous post.
>
> However, now I have another issue.I should have the new variable called nonresident_total with a value 3 because we want to merge all the cases that answered 3 into this new variable. But I have the nonresident_total variable with value 2, 3 and 4 when I run the frequency analysis. The same with resident_total variable. Do you know why and how to fix it?
>
> Thank you again!!
>
> Julie
>

I don't understand what you want to do. It would help if you provided a
short example showing various combinations of the variables
CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03, and what
you want the new variables to look like afterwards.

Julie Hao

unread,
May 30, 2015, 8:14:24 PM5/30/15
to


There is a variable asking fathers about the status of their children. The variable names are CV_CHILD_STATUS_01, CV_CHILD_STATUS_02, and CV_CHILD_STATUS_03. 01 means the first child of the respondent, 02 means the second child of the respondent , and 03 means the third child. The values of these variables are: 1 adopted out 2 deceased 3 non-resident and 4 resident with respondent


Here is what I want to do: I want to create new variables to merge these variables (CV_CHILD_STATUS_01, CV_CHILD_STATUS_02 and CV_CHILD_STATUS_03 ) answered with the same value into one variable.

For example, I want to merge all the cases that were answered with 1 into a new variable called adoptout_total (see the codebook that i provided 1=adopt out 2=deceased 3=non-resident 4=resident). Merge all the cases that the answer values are 2 into a new variable called deceased_total, merge all the cases that were answered with value 3 into a new variable named nonresident_total, merge all the cases that were answered with a value 4 into a new variable named resident_total. I want to know how many children of respondents were adopted out, how many children were deceased, how many children are non-resident, and how many children are resident with respondents.

For example, for the variable CV_CHILD_STATUS_01, let's just make up the numbers. Let's say 100 cases answered 4 (means fathers have 100 of their first children live with them since 4=resident ), for the variable CV_CHILD_STATUS_02, 50 cases answer 4 (means fathers have 50 of their second children resident with them), for the variable CV_CHILD_STATUS_03, 20 cases answered 4(means fathers have 20 of their third children live with them), 01 in the variable CV_CHILD_STATUS_01 means the first child, 02 in CV_CHILD_STATUS_02 means the second child, 03 means the third child.

I want to create a new variable to sum up all the children who are resident with respondents(fathers), if I create a new variable called resident_total to sum up all the children live with their fathers, I should have 170(100+50+20) children living with their fathers.

How to write a syntax to achieve this? Thank you sooooooo much!


Julie

fur...@mail.gvsu.edu

unread,
May 30, 2015, 10:53:33 PM5/30/15
to
Julie,

It sounds like I did something very similar to what you want to do. I am not by my computer with spss for the weekend, but I can post my syntax for you on Monday. I did use COUNT to do it; however, it is a multiple step process.

Julie Hao

unread,
May 30, 2015, 11:01:56 PM5/30/15
to
On Saturday, May 30, 2015 at 10:53:33 PM UTC-4, fur...@mail.gvsu.edu wrote:
> Julie,
>
> It sounds like I did something very similar to what you want to do. I am not by my computer with spss for the weekend, but I can post my syntax for you on Monday. I did use COUNT to do it; however, it is a multiple step process.

Wow! That sounds great!!! Please do send me your syntax on Monday! Thank you soooo much!

Julie

jasongre...@gmail.com

unread,
Mar 18, 2016, 10:32:48 AM3/18/16
to
Art,

I found what you wrote here highly useful. I was hoping you could help me with a syntax problem as well.

I have four possible combinations of answers to two categorical variables and I need to turn them into one variable.

Variable One Variable Two New Variable
yes yes = Yes
Yes No = No
No No = No
No Yes = Yes

This is what I've been using so far but its incomplete:

IF (var1 eq 4 AND var2 eq 4) newvar=1.

Thank you for any assistance you can give.

Jason

David Marso

unread,
Mar 18, 2016, 2:26:51 PM3/18/16
to
Jason,
This thread is 80 posts deep.
Maybe quoting Art's relevant post would be useful?
At any rate, it looks like your NewVariable is an exact copy of Variable Two.
So what seems to be the problem? Or more likely what are you not telling us?
Your code is mixing 4 with yes and using different variable names?
Please pay attention and post exact variable names and exact code along with whatever error messages and results?
We are pretty good at mind reading but help others help you by formulating a post which makes sense and exhibits internal consistency?

leilaka...@gmail.com

unread,
Apr 15, 2016, 11:40:40 AM4/15/16
to
Hi I have used the below syntax but it doesn't work I receive only a new variable with missing? what is wrong with my syntax? thank you leila
IF (( C10M= 0) & (C10V = 0) & (C10B=0) & (C10Z=0)) newC10= 0.
IF (( C10M= 1) & (C10V = 0) & (C10B=0) & (C10Z=0)) newC10= 1.
IF (( C10M= 0) & (C10V = 1) & (C10B=0) & (C10Z=0)) newC10= 2.
IF (( C10M= 1) & (C10V = 1) & (C10B=0) & (C10Z=0)) newC10= 3.
IF (( C10M= 1) & (C10V = 1) & (C10B=1) & (C10Z=0)) newC10= 4.
IF (( C10M= 1) & (C10V = 0) & (C10B=1) & (C10Z=0)) newC10= 5.
IF (( C10M= 1) & (C10V = 0) & (C10B=0) & (C10Z=1)) newC10= 6.
IF (( C10M= 1) & (C10V = 0) & (C10B=1) & (C10Z=1)) newC10= 7.
IF (( C10M= 0) & (C10V = 1) & (C10B=1) & (C10Z=0)) newC10= 8.
IF (( C10M= 0) & (C10V = 1) & (C10B=0) & (C10Z=1)) newC10= 9.
IF (( C10M= 0) & (C10V = 1) & (C10B=1) & (C10Z=1)) newC10= 10.
IF (( C10M= 0) & (C10V = 0) & (C10B=0) & (C10Z=1)) newC10= 11.
IF (( C10M= 0) & (C10V = 0) & (C10B=1) & (C10Z=0)) newC10= 12.
EXECUTE.

Rich Ulrich

unread,
Apr 15, 2016, 2:14:48 PM4/15/16
to
On Fri, 15 Apr 2016 08:40:37 -0700 (PDT), leilaka...@gmail.com
wrote:
Your syntax is bulky, time-consuming, hard to read, leaves out
3 of the 16 possibilities, and takes no notice of possible Missings
or of values other than 0 and 1.

Try: (for variables whose values are 0/1 without exception)

COMPUTE newC10= C10z+ 2*(C10b+ 2*(C10v + 2*C10m))).
or
COMPUTE newC10= C10z+ 2*C10b+ 4*C10v + 8*C10m.

That gives totals that run from 0 to 15, so they don't match your
0-12.


If there are other values like Missing, and if "1" is the crucial
aspect, as it often is, you can use the same code as above
except replace each variable with (<var> EQ 1) ...
like using 2*(C10b EQ 1) in place of 2*C10b.

--
Rich Ulrich

Bruce Weaver

unread,
Apr 15, 2016, 2:18:12 PM4/15/16
to
It looks like those 4 variables can only take values of 0 or 1, is that correct? What do you want to do in the event of missing values?

sarucher...@gmail.com

unread,
Jun 21, 2016, 8:02:59 AM6/21/16
to
Hie

How to.i join single variables presented in a ranking order. For example different factors into one factor

Bruce Weaver

unread,
Jun 21, 2016, 10:10:29 AM6/21/16
to
On Tuesday, June 21, 2016 at 8:02:59 AM UTC-4, sarucher...@gmail.com wrote:
> Hie
>
> How to.i join single variables presented in a ranking order. For example different factors into one factor

Please provide a small example showing what the data looks like now, and what you want it to look like after you're done.

j.sal...@gmail.com

unread,
Aug 3, 2016, 7:03:34 AM8/3/16
to
Hello everybody,

I have a similar question. I want to merge 2 existing variables into a new one. I have been trying with this syntax, but it's not working at all. How can I do it? I have some combination to comply. Which would be the correct way with Syntax?

The new variable has to be named AB and the cases are these (-99 missing data):

IF (A=0 & B=0) AB=0.
IF (A=0 & B=1) AB=0.
IF (A=1 & B=0) AB=0.
IF (A=1 & B=1) AB=1.
IF (A=-99 & B=0) AB=-99.
IF (A=-99 & B=1) AB=-99.
IF (A=-99 & B=-99) AB=-99.
IF (A=0 & B=-99) AB=0.
IF (A=1 & B=-99) AB=-99.
EXECUTE.

Thanks in advance

David Marso

unread,
Aug 3, 2016, 4:04:49 PM8/3/16
to
Simple Multiplication works to do what you want for
all except the MISSING(A) B=0 case.
--

DATA LIST FREE / A B .
BEGIN DATA
0 0 0 1 1 0 1 1 -99 0 -99 1 -99 -99 0 -99 1 -99
END DATA.

MISSING VALUES A B (-99).
COMPUTE AB = A * B.
/* Note Missing * 0 = 0 */.
IF (MISSING(A) AND B EQ 0) AB = -99.
RECODE AB (SYSMIS = -99).
MISSING VALUES AB (-99).
LIST.

/*Result*/

A B AB

.00 .00 .00
.00 1.00 .00
1.00 .00 .00
1.00 1.00 1.00
-99.00 .00 -99.00
-99.00 1.00 -99.00
-99.00 -99.00 -99.00
.00 -99.00 .00
1.00 -99.00 -99.00

munaja...@gmail.com

unread,
Aug 27, 2016, 8:49:04 AM8/27/16
to
On Friday, May 29, 2009 at 9:08:48 PM UTC+3, southernpsy wrote:
> I am an SPSS novice, and I found this group recently when I was trying
> to determine how to combine two categorical into one variable in SPSS.
> I did not find an answer online, but I did eventually figure out how
> to do it. I decided to post it here to the benefit of others.
>
> I had one variable for Sex (1: Male; 2: Female) and one variable for
> Self-Identified Gender Expression (1: Masculine; 2: Equally or Neither
> Masculine Nor Feminine; 3: Feminine). I wanted to be able to compare
> Masculine Males, et cetera in post hoc analyses.
>
> Here is a template of the syntax that worked for me:
>
> IF ((var1 = 1) & (var2 = 1)) newvar= 1.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 2)) newvar= 2.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 3)) newvar= 3.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 1)) newvar= 4.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 2)) newvar= 5.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 3)) newvar= 6.
> EXECUTE.

Hello Dear
Currently I am doing My thesis under the title of the effect/impact of knowledge management on organizational performance.Unfortunatlly I am stack on the analysis phase. I use SPSS version 20.My Knowledge management has two elements i.e Knowledge enablers (Technology, Organizational Structure and organizational culture) and Knowledge process (knowledge creation, Application, sharing , acquisition). The organizational performance has 3 elements i.e Customer satisfaction, Learning and growth of employee and perceived performance of the organization. Now I have a total of 94 liker scale questionnaire (Strongly Disagree, disagree, neither agree nor disagree, agree and strongly agree) i.e Technology has 8 items, structure 5 items, culture has 8 items knowledge creation 12 items, knowledge application 7 items etc.Now My question is that how do I group and analyses all the Knowledge management (Knowledge enablers and knowledge process) items in one on SPSS (like correlation etc), And organizational performance items in one. Then how do correlate or identify the impact/effect of Knowledge management on organizational performance grouping all this items in one. The other problem is how to make validity and reliability of each group of items as a group and individually. Pls help me on these issues on SPSS 20.
Thank you In advance.

Rich Ulrich

unread,
Aug 29, 2016, 11:43:45 AM8/29/16
to
On Sat, 27 Aug 2016 05:48:58 -0700 (PDT), munaja...@gmail.com
wrote:
[snip, irrelevant post from 2009. This should have been posted
as a new Post with a new Subject.>

>Hello Dear
>Currently I am doing My thesis under the title of the effect/impact of knowledge management on organizational performance.Unfortunatlly I am stack on the analysis phase. I use SPSS version 20.My Knowledge management has two elements i.e Knowledge enablers (Technology, Organizational Structure and organizational culture) and Knowledge process (knowledge creation, Application, sharing , acquisition). The organizational performance has 3 elements i.e Customer satisfaction, Learning and growth of employee and perceived performance of the organization. Now I have a total of 94 liker scale questionnaire (Strongly Disagree, disagree, neither agree nor disagree, agree and strongly agree) i.e Technology has 8 items, structure 5 items, culture has 8 items knowledge creation 12 items, knowledge application 7 items etc.Now My question is that how do I group and analyses all the Knowledge management (Knowledge enablers and knowledge process) items in one on SPSS (like correlation etc), And
>organizational performance items in one. Then how do correlate or identify the impact/effect of Knowledge management on organizational performance grouping all this items in one. The other problem is how to make validity and reliability of each group of items as a group and individually. Pls help me on these issues on SPSS 20.

You probably should have taken a course that included
data management and use of SPSS. I don't know how fully
they can substitute, but you can Google up and read the
tutorial pages on SPSS provided by UCLA.

SPSS lets you compute total scores like this --

COMPUTE Subsc1= mean.7(v1, v8 to v16).
- where the ".7" in the command is optional, and 7 is
whatever number of items you insist must be present
(not "missing") in order to result in a score.

With no replication, your reliability is "internal", for scales; the
procedure RELIABILITY provides Cronbach's alpha for that, among
other numbers. What else can you say about individual items?
- If there are single pairs of items with correlations above (say)
0.90, they may be effectively duplicates; possibly, one should
be dropped. - If there are single items with no high correlations,
those items seem to not-belong to the same universe of items,
and should be examined (say) for ambiguity or other mis-wording.

If there is a clear, underlying factor structure, you might be able
to substantiate the original nominal clusterings of items by
performing a factor analysis (iterate to estimate communalities
and use Varimax rotation) if you have only four or five hundred
cases; though having cases equal to 10 times the number of items
is a safer recommendation. That is, with fewer than 900, do not
be surprised if there is a lot of noise and odd-seeming results.

The analyses dealing with actual hypotheses should (for the
most part) make use of the small set of subscales, and not
the individual items.

--
Rich Ulrich

Wiljamama

unread,
Oct 10, 2016, 11:55:28 AM10/10/16
to
Thank you for this! super helpful!

David Marso

unread,
Oct 10, 2016, 3:02:37 PM10/10/16
to
Please LOSE the EXECUTE commands. Entirely unnecessary and very inefficient.
The following will do the same as that cumbersome code.

COMPUTE newvar=(var1-1)*3 + var2.

edel...@gmail.com

unread,
Nov 1, 2016, 4:30:45 PM11/1/16
to
What would the code be if there was a third variable?

Bruce Weaver

unread,
Nov 2, 2016, 7:37:07 AM11/2/16
to
On Tuesday, November 1, 2016 at 4:30:45 PM UTC-4, edel...@gmail.com wrote:
> What would the code be if there was a third variable?

Does this do what you want?

* A ranges from 1 to nA.
* B ranges from 1 to nB.
* C ranges from 1 to nC.
COMPUTE newvar=(A-1)*nB + B + nA*nB*(C-1).
FORMATS newvar(F5.0).
DESCRIPTIVES newvar.

Bruce Weaver

unread,
Nov 2, 2016, 11:32:16 AM11/2/16
to
Actually, you might like this modified version better, as the numbers will be in an order that is consistent with sorting by A, B and C:

COMPUTE newvar=(B-1)*nC + C + nB*nC*(A-1).

Matt S

unread,
Nov 30, 2016, 8:20:52 AM11/30/16
to
Hello all,

Didnt know which thread would be useful but I'm stuck with this for some months and need some opinion.

In my questionnaire, I asked each of my respondents what was the budget of their last two projects which had 5 categories, this gives me two variables. In the end, I asked them "in which of your last two project did you spend more time on issue X" and this had three categories, more, less and same. Now I am using Kruskal Wallis to see how my three groups differ: more, less and same. The problem is, I don't know what is the best way to compute the change of budget between two projects. Subtracting is not a good idea since 5-3, 4-2, 3-1; all gives 2 but I'm also interested in the fact that the larger the budget gets, the more time spent on issue X. I recoded data as if first project budget is 1 and second project budget is 1, newvar=10 and I repeated this syntax until I reached newvar=34. Any comments will be lifesaving...Sorry if I missed an explanation of solution earlier in the thread

Rich Ulrich

unread,
Dec 6, 2016, 1:28:59 AM12/6/16
to
On Wed, 30 Nov 2016 05:20:51 -0800 (PST), Matt S
<ahmet.an...@gmail.com> wrote:

>Hello all,
>
>Didnt know which thread would be useful but I'm stuck with this for some months and need some opinion.

The standard --and most useful -- thing is to create a
new and unique Subject. You can still do that when you
re-write this question.

>
>In my questionnaire, I asked each of my respondents what was the budget of their last two projects which had 5 categories, this gives me two variables.

Okay, I read that as "budget" answered with five-levels of response
for each of the last two projects. Budget1 and Budget2.

It possibly will be handier for the hypothesis you /seem/ to have
if you insist that Budgets be in order by time - in case it seems
handy to control for that.

>In the end, I asked them "in which of your last two project did you spend more time on issue X" and this had three categories, more, less and same.

- and this makes no sense. The question is "in which..." and the
answer is "more, less and same."
Point 1: the ordered version of those responses is More, Same, Less.
Point 2: you would have obtained far more use if you had asked, for
each, "How much time did you spend ..." with the response (perhaps)
in both hours/days/weeks/months and (in some way) "percent of time".


>Now I am using Kruskal Wallis to see how my three groups differ: more, less and same. The problem is, I don't know what is the best way to compute the change of budget between two projects. Subtracting is not a good idea since 5-3, 4-2, 3-1; all gives 2 but I'm also interested in the fact that the larger the budget gets, the more time spent on issue X. I recoded data as if first project budget is 1 and second project budget is 1, newvar=10 and I repeated this syntax until I reached newvar=34. Any comments will be lifesaving...Sorry if I missed an explanation of solution earlier in the thread

Point 3: If your 5 levels of budget were not chosen to be
approximately equal-interval ... What were you thinking of, instead?

So, is Newvar just a place-holder for all unique combinations of
budget-level? Newvar= 10*Budget1 + Budget2; and Autorecode
if you want a compact set. If you have enough subjects that you
still have multiple cases per category, maybe you can plot means.

This mess reminds me, again, of why it is useful to consult a
statistician and design your study and its data /before/ you
collect it.

--
Rich Ulrich

Matt S

unread,
Dec 8, 2016, 8:28:05 AM12/8/16
to
Thank you very much Rich. I probably made things more confusing, for example the order of answers for the 2nd part was "less, same, more" already which I coded as 1,2,3 in SPSS. I definitely agree on your point 2, it was actually silly to ask for the last 2 projects and not focus on only 1 from the beginning.

In the end, this was the first time I designed a questionnaire and carried out such a study. I mainly did it for learning purposes since my department offer text book courses with no practical support at all. Thank you, now I learnt one more thing :) Have a nice day!

diabeteson...@gmail.com

unread,
Dec 4, 2017, 9:57:56 AM12/4/17
to
On Friday, 29 May 2009 19:08:48 UTC+1, southernpsy wrote:
> I am an SPSS novice, and I found this group recently when I was trying
> to determine how to combine two categorical into one variable in SPSS.
> I did not find an answer online, but I did eventually figure out how
> to do it. I decided to post it here to the benefit of others.
>
> I had one variable for Sex (1: Male; 2: Female) and one variable for
> Self-Identified Gender Expression (1: Masculine; 2: Equally or Neither
> Masculine Nor Feminine; 3: Feminine). I wanted to be able to compare
> Masculine Males, et cetera in post hoc analyses.
>
> Here is a template of the syntax that worked for me:
>
> IF ((var1 = 1) & (var2 = 1)) newvar= 1.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 2)) newvar= 2.
> EXECUTE.
> IF ((var1 = 1) & (var2 = 3)) newvar= 3.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 1)) newvar= 4.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 2)) newvar= 5.
> EXECUTE.
> IF ((var1 = 2) & (var2 = 3)) newvar= 6.
> EXECUTE.

Thank you for sharing. Exactly what I was looking for and no one else seemed to have the same question.
It is loading more messages.
0 new messages