Subscribe Bookmark RSS Feed

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

brianm

Community Trekker

Joined:

Mar 7, 2013

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
Solution

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 ) ) );

2 REPLIES
Solution

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

Community Trekker

Joined:

Mar 7, 2013

thanks mpb!

I feel pretty pretty embarrassed now - it was so simple