Date: Fri, 9 Feb 2007 14:43:55 -0600
Reply-To: "Marks, Jim" <Jim.Marks@lodgenet.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Marks, Jim" <Jim.Marks@lodgenet.com>
Subject: Re: IF statement to overwite an existing value with a missing
Content-Type: text/plain; charset="US-ASCII"
A statement like:
COMPUTE P01_VAR3 = $SYMSIS.
IF P01_VAR4 > 0 P01_VAR3 = P01_VAR1.
Will reset all the values and populate P01_VAR3 with the values you
It looks like you have a set of variables to process. If so, something
using DO REPEAT could reduce your typing:
*** SAMPLE DATA.
data list free /id P01_VAR4 P02_VAR4 P03_VAR4 P01_VAR1.
1 2 2 0 0 0 5
2 1 1 1 1 0 5
3 0 0 0 0 0 5
4 1 2 3 4 5 5
5 0 0 0 0 1 5
x = P01_VAR4 P02_VAR4 P03_VAR4 P04_VAR4
/y = P01_VAR3 P02_VAR3 P03_VAR3 P04_VAR3
COMPUTE Y = $SYSMIS.
IF X >0 Y =P01_VAR1.
This will run COMPUTE for each value of Pxx_VAR4 and Pxx_VAR3.
Does this help?
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Thursday, February 08, 2007 9:57 PM
Subject: IF statement to overwite an existing value with a missing value
I have the following set of IF statements which successfully execute.
IF ( P01_VAR4 > 0 ) P01_VAR3 = P01_VAR1 .
IF ( P35_VAR4 > 0 ) P35_VAR3 = P01_VAR1 .
In some cases the value for VAR3 is zero and I rightly get a warning
message and the cell is marked with a dot for missing value.
The command has evolved over a week of modifying the calculation with
the result that the cells contain pre-existing values. What I have
noticed is that the IF statement above does not replace the pre-existing
values with a blank cell.
My questions are:
(a) Is there a command that I can apply to a variable to clear values?
I cannot see anything in the syntax help file that
erases/deletes/removes values. These key words only seem to apply to
files or variables themselves.
(b) Is there an amendment to the syntax which can force a missing value
to be inserted overriding whatever is in the cell?