Recding in JSL while keeping most initial valuesHi,
I have a column with probablities. Mostly these are just numbers between 0 and 1. However, for a probablity of 100% I got 100 instead of 1. My idea to fis the issue was simply to ues the recoding function and then replace all occurences of "100" by "1".
The code scnipped I'm using is:
dt << Recode Column (
:"probability"n,
{IF( _rcNOW == 100, 1)},
Target Column (:"probability"n)
);This works partly, the problem is that all cases where the probability is < 100, the updated column is empty. That's because the IF statement does not know what to do in the case. Is there a way to tell that in that case, it should just keep the orignal value?
Automation and ScriptingData Blending and CleanupRe: Recding in JSL while keeping most initial valuesDo it interactively in JMP and JMP will create a script for you. For example I have a table

And I wish to change 100 to 1


JMP creates a script for you

And you can clean it up and modify it a bit and have it look like this
dt << Recode Column(
dt:Prob,
{Map Value(_rcOrig, {100, 1}, Unmatched(_rcNow))},
Target Column(:Prob)
);
JMP basically created this script for me without me writing any JSL.
Re: Recding in JSL while keeping most initial valuesThanks that worked perfectly! (and looks obvious in hindsight).
Indeed, I could to it interactively w/o problem and I might have to run that on different files, so I prefer a scirpting solution.
What do you mean by "Map Value"? (Or is that the interactive aproach?)
Re: Recding in JSL while keeping most initial valuesI think you can use _rcNOW in your else statement
dt << Recode Column(
:"probability"n,
{If(_rcNOW == 100,
1
, _rcNOW
)},
Target Column(:"probability"n)
);
but if you just want to change 100 to 1, using Map Value (the most basic recode operation) might be easier. I think you can just do this interactively from Recode menu.