Get Column Names from List of Columns
Names Default to Here(1);
dt = Current Data Table();
column list = dt << Get Column Names(Continuous);
key list = dt << Get Column Group("KEYS");"column list" contains a list of names from columns containing continuous data.
"key list" contains a list of columns in the "KEYS" group.
How do I get the names of the columns from "key list"? Ultimately I would like to remove any continuous column names from the "column list" that are in the "KEYS" group. I found a post from Craige Hales to manage the lists, but I need to get them in the same format.
Re: Get Column Names from List of ColumnsHere's an easy task you can help me with - once I "get column names", how can I then insert them into a data table which is just that selfsame list of column names? THANKS Devin
Re: Get Column Names from List of ColumnsPlease do not bang your head! Use Help > Scripting Index instead.

Re: Get Column Names from List of ColumnsThanks for your note about contain requiring literal strings and the "get column names" not providing that with out the "string" option. I banged my head against this for a long time and adding "string" immediately fixed it.Re: Get Column Names from List of ColumnsThe trick was: Char(key list[i]))
(I never thought of casting the column reference into a string)Re: Get Column Names from List of ColumnsHere is the solution I arrived at after converting the key list to strings as suggested:
// Initialize
Names Default to Here(1);
dt = Current Data Table();
key list names = {};
// Get a list of all continuous columns
column list = dt << Get Column Names(Continuous, String);
// Create a list of column names in the KEYS group
key list = dt << Get Column Group("KEYS");
For(i = 1, i <= N Items(key list), i++,
Insert Into(key list names, Char(key list[i]))
);
// Remove from the column list any column that is in the KEYS group
/* <BR />Adapted from - Re: Quick way to compare two lists (uncommon elements)?
JAN 10, 2017 6:41 AM, by Craige_Hales, STAFF (RETIRED)
*/
set1 = Associative Array(column list);
set2 = Associative Array(key list names);
// Find the names common to both lists
intersection = set1;
intersection << Intersect(set2);
// Remove the common names
cleaned list = set1;
cleaned list << Remove(intersection);
column list = cleaned list << Get Keys;
Re: Get Column Names from List of ColumnsThanks. I am looking to remove from "column list" any name that is in the "Processes" group (using your example), so items need to be removed from "column list", not "key list". I expect that I will need to search column list for Char(key list[i]) and if found remove it.Re: Get Column Names from List of ColumnsWhat is returned from both the << Get Column Names, and << Get Column Group are JMP lists. You can roughly think of them as Arrays of values. Please review the Scripting Guides section on using lists.
Below is a modification of your code, that will check for the comparison between 2 lists, for column names found common in both lists and then removing them from the Key List, list. Please note, that the Contains function requires literal strings for it to function, so that is why the <
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
column list = dt << Get Column Names( Continuous, string );
key list = dt << Get Column Group( "Processes" );
Show( "complete list", key list );
For( i = N Items( key list ), i >= 1, i--,
If( Contains( column list, Char( key list[i] ) ),
key list = Remove( key list, i, 1 )
)
);
Show( "final list", key list );
In my example, the Keys List ends up not having any values, since all elements in the group are numeric columns