spss >> How to compute a dummy variable

by Burger » Tue, 07 Mar 2006 01:51:02 GMT

I have four dummy variables (yes/no). I would like to compute a variable
(Transform > Compute) that is also a dummy variable. It should be 0 when
none of the four dummy variables is 1. Otherwise it should be a 1. Only when
all four dummy variables have no value (no response), the new variable
should also have no value. How can I compute such a variable?



spss >> How to compute a dummy variable

by Bruce Weaver » Tue, 07 Mar 2006 02:20:31 GMT



Does this do what you want?

compute newdum = sum(dum1,dum2,dum3,dum4) GT 0.
exe.

--
Bruce Weaver
XXXX@XXXXX.COM
www.angelfire.com/wv/bwhomedir

spss >> How to compute a dummy variable

by Burger » Tue, 07 Mar 2006 03:24:46 GMT

Thanks!
When I enter the function "sum(dum1,dum2,dum3,dum4) GT 0" in the all the
values of the new variable are "1".
However, I now see that the initial dummy variables are value "1" when no
and "2" when yes, instead of "0" and "1". Perhaps this causes this mistake?
How can I correct this and what does the "GT 0" mean?

"Bruce Weaver" < XXXX@XXXXX.COM > wrote

when

spss >> How to compute a dummy variable

by Bruce Weaver » Tue, 07 Mar 2006 04:42:02 GMT


Yes, it does. Dummy variables have values of 1 and 0. Try this:

recode dum1 dum2 dum3 dum4 (2=0) (else = copy).
exe.

Then try again.

Normally, it is not a good idea to recode a variable back into itself.
But in a case like this, there are no bad consequences if you happen to
run the RECODE command twice. Nothing would happen the second time,
because there would be no 2's left.


GT 0 means greater than 0.

--
Bruce Weaver
XXXX@XXXXX.COM
www.angelfire.com/wv/bwhomedir

spss >> How to compute a dummy variable

by powpow » Tue, 07 Mar 2006 04:46:40 GMT

As far as Bruce's response goes:

The GT means "Greater Than" or ">".

For your specific situation (1's, 2's versus 0,1s), change Bruce's
suggested syntax to the following:

compute newdum = sum(dum1,dum2,dum3,dum4) GE 5.
exe.

Where the GE means "Greater than or equal to" or ">=".

Not the prettiest solution, but it should work.

spss >> How to compute a dummy variable

by MJP » Tue, 07 Mar 2006 19:51:38 GMT


Other

COUNT newdum = Dum1 Dum2 Dum3 Dum4 (2) .
RECODE newdum (1 THRU HI=1).
EXECUTE .


And other

COMPUTE Newdum=(Dum1=2) OR (Dum2=2) OR (Dum3=2) OR (Dum4=2).
EXECUTE.


MJ

spss >> How to compute a dummy variable

by Richard Ulrich » Wed, 08 Mar 2006 06:14:04 GMT


And a neat form for the latter statement is

Compute Newdum= any(2, dum1, dum2, dum3, dum4) .

ANY() is dual purpose; that is, it is possible to say,
"any(value, varlist)" as well as "any(var, value-list)"

--
Rich Ulrich, XXXX@XXXXX.COM
http://www.pitt.edu/ ~wpilib/index.html