Hi there,
I am stuck on a specific part of my JMP script and am hoping to get some help from a different set of eyes.
I have a dataset that looks like this, but with a lot more categories, each with longer names.
I want to create another column, with numeric values, based on the given column. This product needs to be fully automated, with a pop-up window with each of the categories listed out, with number edit boxes that the user can input the numeric values that will correspond to a category. For example:
Pop-up window box: new window with all prompts in the pop-up window box.
Enter value corresponding to A: ___1___ Enter value corresponding to B: ___2___ Enter value corresponding to C: ___3___ Enter value corresponding to ___4___ Enter value corresponding to E: ___5___ |
The resulting data table should look like this:
Below is the JMP script that I have right now. I have also uploaded the JMP file to this post. What I need help with is in red text below. I am having trouble assigning the ith value in the for loop, based on user input and corresponding to the ith unique category in the list, unique_char
, to the ith position in the initialized numeric list, num_list
, which will be used later in the next for loop for creating the column 2 (at the end of the JMP script below).
dt = Current Data Table();
//get the unique character variable list
Names Default To Here( 1 );
col9 = Column(dt, "Column 1");
unique_char = Associative Array(col9) << get keys; // unique_char = {"A", "B", "C", "D", "E"}
//get n items in character variable list
nuniquechar = N Items(unique_char); //will be 5, if categories are A, B, C, D, E
//initalize number list
num_list = {};
//create new window to create multiple number edit boxes
nw = New Window( "Set Values",
<<Modal,
// Make the for loop of for every item in nuniquechar list,
// ask and save user input for the LSL in a element of the num_list list
for (i = 1,
i <= nuniquechar,
i++,
Text Box("Number for " || unique_char[i] || ":"), //i.e. "Number for A:"
// HELP:
// name a numeric variable on each iteration that will be the holder of a numeric edit box
// put the resulting ith entry into the num_list
num_list[i] = number edit box(),
// number box default is null/missing. If no input, place a missing value in the num_list
)
);
// TO DO:
// Create new column assigning the num_list values to
// the corresponding rows based the unique character value.
// Pseudo-code:
// for(i in 1:nuniquechar)
// if :column 1 = unique_char[i], num_list[i]
//
//
The results from this will be the automated and user-friendly version of using the following conditional logic to make column 2 based on column 1's categories.