Suppose I want to concatenate a high number of tables that all have the same format. I would like to have one single call to concatenate function, rather than a loop to concatenate one data table at a time. This is because I want to learn expressions in JMP.
I would like to have something like this
Data table("dt1") << concatenate(data table("dt2"),data table("dt3"),…, data table("dt100"))
In this example, I’m creating copies of the same sample data, but imagine that they could come from different sources and contain different values.
close all(data tables, nosave);
dt1 = Open("$SAMPLE_DATA/Big Class.jmp");
N=100;
/*in this loop, I’m copying the data table and creating a string, with the aim to use it in the concatenate function*/
/*I’m using the escape character because I have double quotes*/
dt_string="";
for(i=2,i<=N,i++,
dt_tmp = (dt1 << subset(all rows, all columns, invisible ));
dt_name = "dt" || char(i);
dt_tmp << set name(dt_name);
if(dt_string=="",
dt_string = "data table(\!"" || dt_name || "\!")";,
dt_string = dt_string || ", data table(\!"" || dt_name || "\!")");
);
show(dt_string);
concat_expr = expr(dt1 << concatenate(dt_list));
show(concat_expr);
concat_expr2 = substitute(Nameexpr(concat_expr),expr(dt_list),dt_string);
show(concat_expr2);
eval(concat_expr2);
And my problem is that I have still the escape character in the expression and its evaluation fails.
Please could you propose a code to construct the correct expression?
Thanks in advance.
JF