Here is an example of one way to do this
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
summarize( dt, levels = By( :Age ) );
dtNew = New Table( "Count",
Add Rows( 1 ),
New Column( "Count" )
);
dtNew:Count[1] = N Items( Levels );
Here is a second example that reads the Frequencies table directly and count the number of rows
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// Report snapshot: Big Class - Distribution of sex
dis = Data Table( "Big Class" ) << Distribution( Nominal Distribution( Column( :age ) ) );
dtNew = New Table( "Count2",
Add Rows( 1 ),
New Column( "Count" )
);
// Calculate the number of items in the Frequencies table, minus the
// the last row which is the Totals row
tableLevels = N Items( report(dis)["Frequencies",StringColBox(1)] << get ) - 1;
dtNew:Count[1] = tableLevels;
Jim