Date: Thu, 31 Oct 2002 16:54:04 -0600
Reply-To: "Peck, Jon" <peck@spss.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Peck, Jon" <peck@spss.com>
Subject: Re: Why does (missing value) multiplied by zero = zero?
Content-Type: text/plain; charset="iso-8859-1"
The SPSS Syntax Reference explains what is happening here...
Some arithmetic operations involving 0 can be evaluated even when the variables have missing values. These operations are
0*missing = 0
0/missing = 0
mod(0,missing) = 0
----------
You can use the SYSMIS() or MISSING() functions in an expression to achieve different results.
Regards,
Jon Peck
-----Original Message-----
From: Andrew Fenyo [mailto:A.J.Fenyo@ukc.ac.uk]
Sent: Thursday, October 31, 2002 11:27 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: [SPSSX-L] Why does (missing value) multiplied by zero = zero?
Folks,
I have been tearing my hair out, but I cannot see what I am doing wrong!
I have a variable Q and a category TYPE. I need to create two new
variables (QA and QB) which take the value of Q or MISSING depending
on TYPE. It works fine EXCEPT when Q is zero: then I get both QA and QB set
to zero.
I have probably overlooked something very simple, but any suggestions would
be most welcome.
Here is a sample and the syntax:
DATA LIST LIST /TYPE Q.
BEGIN DATA
1 25
1 2
1 0
1 6
1 17
2 6
2 26
2 9999
2 0
2 18
END DATA.
LIST.
MISSING VALUES Q (9999).
COMPUTE ATYPE=2-TYPE.
COMPUTE BTYPE=1-ATYPE.
MISSING VALUES ATYPE BTYPE (0).
LIST.
DO IF MISSING (Q).
COMPUTE QA=-9.
COMPUTE QB=-9.
ELSE.
COMPUTE QA=Q*ATYPE.
COMPUTE QB=Q*BTYPE.
END IF.
MISSING VALUES QA QB (-9).
LIST.
==============================
Andrew Fenyo, Senior Computing Officer
Personal Social Services Research Unit
University of Kent, Canterbury, CT2 7NF
Voice: 01227 827610 Fax: 01227 827038
PSSRU: http://www.ukc.ac.uk/PSSRU