尝试使用分组列语句我有一个列列表,想要对其进行分组,但如果其中任何一列缺失,脚本就会运行失败。使用 try 语句似乎无法解决这个问题。
, :Param_3}));dt = Current Data Table();
Try( dt << Group Columns ("TM", {:Param_1, :<CODE class="language-jsl">Param_2
自动化和脚本编写回复:使用分组列的 Try 语句如果你想将该列表中存在的所有列进行分组(即使缺少 :Param_2),你可以尝试类似这样的方法。
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 ) ) ) ) );
回复:使用分组列的 Try 语句需要稍微调整一下才能确定 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 ) ) ) ) );
回复:使用分组列的 Try 语句我的建议是避免使用 `:col`,而改用字符串。在 JMP19 中,您可以使用 `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);
在早期版本中,关联数组(或 Filter Each)可以替代集合交集。