Here is one way of retrieving the frequency counts from a matrix
Names Default To Here( 1 );
dt = // Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );;
ar = dt << getasmatrix( {4, 5} );
dt_freq = New Table( "dt_freq", private, New Column( "groups" ) );
dt_freq:groups << set values( ar[0, 2] );
Summarize( dt_freq, Bygroup = by( :groups ), ngroups = Count( :groups ) );
Close( dt_freq, nosave );
For Each( {value, index}, Bygroup, Bygroup[index] = Num( Bygroup[index] ) );
bygroup = Matrix( bygroup );
theReturned = bygroup || ngroups;
Jim