これはすでに JMP サポートに報告されており、バグとして開発に提出されています (00049239)。 少なくともJMP16.2とJMP17.0では発生するようです
注意点として、上記の組み合わせ (各値、ループ、および Col 統計関数の設定) を使用する場合、JMP にはかなり悪いバグがあります。 何が起こるかというと、JMP は別のテーブルにデータを追加するときに、間違ったテーブルのデータを使用します。 回避策の 1 つは、<< Set Each Value (<< Set Each Value(Col Rank(Row(), dt:name))) 内でテーブル設定を指定することです。
(私のかなり簡単なテストに基づくと) 次のものが必要のようです。
- 同じ列名を持つデータテーブル
- それらをループします
- << Set Each Value を使用して列に値を設定します
- 使用する式には Col 統計関数を使用する必要がありますとbyVar (そしてほとんどの場合、これは両方のテーブルで同じ名前を持つ必要があります)
以下にいくつかのテストケースを示します
Names Default To Here(1);
// https://www.jmp.com/support/help/en/17.0/#page/jmp/scoping-operators.shtml#
// Initialize data
test_tables = {};
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
dt = Open("$SAMPLE_DATA/Students1.jmp");
dt << Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
/*
dt = Open("$SAMPLE_DATA/Students2.jmp");
dt << Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
*/
// use idx 1 to skip first table
min_idx = 0;
// without reversing we will run out of index as we are using wrong table
// but if we reverse we will get worse outcome (in my opinion) as we end up with wrong data
reverse_tableorder = 0;
If(reverse_tableorder,
test_tables = Reverse(test_tables);
);
For Each({dt, idx}, test_tables,
// works
// dt << New Column("COPY", Character, Nominal, << Set Each Value(:NAME));
// dt << New Column("MULTI", Numeric, Continuous, << Set Each Value(:age * :age));
If(idx > 0, // if the column isn't created to first table seems to work fine?
// Doesn't work (// old table used due to some col function optimizations when using byVar?)
Try(
dt << New Column("RANK", Numeric, Continuous, << Set Each Value(Col Rank(Row(), :NAME)));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("RANK_SEPARATE", Numeric, Continuous);
new_col << Set Each Value(Col Rank(:Row(), :name));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("SUM", Numeric, Continuous, << Set Each Value(Col Sum(1)));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("SUM_WITH_GROUP", Numeric, Continuous, << Set Each Value(Col Sum(1, :name)));
,
show(exception_msg);
);
Try( // with reverse_tableorder = 1, :age is taken from correct table BUT the group sizes from wrong?
// KATIE -> 72 (6*12) and not 11+12+12+13+14+15 -> 77
new_col = dt << New Column("SUM_OF_COL", Numeric, Continuous);
new_col << Set Each Value(Col Sum(:age, :name));
,
show(exception_msg);
);
// workaround
dt << New Column("RANK_WITH_REF", Numeric, Continuous, << Set Each Value(
Col Rank(Row(), dt:NAME)
));
);
);