cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
brianm
Level I

JMP - How to pass a dynamic list of columns to Summary()

Hi,

I want to open a data table (using Big Class.jmp as example, but want to do this for any table) and create a summary table for each column, returning the number of non-missing values for each column (as shown in table below).

N RowsN(name)N(age)N(sex)N(height)N(weight)
404040404040

I have tried two different approaches to this and have had no success (I'm using JMP 9.0.3 64bit).

In the first example, I try to pass a list of parsed strings {N(:name),N(:age),N(:sex),N(:height),N(:weight)} to Summary(). However, when I run this, it only creates a summary table with N Rows.

Example1

///////////////////////////////////////////////////////////////////////////////

Open( "$SAMPLE_DATA/Big Class.jmp" );

dt = current data table();

colList = dt<<Get Column Names();

icols = N Items(colList);

sumList={};

for(i=1, i<=icols, i++,

    Insert Into(sumList, parse("N(:" || char(colList) || ")"))

);

summDt = dt<<Summary(Group, Eval(sumList), output table name("Summary_Table"));

///////////////////////////////////////////////////////////////////////////////

I then tried to define an expression and pass a parsed string (N(:name),N(:age),N(:sex),N(:height),N(:weight)). However, when I try to evaluate this expression, I get the following...

Unexpected ",". Perhaps there is a missing ";" or ",".

Line 1 Column 9: N(:name)►, N(:age), N(:sex), N(:height), N(:weight)

The remaining text that was ignored was

Example2

///////////////////////////////////////////////////////////////////////////////

Open( "$SAMPLE_DATA/Big Class.jmp" );

dt = current data table();

colList = dt<<Get Column Names();

icols = N Items(colList);

MyExpr = expr(summDt = dt<<Summary(Group, expr(parse(strColumns)), output table name("Summary_Table")));

for(i=1, i<=icols, i++,

    if(i==1, strColumns = "N(:" || char(colList) || ")", strColumns = strColumns || ", N(:" || char(colList) || ")")

);

//bypass above for check

//strColumns = "N(:name)"; //will work for one column, but throws an error when I try to pass more than one column (i.e. "Unexpected ",". Perhaps there is a missing ";" or ",".")

test = Eval Expr(MyExpr);

test;

///////////////////////////////////////////////////////////////////////////////

I must be doing something silly.

Any advice/help would be greatly appreciated.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
mpb
mpb
Level VII

Re: JMP - How to pass a dynamic list of columns to Summary()

This example seems to work and may help:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

colList = dt << Get Column Names();

dtsum = dt << Summary(Mean( Eval( colList ) ) );

View solution in original post

3 REPLIES 3
mpb
mpb
Level VII

Re: JMP - How to pass a dynamic list of columns to Summary()

This example seems to work and may help:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

colList = dt << Get Column Names();

dtsum = dt << Summary(Mean( Eval( colList ) ) );

brianm
Level I

Re: JMP - How to pass a dynamic list of columns to Summary()

thanks mpb!

I feel pretty pretty embarrassed now - it was so simple

Thomas1
Level V

Re: JMP - How to pass a dynamic list of columns to Summary()

Thanks. Plain and helpful.