The table message dt << Color Rows By Row State() seems to be a "view" statement. The table view is changed, but saving the table and opening it or journaling does not maintain the colored cells. Journaling that table will create a report in the Journal with the table font colors rmatching the row state colors.
However, col << Color Cells( clr, rows) is a column message. This message is stored in the table column's attributes. Also when journaling the cell color is maintained.
Below both script and result are displayed below. Note another method (might be more direct) would be to get the unique keys for each group (age), get the rows for each age, then pick a color and apply it to those rows of each column.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Color by Column( :age );
Wait( 0 );
//This next command does not save the cell colors.
//dt << Color Rows by Row State;
dt << Clear column selection();
dt << clear select;
//get the unique colors
nr = N Row( dt );
//make a list the size of the table to get the row colors and locate rows of a given color
_clr = As List( J( nr, 1, 0 ) );
For( i = 1, i <= N Row( dt ), i++,
_clr[i] = Color To RGB( Color Of( Row State( i ) ) )
);
//creates a list of unique colors
clr_keys = Associative Array( _clr ) << get keys;
//for each color (j), locate which rows are assigned that color using Loc( _clr, ...)
For( j = 1, j <= N Items( clr_keys ), j++,
idx = Loc( _clr, clr_keys[j] );
//Color the cells in rows idx and each coloumn
For( i = 1, i <= N Col( dt ), i++,
Column( dt, i ) << color cells( RGB Color( clr_keys[j] ), idx )
);
);
//now journal the table
dt << journal;
![image.png image.png](https://community.jmp.com/t5/image/serverpage/image-id/15020i50EE4F4F79035F11/image-size/large?v=v2&px=999)