Choose Language Hide Translation Bar
Highlighted

## Sorting Tabulate by Statistic

Hello,

I have I am trying to be able to create a tabular table where I can sort the values by the statistic, such as mean value. So for example, for the sample file "Car Poll",  I have the following basic tabulate code:

Tabulate(

Column Table( Analysis Columns( :age ), Statistics( Mean ) ),

Row Table( Grouping Columns( :size ) )

)

);

Which produces the following pivot table:

Age

size         Mean

Large        33.3

Medium    30.7

Small       30.0

but I would like to be able to sort the means in descending value so the first row shows "Medium " and it's values, 2nd row as "Large", and 3rd row as "Small". I know there is a

Sort(By()) function for data tables, but there doesn't seem to be anything similar for tabulate. Does anyone have a suggestion of how I could achieve this?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Sorting Tabulate by Statistic

I can't find a direct interactive way to sort a tabulate report. However, it acknowledges the value ordering column property.

This code should work to conditionally set value ordering for a column (only tried it in JMP 10):

dt = Open( "\$SAMPLE_DATA/Car Poll.jmp" );

col_list = {:size, :age};

Summarize( g = by( col_list ), m = Mean( col_list ) );

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

dt << Tabulate(

Column Table( Analysis Columns( col_list ), Statistics( Mean ) ),

Row Table( Grouping Columns( col_list ) )

)

);

## Re: Sorting Tabulate by Statistic

I can't find a direct interactive way to sort a tabulate report. However, it acknowledges the value ordering column property.

This code should work to conditionally set value ordering for a column (only tried it in JMP 10):

dt = Open( "\$SAMPLE_DATA/Car Poll.jmp" );

col_list = {:size, :age};

Summarize( g = by( col_list ), m = Mean( col_list ) );

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

dt << Tabulate(