The Summary command creates a new table of summary statistics according to the grouping columns that you specify. Do not confuse Summary with Summarize, which collects summary statistics for a data table and stores them in global variables. See Store Summary Statistics in Global Variables.
summDt = dt << Summary(
Group( groupingColumns ),
Subgroup( subGroupColumn ),
Statistic( columns ),// where statistic is Mean, Min, Max, Std Dev, and so on.
Output Table Name( newName ) );
The following example creates a new table with columns for the mean of height and weight by age, and the maximum height and minimum weight by age:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
summDt = dt << Summary(
Group( :age ),
Mean( :height, :weight ), Max( :height ), Min( :weight ),
Output Table Name( "Height-Weight Chart" ) );
Tip: Output Table Name can take a quoted string or a variable that is a string.
By default, a summary table is linked to the original data table. If you want to produce a summary that is not linked to the original data table, add this option to your Summary message:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
summDt = dt << Summary( Group( :age ), Mean( :height ),
Link to Original Data Table( 0 )
);
You can choose to add marginal statistics for grouping variables to the output columns of your data table. JMP also adds a row to the end of the data table that summarizes each level of the grouping variables. To add marginal statistics, add this option to your Summary message:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
summDt = dt << Summary( Group( :age ), Mean( :height ),
Include marginal statistics
);
You can specify the format of the statistics column name using statistics column name format(). Statistics Column Name Format Options and Examples shows the option and examples:
Option |
Example |
---|---|
stat (column) |
Mean (Profits ($M)) |
column |
Profits ($M) |
stat of column |
Mean of Profits ($M) |
column stat |
Profits ($M) Mean |
For example, add an option like this to your Summary message:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
summDt = dt << Summary( Group( :age ), Mean( :height ),
statistics column name format( "stat of column" )
);
The height column is named Mean of height.