Subscribe Bookmark RSS Feed

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

ron_horne

Super User

Joined:

Jun 23, 2011

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
Solution

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
mikedriscoll

Community Trekker

Joined:

Jun 23, 2011

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

ron_horne

Super User

Joined:

Jun 23, 2011

Thanks Mjdeez,

i was using version 10.

Solution

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.

ron_horne

Super User

Joined:

Jun 23, 2011

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.

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

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
ms

Super User

Joined:

Jun 23, 2011

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

ron_horne

Super User

Joined:

Jun 23, 2011

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

ron_horne

Super User

Joined:

Jun 23, 2011

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 )

);

chungwei

Staff

Joined:

Jun 23, 2011

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