Yeah, seems like Choose Closest is doing some weird things when it is inside a loop. For example this didn't seem to work without using Eval(EvalExpr()) as it was matching abcabcb with abcabca if run inside a loop (if you run it manually until failure, the result was ok).
Below is my attempt on something like this (I think Group Choose Closest or something similar would be a good idea for Wish List which would do what Recode is doing)
names default to here(1);
dt = Open("$DOWNLOADS/Test_Table.jmp");
dt << new column("Ones", Numeric, Continuous, Set Each Value(1)); // summarize...
Summarize(dt, groups = By(:Column 1), counts = Sum(:Ones));
aa_matches = Associative Array(groups);
groups = groups[Rank(Ranking(counts))];
aa_matches[Reverse(groups)[1]] = Reverse(groups)[1]; // highest is group with itself
str_a = Remove From(groups, 1)[1];
While(N Items(groups) > 0,
Eval(EvalExpr(
str_b = Choose Closest(Expr(str_a), Expr(groups), Ignore Case(1), Ignore Whitespace(1), Ignore Nonprintable(1), Max Edit Count(2), Max Edit Ratio(0.25));
));
aa_matches[str_a] = str_b;
str_a = Remove From(groups, 1)[1];
);
dt << New Column("Recoded", Character, Nominal, Set Each Value(
aa_matches[:Column 1];
));
-Jarmo