System Missing Recode Syntax

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

System Missing Recode Syntax

Jim Moffitt
How would I write syntax to accomplish the following: recode the system
missing value in var 12 to a zero if var 12 is originally system missing
and var 17 and var 21 are not system missing but leave the system
missing value in var 12 as sytem missing if all three variables are
system missing.
 
Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
changed from SM to zero.
If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

<R. Abraham>
Try this:

IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0 .
IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .
EXECUTE .






Jim Moffitt <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>
06/22/2006 03:24 PM
Please respond to
[hidden email]


To
[hidden email]
cc

Subject
System Missing Recode Syntax






How would I write syntax to accomplish the following: recode the system
missing value in var 12 to a zero if var 12 is originally system missing
and var 17 and var 21 are not system missing but leave the system
missing value in var 12 as sytem missing if all three variables are
system missing.

Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
changed from SM to zero.
If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

<R. Abraham>
In reply to this post by Jim Moffitt
I think this should work:

IF (SYSMIS(var12) & NOT(SYSMIS(var17)) & NOT(SYSMIS(var21))) var12=0 .
IF (SYSMIS(var12) & SYSMIS(var17) & SYSMIS(var21)) var12=SYSMIS .
EXECUTE .





Renji Abraham/AAALIFE/US
06/22/2006 04:27 PM

To
[hidden email]
cc

Subject
Re: System Missing Recode Syntax






Try this:

IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0 .
IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .
EXECUTE .






Jim Moffitt <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>
06/22/2006 03:24 PM
Please respond to
[hidden email]


To
[hidden email]
cc

Subject
System Missing Recode Syntax






How would I write syntax to accomplish the following: recode the system
missing value in var 12 to a zero if var 12 is originally system missing
and var 17 and var 21 are not system missing but leave the system
missing value in var 12 as sytem missing if all three variables are
system missing.

Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
changed from SM to zero.
If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Richard Ristow
In reply to this post by Jim Moffitt
At 03:24 PM 6/22/2006, Jim Moffitt wrote:

>How would I write syntax to accomplish the following: recode the
>system missing value in var 12 to a zero if var 12 is originally
>system missing and var 17 and var 21 are not system missing but leave
>the system missing value in var 12 as sytem missing if all three
>variables are system missing.
>
>Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
>changed from SM to zero.
>If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.

Oh, well. A little bit of code that's relaxing to write. Except I
haven't tested it, and there's nothing easier than making a typo or
other silly mistake in 'easy' code.

DO IF NVALID(VAR17,VAR21) GT 0.
.  RECODE VAR12 (SYSMIS = 0).
END IF.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Oliver, Richard
In reply to this post by Jim Moffitt
I don't think that will work for several reasons:

1. When setting something to system-missing, you need to specify the system variable with a leading dollar sign, as in: var12=$sysmis.

2. When evaluating missing status in commands like IF or DO IF, I think you need to use the sysmis function, as in:

if sysmis(var12) & not(sysmis(var17)) & not(sysmis(var21)) var12=0.

I'm not 100% sure, but I think the general form "if varname=$sysmis" always evaluates to missing, which means the condition is never met.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Renji Abraham
Sent: Thursday, June 22, 2006 3:27 PM
To: [hidden email]
Subject: Re: System Missing Recode Syntax

Try this:

IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0 .
IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .
EXECUTE .






Jim Moffitt <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>
06/22/2006 03:24 PM
Please respond to
[hidden email]


To
[hidden email]
cc

Subject
System Missing Recode Syntax






How would I write syntax to accomplish the following: recode the system
missing value in var 12 to a zero if var 12 is originally system missing
and var 17 and var 21 are not system missing but leave the system
missing value in var 12 as sytem missing if all three variables are
system missing.

Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
changed from SM to zero.
If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

<R. Abraham>
I did try to correct the 'SYSMIS' part it in my second reply. but still I
missed the $ sign.

Thanks for the correction.





"Oliver, Richard" <[hidden email]>
06/22/2006 05:06 PM

To
<[hidden email]>, <[hidden email]>
cc

Subject
RE:      Re: System Missing Recode Syntax






I don't think that will work for several reasons:

1. When setting something to system-missing, you need to specify the
system variable with a leading dollar sign, as in: var12=$sysmis.

2. When evaluating missing status in commands like IF or DO IF, I think
you need to use the sysmis function, as in:

if sysmis(var12) & not(sysmis(var17)) & not(sysmis(var21)) var12=0.

I'm not 100% sure, but I think the general form "if varname=$sysmis"
always evaluates to missing, which means the condition is never met.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Renji Abraham
Sent: Thursday, June 22, 2006 3:27 PM
To: [hidden email]
Subject: Re: System Missing Recode Syntax

Try this:

IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0 .
IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .
EXECUTE .






Jim Moffitt <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>
06/22/2006 03:24 PM
Please respond to
[hidden email]


To
[hidden email]
cc

Subject
System Missing Recode Syntax






How would I write syntax to accomplish the following: recode the system
missing value in var 12 to a zero if var 12 is originally system missing
and var 17 and var 21 are not system missing but leave the system
missing value in var 12 as sytem missing if all three variables are
system missing.

Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
changed from SM to zero.
If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Keith McCormick
In reply to this post by Jim Moffitt
Hi Jim,

I didn't create fake data to test this, but this should do the trick.

DO IF ( SYSMIS(var12) AND NOT(SYSMIS(var17) and NOT(SYSMIS(var21) ) .
RECODE var12 (SYSMIS=0)  .
END IF.

Since you want the value to remain unchanged in the second instance,
there should be no reason to explicitly state it.  Recode leaves
anything left unstated as unchanged.

But ... if you wanted to add more DO IF can accept and ELSE IF and ELSE as well.

Best, Keith
keithmccormick.com



On 6/22/06, Jim Moffitt <[hidden email]> wrote:

> How would I write syntax to accomplish the following: recode the system
> missing value in var 12 to a zero if var 12 is originally system missing
> and var 17 and var 21 are not system missing but leave the system
> missing value in var 12 as sytem missing if all three variables are
> system missing.
>
> Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
> changed from SM to zero.
> If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
>
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Keith McCormick
There was a delay in my email getting sent.  Forgive the redundancy.

On 6/22/06, Keith McCormick <[hidden email]> wrote:

> Hi Jim,
>
> I didn't create fake data to test this, but this should do the trick.
>
> DO IF ( SYSMIS(var12) AND NOT(SYSMIS(var17) and NOT(SYSMIS(var21) ) .
> RECODE var12 (SYSMIS=0)  .
> END IF.
>
> Since you want the value to remain unchanged in the second instance,
> there should be no reason to explicitly state it.  Recode leaves
> anything left unstated as unchanged.
>
> But ... if you wanted to add more DO IF can accept and ELSE IF and ELSE as well.
>
> Best, Keith
> keithmccormick.com
>
>
>
> On 6/22/06, Jim Moffitt <[hidden email]> wrote:
> > How would I write syntax to accomplish the following: recode the system
> > missing value in var 12 to a zero if var 12 is originally system missing
> > and var 17 and var 21 are not system missing but leave the system
> > missing value in var 12 as sytem missing if all three variables are
> > system missing.
> >
> > Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
> > changed from SM to zero.
> > If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Jim Moffitt
Thanks, Keith. I appreciate the help.

-----Original Message-----
From: Keith McCormick [mailto:[hidden email]]
Sent: Thursday, June 22, 2006 5:09 PM
To: Moffitt, James (West)
Cc: [hidden email]
Subject: Re: System Missing Recode Syntax

There was a delay in my email getting sent.  Forgive the redundancy.

On 6/22/06, Keith McCormick <[hidden email]> wrote:

> Hi Jim,
>
> I didn't create fake data to test this, but this should do the trick.
>
> DO IF ( SYSMIS(var12) AND NOT(SYSMIS(var17) and NOT(SYSMIS(var21) ) .
> RECODE var12 (SYSMIS=0)  .
> END IF.
>
> Since you want the value to remain unchanged in the second instance,
> there should be no reason to explicitly state it.  Recode leaves
> anything left unstated as unchanged.
>
> But ... if you wanted to add more DO IF can accept and ELSE IF and
ELSE as well.

>
> Best, Keith
> keithmccormick.com
>
>
>
> On 6/22/06, Jim Moffitt <[hidden email]> wrote:
> > How would I write syntax to accomplish the following: recode the
> > system missing value in var 12 to a zero if var 12 is originally
> > system missing and var 17 and var 21 are not system missing but
> > leave the system missing value in var 12 as sytem missing if all
> > three variables are system missing.
> >
> > Example: If Var 12=SM and  Var 17=1 and Var 21=SM, Var 12 should be
> > changed from SM to zero.
> > If Var 12=SM and  Var 17=SM and Var21=SM, Var 12 should remain SM.
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Richard Ristow
In reply to this post by Oliver, Richard
Regarding the proposed

>>IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0
>>.
>>IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .

at 05:06 PM 6/22/2006, Oliver, Richard wrote:

>I don't think that will work for several reasons:
>
>1. When setting something to system-missing, you need to specify the
>system variable with a leading dollar sign, as in: var12=$sysmis.
>
>2. When evaluating missing status in commands like IF or DO IF, I
>think you need to use the sysmis function, as in:
>
>if sysmis(var12) & not(sysmis(var17)) & not(sysmis(var21)) var12=0.
>
>I'm not 100% sure, but I think the general form "if varname=$sysmis"
>always evaluates to missing, which means the condition is never met.

Right. And a very interesting difference between how SPSS and SAS
handle 'missing' in logical expressions.

(Next step: Now that SPSS gives a warning when a loop is terminated by
reaching MXLOOPS, it should probably give a warning when a test
evaluates 'missing'.)

You can also write

.  if sysmis(var12) & not(sysmis(var17)) & not(sysmis(var21)) var12=0.

as

.  if sysmis(var12) & NMISS(var17,var21) NE 0 var12=0.

(That's not *quite* equivalent, if var17 and var21 have user-missing
values defined. There should probably be an "NSYSMIS" function,
analogous to NMISS and NVALID.)


can be written more compactly as

.  if
Reply | Threaded
Open this post in threaded view
|

Re: System Missing Recode Syntax

Peck, Jon
In reply to this post by Jim Moffitt
A word on SPSS logic for missing: system missing represents the absence of information.  Since two instances of no information does not mean that those instances are equal to each other (or that they are not equal to each other), it follows logically that the test
$sysmis eq $sysmis
or
x eq $sysmis
always has to result in an indeterminate, i.e., missing, answer.

The missing value functions allow you to deal with the case where you want to know whether a value is sysmis or not, which is a subtly different question.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow
Sent: Friday, June 23, 2006 12:15 AM
To: [hidden email]
Subject: Re: [SPSSX-L] System Missing Recode Syntax

Regarding the proposed

>>IF ((var12=SYSMIS) & (NOT(var17=SYSMIS) & NOT(var21=SYSMIS))) var12=0
>>.
>>IF ((var12=SYSMIS) & (var17=SYSMIS) & (var21=SYSMIS)) var12=SYSMIS .

at 05:06 PM 6/22/2006, Oliver, Richard wrote:

>I don't think that will work for several reasons:
>
>1. When setting something to system-missing, you need to specify the
>system variable with a leading dollar sign, as in: var12=$sysmis.
>
>2. When evaluating missing status in commands like IF or DO IF, I
>think you need to use the sysmis function, as in:
>
>if sysmis(var12) & not(sysmis(var17)) & not(sysmis(var21)) var12=0.
>
>I'm not 100% sure, but I think the general form "if varname=$sysmis"
>always evaluates to missing, which means the condition is never met.

Right. And a very interesting difference between how SPSS and SAS
handle 'missing' in logical expressions.