LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
              value
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 want.

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.

begin data 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 end data.

DO REPEAT 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. END REPEAT. EXE.

This will run COMPUTE for each value of Pxx_VAR4 and Pxx_VAR3.

Does this help?

--jim

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Gary Oliver Sent: Thursday, February 08, 2007 9:57 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: IF statement to overwite an existing value with a missing value

Colleagues

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?

TIA/gary


Back to: Top of message | Previous page | Main SPSSX-L page