Subscribe Bookmark RSS Feed

use of the values in a column to generate a string, in order to use the string as a parameter for stack

dghidoni

Community Trekker

Joined:

Jan 23, 2012

my need is: stack a table with a dynamical (well, sort of) selection of the column to stack.
I solved with a config table in which the names of the colums to be stacked are stored as values, then I do a "get values" and

assign the result to a string. finally I feed this string to stack command.

it works, but ...
every time in my log it says

Errors found. in access or evaluation of 'columns' , Bad Argument( Eval( d ) )

, columns( Eval( d ) )"
without eval it does not run, with eval it runs perfectly but pollute my log. does anyone knows why?


here is the code:

conf3 = open ("\here is the config table");

// load config, it is a excel file to be edited by the users in order to choose what "class" they want in the final report

// these class sets are quite stable, and most of the times are untouched from the last execution, but sometimes a class has to be added or changed
// it is simply like this:    column1: black white red     column2: red white     etc


d=Column(conf3,i)<<get values;
// i is the index
// I do it in a cycle, each run for a different table to be stacked reading a different column for a different stack set
// here I do get values from the i-th column of the config, and assing it to the string d --> it is good?


snowhite = Open( "\jmp_tables\snowhite.jmp" , invisible );
// load the table to be stacked


snowhite << Stack(
columns(eval(d)),
Source Label Column( "class" ),Stacked Data Column( "density" ), Name( "Non-stacked columns" )(Keep(:Split,:Lot ID, :Device ID,)),Output Table( s ));

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

I guess that d is not a string here, but a list of strings as <<get values yields a list (or matrix for continuous variables). If the class sets in conf3 differ in number of items the table will have as many rows as the biggest set. Then for some choises d will contain empty string items i.e "". That may be the cause of the reported error (columns must have a name other than "").

With the line of code below you can remove all instances of "" from d prior to stacking. It may be an easier way to tidy the lists, but this should work.

While( Contains( d, "" ) > 0, Remove From( d, Contains( d, "" ) ) );

dghidoni

Community Trekker

Joined:

Jan 23, 2012

yeah, i supposed that could be an issue when i noticed that there was some "" value.

unfortunately as you said the list come from an excel file column, that automatically insert empty cell at the end in order to have all columns of the same height, so the "" values are unavoidable.

i will try your solution, thanks!

and yes, i was uncorrect in my explanation: d is not a string but a list of strings, because the stack command need a list not a string!