How to group columns names that ending with certain words given by user into a new column?Hi all,
I'm new to the JMP, would like to seek for some helps related to the JMP script.
Recently I am having some trouble to group all the columns together that each column variable name are ending with certain words.
eg. 1_id, 2_id, 3_id - group into named as id_group
Thanks & appreciated for the great helps.
Re: How to group columns names that ending with certain words given by user into a new column?perhaps mark it as answered?
Re: How to group columns names that ending with certain words given by user into a new column?Its working. Thanks for the great help.
Re: How to group columns names that ending with certain words given by user into a new column?You can try something like this:
NamesDefaultToHere(1);
// Make a table with some columns having random names'
dt = NewTable("Random Column Names");
For(i=1, i<=100, i++,
dt << NewColumn(Char(RandomInteger(10))||Char(RandomInteger(5)))
);
// Get a list of columns in the table
cols = dt << getColumnNames("String");
// Make a column group from columns with names ending in '2'
cols2group = {};
for(i=1, i<=NItems(cols), i++,
if(EndsWith(cols[i], "2"), InsertInto(cols2group, cols[i]));
);
dt << groupColumns("Ending in 2", cols2group);