- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
JMP Script : Creation of a new list
Hello everyone,
I created a list named Y_list containing variable names. From this list, I would like to create a new list, containing only the variable names which contains values in the dataset.
Example:
Y_list contains {"height", "Weight", "Age"}
_LimitsKey | height | Weight | Age |
_UCL | 54 | 80 | |
_LCL | 72 | 150 |
As there is no value in the Age row, I would like to create a new list containing only variables names which contains data :
Y_new_list ==> {"height", "Weight"}
However, I do not know how to make this new list with JMP script.
Do you have any suggestion to help me?
Thanks a lot
Sebastien
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
If you have JMP16+ below is one option using Filter Each and checking if column only has missing values with IsMissing
Names Default To Here(1);
input_list = {"height", "Weight", "Age"};
dt = New Table("Untitled 6",
Add Rows(2),
Compress File When Saved(1),
New Column("_LimitsKey", Character, "Nominal", Set Values({"_UCL", "_LCL"})),
New Column("height", Numeric, "Continuous", Format("Best", 12), Set Values([54, 72])),
New Column("Weight", Numeric, "Continuous", Format("Best", 12), Set Values([80, 150])),
New Column("Age", Numeric, "Nominal", Format("", 16), Set Values([., .]))
);
new_list = Filter Each({list_val}, input_list,
found_values = Sum(!IsMissing(dt[0, list_val]));
found_values > 0;
);
show(new_list);
Adding debug prints inside Filter Each might be helpful to understand what is going on. Such as
Show(dt[0, list_val]);
Show(IsMissing(dt[0, list_val]));
Show(!IsMissing(dt[0, list_val]));
show(found_values);
There are also many other ways of doing this (like most of the time with jmp)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
If you have JMP16+ below is one option using Filter Each and checking if column only has missing values with IsMissing
Names Default To Here(1);
input_list = {"height", "Weight", "Age"};
dt = New Table("Untitled 6",
Add Rows(2),
Compress File When Saved(1),
New Column("_LimitsKey", Character, "Nominal", Set Values({"_UCL", "_LCL"})),
New Column("height", Numeric, "Continuous", Format("Best", 12), Set Values([54, 72])),
New Column("Weight", Numeric, "Continuous", Format("Best", 12), Set Values([80, 150])),
New Column("Age", Numeric, "Nominal", Format("", 16), Set Values([., .]))
);
new_list = Filter Each({list_val}, input_list,
found_values = Sum(!IsMissing(dt[0, list_val]));
found_values > 0;
);
show(new_list);
Adding debug prints inside Filter Each might be helpful to understand what is going on. Such as
Show(dt[0, list_val]);
Show(IsMissing(dt[0, list_val]));
Show(!IsMissing(dt[0, list_val]));
show(found_values);
There are also many other ways of doing this (like most of the time with jmp)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
Great, It is working well! Thaks a lot!
I would like to implement an if condition based on this:
If the Y column is included in the list_val created, then...
How can I write this condition?
If (Eval(Y) != list_val,
...
I think the != is not adapted...
Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
Use Contains() with If() to check if item is found from a list
Contains({"a","b","c"}, "b");
or you can use Contains Item()
Contains Item("b", {"a","b","c"});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
Thanks for your reply,
It should work but JMP does not like the Eval(Y) and always return 0:
r=Contains(list_val, Eval(Y))
For information, the Y is made like this:
Y = concat(Y," (ppm)");
Any idea?
Sebastien
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
I'm not exactly sure what you are trying to do? Why are you using Eval? Usually it is easier to handle column names as strings and then when you need them convert them to column references in some way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP Script : Creation of a new list
I am using the Eval because it is based on the user selection and then the concatenation:
Y = concat(Y," (ppm)");
Then I need to determine if this user selection can be found in the list:
r=Contains(list_val, Eval(Y))
I tried this also
r=Contains(list_val, Y)
But also always return 0...