cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

How to summarize by variable column names

MuttonChops
Level III

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