if command with missing values

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

if command with missing values

Aenni
Hi there

I'm just trying to code a filter that takes the value of my Manip2 variable if the value in the CheckQ variable is missing, otherwise it should take the value of the CheckQ.

I tried it like this:

compute NestedFil.
do if missing(CheckQ) NestedFil=Manip2.
else NestedFil=CheckQ.
end if.

another option I thought of was this one:
do if (CheckQ = Sysmis).
compute NestedFil=Manip2.
else if NestedFil=CheckQ.
end if.

I guess there is a mistake how I address a missing value in the if statement.
Has someone experience with addressing missing values in an if statement?

Many, many thanks
Anna
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Kirill Orlov
if (CheckQ = Sysmis)
is an illegal statement.
$sysmis keyword can be used in assignment such as
compute var = $sysmis
but not as a condition expression argument
Use sysmis() function instead


26.07.2017 10:24, Aenni пишет:
Hi there

I'm just trying to code a filter that takes the value of my Manip2 variable
if the value in the CheckQ variable is missing, otherwise it should take the
value of the CheckQ. 

I tried it like this:

compute NestedFil. 
do if missing(CheckQ) NestedFil=Manip2.
else NestedFil=CheckQ.
end if.

another option I thought of was this one:
do if (CheckQ = Sysmis).
compute NestedFil=Manip2.
else if NestedFil=CheckQ.
end if. 

I guess there is a mistake how I address a missing value in the if
statement. 
Has someone experience with addressing missing values in an if statement?

Many, many thanks
Anna



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-with-missing-values-tp5734570.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

David Marso
Administrator
In reply to this post by Aenni
CLOSE.
Try:
DO IF MISSING(CheckQ).
COMPUTE NestedFil=Manip2.
ELSE.
COMPUTE NestedFil=CheckQ.
END IF.

OR:
More concisely:

COMPUTE NestedFil=SUM(MISSING(CheckQ)*Manip2,CheckQ).


Aenni wrote
Hi there

I'm just trying to code a filter that takes the value of my Manip2 variable if the value in the CheckQ variable is missing, otherwise it should take the value of the CheckQ.

I tried it like this:

compute NestedFil.
do if missing(CheckQ) NestedFil=Manip2.
else NestedFil=CheckQ.
end if.

another option I thought of was this one:
do if (CheckQ = Sysmis).
compute NestedFil=Manip2.
else if NestedFil=CheckQ.
end if.

I guess there is a mistake how I address a missing value in the if statement.
Has someone experience with addressing missing values in an if statement?

Many, many thanks
Anna
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

MLIves
In reply to this post by Aenni
Why not make NestedFil = to CheckQ then set missing to Manip2?

compute NestedFil=CheckQ.
If (missing(CheckQ)) NestedFil=Manip2.

M
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Aenni
Sent: Wednesday, July 26, 2017 3:25 AM
To: [hidden email]
Subject: [SPSSX-L] if command with missing values

Hi there

I'm just trying to code a filter that takes the value of my Manip2 variable if the value in the CheckQ variable is missing, otherwise it should take the value of the CheckQ.

I tried it like this:

compute NestedFil.
do if missing(CheckQ) NestedFil=Manip2.
else NestedFil=CheckQ.
end if.

another option I thought of was this one:
do if (CheckQ = Sysmis).
compute NestedFil=Manip2.
else if NestedFil=CheckQ.
end if.

I guess there is a mistake how I address a missing value in the if statement.
Has someone experience with addressing missing values in an if statement?

Many, many thanks
Anna



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-with-missing-values-tp5734570.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

________________________________

This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Jon Peck
In reply to this post by Kirill Orlov
To elaborate on Kirill's answer,

It is legal to use sysmis in a conditional statement but as $sysmis.
if x = $sysmis...
but it is useless, because sysmis is not equal to any value - not even itself.  It's best to think of sysmis as a NaN - not a number.  Just because the value is unknown does not mean that it is equal to another unknown.  As Kirill said, the sysmis function tests whether a value is sysmis.

The only arithmetic properties that sysmis has is that sysmis * 0 = 0, sysmis / 0 = 0, and mod(0, sysmis) = 0.

On Wed, Jul 26, 2017 at 5:33 AM, Kirill Orlov <[hidden email]> wrote:
if (CheckQ = Sysmis)
is an illegal statement.
$sysmis keyword can be used in assignment such as
compute var = $sysmis
but not as a condition expression argument
Use sysmis() function instead


26.07.2017 10:24, Aenni пишет:
Hi there

I'm just trying to code a filter that takes the value of my Manip2 variable
if the value in the CheckQ variable is missing, otherwise it should take the
value of the CheckQ. 

I tried it like this:

compute NestedFil. 
do if missing(CheckQ) NestedFil=Manip2.
else NestedFil=CheckQ.
end if.

another option I thought of was this one:
do if (CheckQ = Sysmis).
compute NestedFil=Manip2.
else if NestedFil=CheckQ.
end if. 

I guess there is a mistake how I address a missing value in the if
statement. 
Has someone experience with addressing missing values in an if statement?

Many, many thanks
Anna



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-with-missing-values-tp5734570.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Aenni
In reply to this post by Aenni
Many thanks to all you for the helpful explanations!
It worked out great and I'm learning a lot.
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

PRogman
In reply to this post by Jon Peck
Why does not $sysmis/0 generate  Division-by-0 Error? I don't understand why.
/PRogman

<quote author="Jon Peck">
...

The only arithmetic properties that sysmis has is that sysmis * 0 = 0, sysmis / 0 = 0, and mod(0, sysmis) = 0.

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

Re: if command with missing values

David Marso
Administrator
This post was updated on .
I noted that as well.  Could Jon have intended
0 /sysmis  = 0.
I can't test the sysmis /0 idea at the moment.
<quote author="PRogman">
Why does not $sysmis/0 generate  Division-by-0 Error? I don't understand why.
/PRogman

Jon Peck wrote
...

The only arithmetic properties that sysmis has is that sysmis * 0 = 0, sysmis / 0 = 0, and mod(0, sysmis) = 0.

...
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Kirill Orlov
$sysmis/0 gives error. So, it is all right with it.


26.07.2017 20:09, David Marso пишет:
I noted that as well.  Could Kon have intended
0 /sysmis  = 0.
I can't test the sysmis /0 idea at the moment.

Why does not $sysmis/0 generate  Division-by-0 Error? I don't understand
why.
/PRogman


Jon Peck wrote
...

The only arithmetic properties that sysmis has is that sysmis * 0 = 0,
sysmis / 0 = 0, and mod(0, sysmis) = 0.

...



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-with-missing-values-tp5734570p5734577.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Bruce Weaver
Administrator
In reply to this post by David Marso
DATA LIST LIST / v1(F1).
BEGIN DATA
1
END DATA.
COMPUTE test1 = $sysmis*0.
COMPUTE test2a = $sysmis/0. /* sysmis/0 .
COMPUTE test2b = 0/$sysmis. /* 0/sysmis .
COMPUTE test3 = mod(0,$sysmis).
LIST.

>Warning # 511
>A division by zero has been attempted on the indicated command.  The result
>has been set to the system-missing value.
>Command line: 113  Current case: 1  Current splitfile group: 1


v1    test1   test2a   test2b    test3

 1      .00      .        .00      .00


Number of cases read:  1    Number of cases listed:  1


<quote author="David Marso">
I noted that as well.  Could Jon have intended
0 /sysmis  = 0.
I can't test the sysmis /0 idea at the moment.
PRogman wrote
Why does not $sysmis/0 generate  Division-by-0 Error? I don't understand why.
/PRogman

Jon Peck wrote
...

The only arithmetic properties that sysmis has is that sysmis * 0 = 0, sysmis / 0 = 0, and mod(0, sysmis) = 0.

...
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: if command with missing values

Jon Peck
In reply to this post by PRogman
for the second one, I meant to say 0 / missing = 0

Quoted from the CSR

On Wed, Jul 26, 2017 at 10:12 AM, PRogman <[hidden email]> wrote:
Why does not $sysmis/0 generate  Division-by-0 Error? I don't understand why.
/PRogman


...

The only arithmetic properties that sysmis has is that sysmis * 0 = 0,
sysmis / 0 = 0, and mod(0, sysmis) = 0.

...



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-with-missing-values-tp5734570p5734576.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD