cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
MuttonChops
Level III

How to summarize by variable column names

I have a table with variable numeric, continuous column names.  I need to get the mean of each column, grouped by a different column.  The script below shows what I'm trying to do and it makes a generic table that works for this purpose.  I'm getting hung up on the "Mean(ColNames)" line because it can't seem to process that.  

 

If I replace "Mean(ColNames)" with "Mean(:Col2, :Col3)" or "Mean(:Name("Col2"), :Name("Col3"))" then it works but obviously doesn't meet my need of being able to use variable columns.  Am I close or way off?

 

 


// Make a table to work with nr = 20; nc = 3; dt = NewTable("Random_Table"); For(c=1, c<=nc, c++, dt << NewColumn("Col"||Char(c), Numeric, Continuous, Formula(RandomInteger(1, 10))); ); dt << AddRows(nr); Column(1) << Data Type(Character); //Get column names for the numeric continuous columns ColNames = dt << Get Column Names(Numeric, "Continuous"); dt << Summary( Group(:Col1), Mean(ColNames), statistics column name format( "column" ) );

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to summarize by variable column names

Put and Eval() around the columns list and it will work

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");

ColNames = dt << Get Column Names(Numeric, "Continuous");

dt << Summary(
		Group(:sex),
		Mean(eval(ColNames)),
		statistics column name format( "column" )
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: How to summarize by variable column names

Put and Eval() around the columns list and it will work

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");

ColNames = dt << Get Column Names(Numeric, "Continuous");

dt << Summary(
		Group(:sex),
		Mean(eval(ColNames)),
		statistics column name format( "column" )
);
Jim

Recommended Articles