Hi,
I'm trying to write a jsl code that removes numbers from a row if they are not present in a given list.
The list is in the table call "List values"
Bins values I want to modify:
For example: the jsl script should delete "444" from row 7 in the above table and likewise for other rows
Final result:
Here's the code
Names Default To Here( 1 );
dt_list = Data Table("List values");
dtt = Data Table("Bins");
list = dt_list:List<< get values;
//Loop through rows to find the number contain in the lis
For( i = 6, i <= N rows( dtt ), i++,
if( !contains(list, Words( dtt:Bins[i], "[ ]" )),
// I am not sure how to proceed further?
););
Any suggestions?
Thanks,
Jackie
If it doesn't matter that the order is changed, using Associative Arrays is one option
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/List values.jmp");
Column(dt1, "List") << Data Type("Numeric");
dt2 = Open("$DOWNLOADS/Bins.jmp");
aa_listvalues = Associative Array(Column(dt1, "List"));
dt2 << New Column("BinsList", Character, Nominal, << Set Each Value(
If(!IsMissing(:Bins),
r_aa = Associative Array(Parse(:Bins));
r_aa << Intersect(aa_listvalues);
If(N Items(r_aa) > 0,
Substitute(Char((r_aa << get keys)), "}", "]", "{", "[", ",", " ");
,
""
);
,
""
);
));
Not sure why 410 wouldn't be removed on Row 10
If it doesn't matter that the order is changed, using Associative Arrays is one option
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/List values.jmp");
Column(dt1, "List") << Data Type("Numeric");
dt2 = Open("$DOWNLOADS/Bins.jmp");
aa_listvalues = Associative Array(Column(dt1, "List"));
dt2 << New Column("BinsList", Character, Nominal, << Set Each Value(
If(!IsMissing(:Bins),
r_aa = Associative Array(Parse(:Bins));
r_aa << Intersect(aa_listvalues);
If(N Items(r_aa) > 0,
Substitute(Char((r_aa << get keys)), "}", "]", "{", "[", ",", " ");
,
""
);
,
""
);
));
Not sure why 410 wouldn't be removed on Row 10
Thank a lot, Jarmo!
Forget to delete 410