Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Value Ordering in JMP Script by a Variable

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 25, 2013 1:15 PM
(7483 views)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 **)]** **)** **)**;

6 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 **)****)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 **)]** **)** **)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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."

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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}));`

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Value Ordering in JMP Script by a Variable

Mar 27, 2017 9:30 AM
(6912 views)
| Posted in reply to message from melaniedrake 03/27/2017 10:54 AM

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)}));

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 ) )}
)
)
);
```