Login  Register

Re: IF statement to overwite an existing value with a missing value

Posted by Art Kendall-2 on Feb 10, 2007; 2:35pm
URL: http://spssx-discussion.165.s1.nabble.com/Information-about-S-curve-in-SPSS-tp1073784p1073790.html

The approach suggested will work.  However, in the long run it is
advisable to avoid explicitly using $symiss or sysmis on the right hand
side of the assignment operator.

In order to preserve the distinction between user-missing and
system-missing the first statement should be something like
compute p01_var3 = -1.
missing values p01_var3 (lo thru -1).
value labels p01_var3 -1 'initial value set by user'.

The value is *not* missing because the machine could not follow the
user's instruction.  The value is missing because the *user set it to be*.


It is a major help in debugging syntax to reserve system missing to 2
situations
1) when the user tells the system to read data that is not compatible
with the format specified.
This situation is detected from the warnings in the log
The user then edits  the syntax and runs it  again.
This is repeated until there are no more warnings.
Descriptive statistics are then used to explore the data before
transformations are done.
Once the data reading phase has bee debugged it is time to start the
transformations phase.

2) when the user tells the system to do a data transformation that it
cannot do.
This situation is detected because there are warnings in the log and
because values are set to system-missing.
System missing values point to situations where the user's logic did not
accommodate the contingencies encountered in the data.
When this occurs the syntax is edited to correct the syntax to assign
user missing values or valid values as appropriate to the contingency
This is repeated until there are no more warnings.
Descriptive statistics are then used to validate the transformations
before the analysis phase is started.


Art Kendall
Social Research Consultants

Richard Ristow wrote:

> 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
>
>