Hi everyone,
I am working on a script that I would like to use a string as a column name, and use that column name in a formula, see below:
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
//example column
dt << New Column("klaatu barada nikto", formula(3));
//suppose we don't know what exactly will be in 'a' as it is controlled by a for loop etc.
a = Concat Items( {"klaatu", "barada", "nikto"}, " " );
//can we get another column to take 'a' as an input?
dt << New Column("Gort", formula(column(a)*:Y));When I use this however, it does not see "klaatu barada nikto" as a valid column, even though we created it before.
From other posts I have seen that the column() function can be used to assign a string to a column and I have used it in this way before, but in this instance it does not work. All we end up with is this:

Does anyone know a workaround for this? Thanks for any help in advance!
Take a look at this Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
//example column
dt << New Column("klaatu barada nikto", formula(3));
//suppose we don't know what exactly will be in 'a' as it is controlled by a for loop etc.
a = Concat Items( {"klaatu", "barada", "nikto"}, " " );
//can we get another column to take 'a' as an input?
Eval(EvalExpr(dt << New Column("Gort", numeric, formula(ascolumn(expr(a))*:Y))));Fantastic! Thank you so much for your help.