cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to use Accelerated Life Testing (ALT) to evaluate reliability. Register for June 5 webinar, 2pm US Eastern Time.

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