JMP help in scriptHello,
I am trying to update a column based on other columns. If update is not possible, I am happy to create a new column as well using formula. But I am not able to mage to do that. See my sample and solution data and images.
So lets say, for a
"customer_id" = A, if "Site_B" is missing and "Data_set_ID" = 221 or 169 or 136 => Put "Site_B" = "Site_B" at "Data_set_ID" = 142
And
Another similar condition (upto 4 or 5 conditions)
And repeat the same for all customers -- B, C, AA, AD etc.
Any help please?
Thanks.
ScriptingRe: JMP help in scriptFrom the syntax used in your Discussion request, you are not educated in the syntax of JSL. You need to take the time to read the Scripting Guide to become proficient in JSL.
Below is the JSL required to meet what I understand as what you need, based upon the Blue and Red pseudo code in the Sample_Data_Solution.jpg
names default to here(1);
dt=current data table();
for(i=1,i<=N Rows(dt),i++,
If(:Customer_ID[i] == "A",
if(IsMissing(:Site_B[i]) & (:Data_set_ID[i] == 44 | :Data_set_ID[i] == 87),
:Site_B[i] = :Site_B[ (dt << get rows where( :Data_set_ID == 142))[1]]
,
IsMissing(:Site_B[i]) & (:Data_set_ID[i] == 221 | :Data_set_ID[i] == 169 | :Data_set_ID[i] == 136),
:Site_B[i] = :Site_B[ (dt << get rows where( :Data_set_ID == 164))[1]]
)
,
:Customer_ID[i] == "B",
if(IsMissing(:Site_B[i]) & (:Data_set_ID[i] == 44 | :Data_set_ID[i] == 87),
:Site_B[i] = :Site_B[ (dt << get rows where( :Data_set_ID == 142))[1]]
,
IsMissing(:Site_B[i]) & (:Data_set_ID[i] == 221 | :Data_set_ID[i] == 169 | :Data_set_ID[i] == 136),
:Site_B[i] = :Site_B[ (dt << get rows where( :Data_set_ID == 164))[1]]
)
)
);
Re: JMP help in scriptHi,
I mean in your code I can not assign customer_id manually like, in side the if statement --
:Customer_ID[i] == "A",
:Customer_ID[i] == "B",
This would be 6000-7000 alpha numeric variable for me. Like
:Customer_ID[i] == "9UHIW",
:Customer_ID[i] == "7EIGO", etc.
so I need another loop which identify each unique Customer_ID and then implement your script on it.
Thanks.