cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mjbauer
Level I

Value Ordering in JMP Script by a Variable

Hello all,

In my data set I will be using a column, called Set, as my x-axis variable in a barchart.  I want them to be sorted in the order from smallest response value to largest response value so I have bars that are increasing in length.  For example if I have the following data:

Set      Response

A          5

B          -7

C          10

I would want the order in the barchart to be B, A, C.  Obviously I can set the property like this:

Set <<Set Property("Value Ordering", {"B", "A", "C"}), but I am trying to do this without needing to hard code the names.  I'd like to be able to do the value ordering BY a variable, specifically by my response.  I want this to be a standard script I can apply to multiple data sets without needing to change it time after time.


Regards,


Michael.

2 ACCEPTED SOLUTIONS

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Value Ordering in JMP Script by a Variable

The below approach is better (oneliner's fun but rarely sufficient...). It should work even if there are ties and also if there are several values for each level and the the value ordering is to be based on e.g. the mean response of each level.

Summarize( g = by( :Set ), m = Mean( :Response ) );

:Set << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );

View solution in original post

bswedlove
Level IV

Re: Value Ordering in JMP Script by a Variable

FYI for JMP 16 to add Value Ordering I had to change the format to:

:col << Set Property(
	"Value Ordering",
	Eval(myList)
);

View solution in original post

7 REPLIES 7
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Value Ordering in JMP Script by a Variable

This apporach should work for the example above. However, it just occurred to me that if two or more levels have exactly the same response it will fail (only one of any tied levels will be represented in the list).

:Set << Set Property( "Value Ordering",  Eval( Associative Array( :Response, :Set ) << get values ));

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Value Ordering in JMP Script by a Variable

The below approach is better (oneliner's fun but rarely sufficient...). It should work even if there are ties and also if there are several values for each level and the the value ordering is to be based on e.g. the mean response of each level.

Summarize( g = by( :Set ), m = Mean( :Response ) );

:Set << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );

Vball247
Level V

Re: Value Ordering in JMP Script by a Variable

I'm replying to this thread because of similar problem for value ordering. I still can't figure out when to use Expr and Eval Expr for Column Properties in JSL for JMP 12 or JMP 13. It seems the general form should work:

 

:Set << Set Property( "Value Ordering", Eval( {mylist} ) );

 

:Set << Set Property( "Value Ordering", Eval( {my1,my2} ) );

 

In the Big Class data, try to set column :sex to put "M" before "F":

 

my1 = "M";

my2 = "F";

:sex << Set Property("Value Ordering",Eval({my1,my2}));

 

But it puts in the text "my1" and "my2" instead of "M" and "F".

 

I copied the post for how to add spec limits as a column property. http://www.jmp.com/support/notes/46/953.html

 

It appears you have to use Expr and Eval Expr just to get the character variables to show. If you try this portion only:

 

:sex << Set Property("Value Ordering",{Expr(my1),Expr(my2)})

 

You get the text "Expr" and "Expr" in the column property. If you include Eval Expr with the Expr, you get returned to the log the correct phrase.

 

Eval Expr(

:sex << Set Property("Value Ordering",{Expr(my1),Expr(my2)})

);

 

returns:

:sex << Set Property( "Value Ordering", {"M", "F"} )

 

and finally this entire code sets the column property correctly.

Eval(

     Eval Expr(

          :sex << Set Property("Value Ordering",{Expr(my1),Expr(my2)})

     )

);

 

The explanation from the spec limits post was "the column stores the column property with the values supplied without evaluation or validation of the supplied arguments. In order to add column properties using JSL code which contains variables, the script must convert any variables to their actual values."

 

Re: Value Ordering in JMP Script by a Variable

Or you can use Eval List to evaluate all members of a list:

 

:sex << Set Property("Value Ordering",Eval List({my1,my2}));
Vball247
Level V

Re: Value Ordering in JMP Script by a Variable

Great! I see that works for this case. But in the spec limits case, that list does not evaluate? I get an error that it does not seem to like the LSL argument when evaluating the list.

 

lLimit = 55;

uLimit = 70;

tLimit = 62.5;

 

:height << Set Property("Spec Limits",

Eval List({LSL(lLimit), USL(uLimit), Target(tLimit)}));

Re: Value Ordering in JMP Script by a Variable

In the first case, the list contains only variable names. The Eval List simply evaluates each variable. In the second case, the list contains things (LSL, USL, Target) that only make sense in the context of the Set Property message as a whole. Eval List doesn't know about that context, so it can't figure out what to do with the first thing it sees: LSL. For that case, you'll have to use the more complex expression that you worked out for the other case.

 

lLimit = 55;
uLimit = 70;
tLimit = 62.5;
 
Eval(
	Eval Expr(
		:height << Set Property(
			"Spec Limits",
			{LSL( Expr( lLimit ) ), USL( Expr( uLimit ) ), Target( Expr( tLimit ) )}
		)
	)
);
bswedlove
Level IV

Re: Value Ordering in JMP Script by a Variable

FYI for JMP 16 to add Value Ordering I had to change the format to:

:col << Set Property(
	"Value Ordering",
	Eval(myList)
);