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
- :
- Re: summary table sorted in the wrong order if there are value labels

- 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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 16, 2015 4:21 PM
(8968 views)

hi all,

just wondered if i came across a bug in the program.

table summary is known to produce a sorted table by the grouping variable. i just noticed it is not the case if there are value labels (and no value ordering).

for example:

Open( "$SAMPLE_DATA/Big Class.jmp" );

// this will produce a correctly sorted table

Data Table( "Big Class" ) << Summary( Group( :age ), Link to original data table( 0 ) );

// and here is where thing go a bit funny

:age << value labels( {13 = "thirteen"} );

Data Table( "Big Class" ) << Summary( Group( :age ), Link to original data table( 0 ) );

1 ACCEPTED SOLUTION

Accepted Solutions

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

In summary, the categories of the grouping column are ordered by the labels of the corresponding values.

For categories without labels, their values are formatted into text strings and ranked after the sorted labels (or before, if sorting the grouping column in descending order).

This is what you observed in your example.

12 REPLIES 12

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

Re: summary table sorted in the wrong order if there are value labels

Your script didn't behave as you describe. When I ran your code, it applied the :age <<value labels() command to the first summary table, and it was already sorted and therefore in the correct order.

This modified code behaves as you describe. I don't have an answer for you as to why it is happening but maybe it will help someone else trouble shoot. I'm running JMP standard 11.2

Open( "$SAMPLE_DATA/Big Class.jmp" );

dt = current data table();

// this will produce a correctly sorted table

Data Table( "Big Class" ) << Summary( Group( :age ), Link to original data table( 0 ) );

// and here is where thing go a bit funny

//as column(dt, :age) << value labels( {13 = "thirteen"} ); // <-- for some reason this doesn't change the "Big Class" table for me. It still changes the above summary table even though i specify dt. Use below code to fix it.

current data table(dt);

:age << value labels( {13 = "thirteen"} );

Data Table( "Big Class" ) << Summary( Group( :age ), Link to original data table( 0 ) );

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

Re: summary table sorted in the wrong order if there are value labels

Thanks Mjdeez,

i was using version 10.

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

In summary, the categories of the grouping column are ordered by the labels of the corresponding values.

For categories without labels, their values are formatted into text strings and ranked after the sorted labels (or before, if sorting the grouping column in descending order).

This is what you observed in your example.

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

Re: summary table sorted in the wrong order if there are value labels

thanks ChungWei,

i just find it a little surprising the sorting is done by labels and not by value. i was actually counting on the sorting and was not expecting this at all. if it is intended it is probably trying to think one step ahead of the user.

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

Re: summary table sorted in the wrong order if there are value labels

I think the issue here is what should JMP do if there are two different values mapped to the same value label.

In your example you've only got one but consider this:

Open

("$SAMPLE_DATA/Big Class.jmp");dt = current data table

();:age <<

value labels({13= "thirteen",17="thirteen"});Data Table

("Big Class")<<Summary(Group(:age), Link to original data table(0));

Since "thirteen" now represents two different ages it can't sort in either place.

-Jeff

-Jeff

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

Re: summary table sorted in the wrong order if there are value labels

While that makes sense, Jeff, Graph Builder() seems to disagree with Summary() on how to sort categories with value labels.

dt = Open**(**"$SAMPLE_DATA/Big Class.jmp"**)**;

dt:age << **value labels****({****13** = "thirteen", **17** = "thirteen"**})**;

dtsum=**(**dt << **Summary****(**Group**(**:age**)))**;

dtsum << **Graph Builder****(**Variables**(**X**(**:age**)**, Y**(**:N Rows**)))**;

// And "thirteen" seems to represent 13 only

Show**(**dtsum:age << **get values**, Col Sum**(**dtsum:age**))**;

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

Re: summary table sorted in the wrong order if there are value labels

Thanks Jeff and MS.

i just find it inappropriate that jmp takes value labels and all the sudden assumes the user has intended to recode the variable.

ron

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

Re: summary table sorted in the wrong order if there are value labels

thanks Jeff, this behavior of "recoding" by value labels does not happen (an shouldn't) in any of the analysis platforms.

even in other table menu options it doesn't do it such as split.

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt:age << value labels({13 = "thirteen", 17 = "thirteen"});

Data Table( "Big Class" ) << Split(

Split By( :age ),

Split( :height, :weight ),

Remaining Columns( Drop All )

);

Highlighted
##

When somebody assigns the same label to 2 different values, wouldn't you think that he would like to group the 2 together ?

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

Re: summary table sorted in the wrong order if there are value labels