If-function else-clause not recognizing missing values<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />If I add an If-function to a column, the else-clause does not recognize empty values (see attached sheet). this means that the function:
If( :Column 2 == 1, 1,
2 )
leaves missing values if Column 2 contains missing values. I can fix this by changing the function to:
If( :Column 2 == 1, 1,
Is Missing( :Column 2 ), 2)
or
If( :Column 2 == 1, 1,
Is Missing( :Column 2 ), 2,
2)
but why is this necessary? Is it a bug or a deliberate "feature"?
Re: If-function else-clause not recognizing missing valuesI think I came to the same conclusion upon more consideration. That "missing" is not the same as "X is equal to five" in your example. Or whatever else may be placed in the "else" clause.
Thank you
Re: If-function else-clause not recognizing missing valuesIf you want to understand why it behaves this way, run this code in your head (and then try it in JMP):
x = .;If( x < 5, Show( "X is less than five" ), x>5, Show( "X is greater than five" ), Show("X is equal to five"));What did you think it would do?
Re: If-function else-clause not recognizing missing valuesThis behavior is intentional and is associated with the propagation of missing values. Your can read a bit about it in the Conditional Functions section of the JMP Scripting Guide.
You should always include a check for missing values in your conditionals.
-Jeff