嘗試使用分組列語句我有一個列列表,想要對其進行分組,但如果其中任何一列缺失,腳本就會運行失敗。使用 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)可以替代集合交集。