Date: Fri, 9 Feb 2007 17:21:22 -0500
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: IF statement to overwite an existing value with a missing
value
In-Reply-To: <9B4E9074BAEA474FA68BCBFCD1EB81AA01E59B9C@valentino.lodgene t.com>
Content-Type: text/plain; charset="iso-8859-1"; format=flowed
At 03:43 PM 2/9/2007, Marks, Jim wrote:
>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.
Touché. That's the way we did it before DO IF was
introduced. It's shorter, easier to write, and
easier to get right, than the DO IF solution I gave:
>>DO IF ( P01_VAR4 > 0 )
>> AND NOT MISSING( P01_VAR4 > 0 ).
>>. COMPUTE P01_VAR3 = P01_VAR1 .
>>ELSE.
>>. COMPUTE P01_VAR3 = $SYSMIS.
>>END IF.
There's a lot to be said for remembering old-school styles.
Jim also wrote,
>It looks like you have a set of variables to process. If so, something
>using DO REPEAT could reduce your typing:
Yes. Reduce your typing, make your code shorter
and more readable, and be less prone to errors.
-Good luck, and thanks,
Richard
|