Here is the Scripting Index description of the Col Sum()
Note that the function allows for By Variables. Example 4 from the same Scripting Index entry, illustrates the use of the By variables with columns Age and Sex specified as By variables
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Sum for Each Age and Sex Group",
Formula( Col Sum( :height, :age, :sex ) )
);
With the results
Jim