I have a list of columns I want to group but the script fails if any of the columns are absent. A try statement does not seem to fix the problem.
dt = Current Data Table();
Try( dt << Group Columns ("TM", {:Param_1, :Param_2, :Param_3}));
If you want to group all columns present in that list (even if, say, :Param_2 is missing), you could try something like this.
Names Default To Here( 1 );
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );
Had to tweak this a bit to identify dt.
Names Default To Here( 1 );
dt = Current Data Table();
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );
If you want to group all columns present in that list (even if, say, :Param_2 is missing), you could try something like this.
Names Default To Here( 1 );
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );
Had to tweak this a bit to identify dt.
Names Default To Here( 1 );
dt = Current Data Table();
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );
My suggestion would be to avoid :col and use strings. With JMP19 you can use Set Intersection
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
g = {"age", "sex", "height", "test", "test2"};
mycols = Set Intersection(dt << Get Column Names("String"), g);
dt << Group Columns("MyGroup", mycols);
In earlier versions Associative Arrays (or Filter Each) can replace Set Intersection