cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
robot
Level VI

Is Missing( " " ) returns True?

I would like to differentiate a space cell and an empty cell.  The Is Missing() function interprets both as missing.  Is there a better way?

 

I am using JMP 16.2.0.

 

New Table( "Example",
	Add Rows( 1 ),
	New Column( "Empty", Character, "Nominal", Set Values( {""} ) ),
	New Column( "Empty Missing?",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Is Missing( :Empty ) )
	),
	New Column( "Space", Character, "Nominal", Set Values( {" "} ) ),
	New Column( "Space Missing?",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Is Missing( :Space ) )
	)
)
2 ACCEPTED SOLUTIONS

Accepted Solutions
vince_faller
Super User (Alumni)

Re: Is Missing( " " ) returns True?

A blank is just "" and it seems like JMP trims the inputs of spaces to just be blank again.  

 

Names default to here(1);
dt = New Table( "Example",
	New Column( "Fun", Character, Set Values( {" ", "", "A"} ) ),
	New Column("State", character,  Formula(
		Match(:Fun, 
			"", "Blank", 
			" ", "Space"
		, // else
			"Filled"
		)
	))
);

dt:Fun << Get Values(); // {"", "", "A"}

At least in 16.2

 

I know in earlier versions you couldn't even do ismissing() on non numbers.  

 

Vince Faller - Predictum

View solution in original post

txnelson
Super User

Re: Is Missing( " " ) returns True?

To add to @vince_faller , JMP does convert " " to "" in inputting into a data table, however, it does not conver " a" to "a".  That is, when valid characters do exist in the given cell, JMP maintains the leading spaces( "20" hex).  JMP also has escape strings to input blanks( \!b )( "08" hex ), and nulls( \!0 )( "" hex ).

Jim

View solution in original post

6 REPLIES 6
vince_faller
Super User (Alumni)

Re: Is Missing( " " ) returns True?

A blank is just "" and it seems like JMP trims the inputs of spaces to just be blank again.  

 

Names default to here(1);
dt = New Table( "Example",
	New Column( "Fun", Character, Set Values( {" ", "", "A"} ) ),
	New Column("State", character,  Formula(
		Match(:Fun, 
			"", "Blank", 
			" ", "Space"
		, // else
			"Filled"
		)
	))
);

dt:Fun << Get Values(); // {"", "", "A"}

At least in 16.2

 

I know in earlier versions you couldn't even do ismissing() on non numbers.  

 

Vince Faller - Predictum
txnelson
Super User

Re: Is Missing( " " ) returns True?

To add to @vince_faller , JMP does convert " " to "" in inputting into a data table, however, it does not conver " a" to "a".  That is, when valid characters do exist in the given cell, JMP maintains the leading spaces( "20" hex).  JMP also has escape strings to input blanks( \!b )( "08" hex ), and nulls( \!0 )( "" hex ).

Jim
robot
Level VI

Re: Is Missing( " " ) returns True?

Thanks @vince_faller and @txnelson .  This is not the answer I was hoping for, but it does explain the behavior.

hogi
Level XII

Re: Is Missing( " " ) returns True?

Little to add to what is said. Maybe a question:
"So, there is NO space cell" - no chance to create one?

Interesting, even via a formula, the space is converted to "".

New Table( "Example",
	Add Rows( 1 ),
	New Column( "space and A", Character, "Nominal", Set Values( {" A"} ) ),
	New Column( "Space", Character, "Nominal", Formula( Substr(:space and A,1,1) ) ),
	New Column( "Space Missing?", Formula( Is Missing( :Space ) ))
);

Show("x"||Substr(:space and A[1],1,1) ||"x"); // sure, JSL doesn't lose the space
Show("x"||:space_v2 [1] ||"x") //automatically trimmed, even with a formula!


Under the line, if it's impossible to create a space cell, maybe one could reshape the riddle such that there is a solution.
e.g. don't take the space and save it in the cell - add a character - and then check if it's just a character or a character with a space in front.

hogi
Level XII

Re: Is Missing( " " ) returns True?

I guess there is a rule that trailing spaces are automatically removed from strings when saving them in a data table?
because they are hard to detect (much harder than for leading spaces).
An a simple space " " is treated as trailing space - extremely hard to be seen.

 

Is this rule mentioned in the documentation? couldn't find it ...

View more...
hogi_0-1730896397743.png

 

 

Interesting, this rule even applies for Column Formulas: trailing spaces are simply removed.

hogi_0-1730888106448.png

 

dt = new table("test");
New Column( "input", Character, set values({"ABC","A B"}) );
New Column( "first 2 letters",	Character,	Formula( Substr( :input, 1, 2 ) ));
New Column( "length first_two_letters",	Formula( Length( :first 2 letters ) ))


 

hogi
Level XII

Re: Is Missing( " " ) returns True?

Concerning the original question -  you could answer:
The conclusion "Is Missing( " " ) returns True"   was a bit misleading: The space WAS NO space.

If it's a cell in a data table, the table converted it to "".

Along this line, just open JSL editor and run

show(length(" "))

it returns 

hogi_1-1730888394597.png


So, besides the automatically applied magic in data tables, JSL itself doesn't replace the string,

and therefore:

 

show(is missing(" "))

returns ...

Ouch!
why ?!?!