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.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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.

Recommended Articles