Subscribe Bookmark RSS Feed

Max() behavior - different from JMP 12 vs JMP 11?

djhanson

Community Trekker

Joined:

Jun 23, 2011

Why doesn't the following work in JMP 12 anymore?

 

Example, I have a column "WW" with entries like ("17WW01","17WW02","17WW03"..."17WW05").

And I want to find the latest workweek in the "WW" column (charcter/nominal in both JMP versions):

 

current_ww = Max(Associative Array(:WW << Get As Matrix()) << Get Keys);

 

JMP 11.1.1 => this works fine.  current_ww = "17WW05"

JMP 12.2.0 => this doesn't work anymore.  current_ww = .

 

Why is that?  Is Max() now super restrictive in JMP 12?   DJ

2 ACCEPTED SOLUTIONS

Accepted Solutions
melaniedrake

Staff

Joined:

May 30, 2014

Solution

This was changed on purpose - Max() is a numeric function, like Mean() or Std Dev().

 

For strings, you can use Sort Ascending or Sort Descending. For example:

 

current_ww = Sort Descending(Associative Array(:WW << Get As Matrix()) << Get Keys)[1];
danschikore

Staff

Joined:

Sep 21, 2012

Solution

Thanks for your feedback on this.  We should have issued a JSL compabitility note with this change - part of the issue is that the change affected a number of numeric functions.  We will be updating the documentation with a future release.

 

It should be noted that the function never really worked correctly on strings.  Note that expanding the example above:

 

lst = {"17WW01", "17WW02", "17WW03", "17WW04", "17WW05"};
Show(Max(lst));
Show(Min(lst));

 The two answers come back the same.  The bug in JMP 11 (and prior) is that the result that you were seeing is a side-effect of the evaluation of the arguments.

7 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Apparently it has changed.  Neither JMP 12 or JMP 13 returns the same results as JMP 11.

Jim
markbailey

Staff

Joined:

Jun 23, 2011

I took it apart to see where it breaks down. I think that it is a bug. Here is the first part:

aa = Associative Array( :WW << Get As Matrix );
k = aa  << Get Keys;

This expression evaluates to:

Associative array( 5 elements ) assigned.
{"17WW01", "17WW02", "17WW03", "17WW04", "17WW05"}

Finally, I made a valid expression

max expr = Expr( Maximum() );
For( item = 1, item <= N Items( k ), item++,
	Insert Into( max expr, k[item] );
);
Show( Name Expr( max expr ) );

I get this result:

Name Expr(max expr) = Maximum("17WW01", "17WW02", "17WW03", "17WW04", "17WW05");

This is a valid call to the Maximum function. If the multiple arguments appear like this and not in a list or a matrix, then they must all be numeric or all character strings. Clearly this example meets the requirement. When I evaluate this expression, however, I get this result:

need arguments to be scalars, matrices, or lists in access or evaluation of 'Maximum' , Maximum/*###*/("17WW01", "17WW02", "17WW03", "17WW04", "17WW05")

If I try to use the original list of keys:

Name Expr(max expr) = Maximum({"17WW01", "17WW02", "17WW03", "17WW04", "17WW05"});

I don't get the error message. I get only the missing value as report in the original post.

Looks like a bug.

Learn it once, use it forever!
David_Burnham

Super User

Joined:

Jul 13, 2011

I took it apart in a different way:

 

lst = {"17WW01", "17WW02", "17WW03", "17WW04", "17WW05"};
Max(lst);

This returns a value in JMP 11 but an empty value in 12 or 13.  I guess the workaround would be to sort the list and take the last item.  Not sure if the change of behaviour is a bug or a feature.

-Dave
djhanson

Community Trekker

Joined:

Jun 23, 2011

And of course this came back to haunt me today on a critical script. (migrating from JMP11 to JMP12).  I will report this to JMP though they likely won't do anything about it I suppose.  Definitely a JMP12 bug in my mind, as the max function states it can find the max of a string list (as it used to do fine in JMP11).  DJ

melaniedrake

Staff

Joined:

May 30, 2014

Solution

This was changed on purpose - Max() is a numeric function, like Mean() or Std Dev().

 

For strings, you can use Sort Ascending or Sort Descending. For example:

 

current_ww = Sort Descending(Associative Array(:WW << Get As Matrix()) << Get Keys)[1];
djhanson

Community Trekker

Joined:

Jun 23, 2011

"This was changed on purpose - Max() is a numeric function, like Mean() or Std Dev().

 For strings, you can use Sort Ascending or Sort Descending. For example:"

 

But that's not what it says on the JMP12 hover help tip.  It says it can do max of strings too in JMP12.  So yeh, it changed, but the JMP12 documentation failed to change.  This is why folks don't like changing to new JMP versions, because of hidden changes like this.  In my case a critical JSL script for my company was working great in JMP11, then we migrate to JMP12 and it crashes.  DJ

danschikore

Staff

Joined:

Sep 21, 2012

Solution

Thanks for your feedback on this.  We should have issued a JSL compabitility note with this change - part of the issue is that the change affected a number of numeric functions.  We will be updating the documentation with a future release.

 

It should be noted that the function never really worked correctly on strings.  Note that expanding the example above:

 

lst = {"17WW01", "17WW02", "17WW03", "17WW04", "17WW05"};
Show(Max(lst));
Show(Min(lst));

 The two answers come back the same.  The bug in JMP 11 (and prior) is that the result that you were seeing is a side-effect of the evaluation of the arguments.