This has already been reported to JMP support and they have submitted it as a bug to development (00049239). Seems to happen at least with JMP16.2 and JMP17.0
Just as a heads up, there is fairly bad bug with JMP when using the mentioned combination (set each value, loop and col statistical functions). What happens is that JMP does use data from wrong table when adding data to different table. One workaround is to provide table preference within << Set Each Value (<< Set Each Value(Col Rank(Row(), dt:name))).
You seem to need (based on my fairly quick tests):
- Data tables with same column name(s)
- Loop over those
- Use << Set Each Value to set values in column
- The formula used should use Col statistical function WITH byVar (and most likely this has to have same name in both tables)
Below are some test cases
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)
));
);
);
-Jarmo