- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Script the "Group Similar Values" function in the Recode platform with JSL
I want to automate a recode function in JSL but I can not found any documentation on how to achieve it.
No luck in this forum, JMP search function or the scripting index. The workflow recorder and the log file only gets the final result (lock-up table) and its the same with the save script to data table function.
If possible to hand over some of those settings if possible but is not important in a first step:
Best regards
Mauro
- GLaDOS
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Script the "Group Similar Values" function in the Recode platform with JSL
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];
));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Script the "Group Similar Values" function in the Recode platform with JSL
I think you might have to build your own grouping using Choose Closest(). It seems to have MOST of the same options so maybe JMP is using something similar which it isn't recording (I think there are many other things recode isn't recording either).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Script the "Group Similar Values" function in the Recode platform with JSL
I made a small script using Choose Closest() but now run into a problem that it only executes once within any form of loop.
Wait didn't help and I tried a lot of scenarios. As long I execute Choose Closest() multiple times in a loop, it gives back the same string regardless of the input.
Outside / after the loop, it works fine (again).
I added a test setup and will make a ticket at JMP Support.
- GLaDOS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Script the "Group Similar Values" function in the Recode platform with JSL
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];
));