# System Missing Recode Syntax

11 messages
Open this post in threaded view
|
Report Content as Inappropriate

## 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.
Open this post in threaded view
|
Report Content as Inappropriate

## 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.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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. >
Open this post in threaded view
|
Report Content as Inappropriate

## 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. > > >
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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. > > >
Open this post in threaded view
|
Report Content as Inappropriate

## Re: System Missing Recode Syntax

 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