I've been struggling to figure this out. I have a table (Table1) that has columns that I want grouped. Table2 has the column names and group labels I want to use. I want to script and automate creating the grouped table, as shown in the screenshot below. Any suggestions on how to do this would be appreciated.

here are scripts to create Table1 and Table2 shown above
dt1 = New Table( "Table1",
Add Rows( 3 ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [35, 10, 88] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 3, 2] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 3, 1] ) ),
New Column( "D", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 2] ) )
);
dt2 = New Table( "Table2",
Add Rows( 4 ),
New Column( "Name", Character, "Nominal", Set Values( {"A", "B", "C", "D"} ) ),
New Column( "GroupName", Character, "Nominal", Set Values( {"G1", "G1", "G2", "G2"} ) )
);