Is this what you are after? Do 'File > New Script', copy and paste the code below, then 'Edit > Run Script'.
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column( "Mean weight Grouped by age", Formula( Col Mean( :weight, :age ) ) );
If so, take a look at the formula column in the table. Using 'Help > Scripting Index' gives some other possibilities:
Screenshot 2020-03-24 at 10.03.20.png