Hi gandi2223
Try this option to see if it works for you.
dtA = New Table( "TableA",
Add Rows( 12 ),
New Column( "ID", Character, Nominal, Set Values( {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"} ) ),
New Column( "Data1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] ) ),
);
dtB = New Table( "TableB",
Add Rows( 12 ),
New Column( "ID", Character, Nominal, Set Values( {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"} ) ),
New Column( "Data1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 112, 123] ) ),
New Column( "Data2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120] ) ),
);
// duplicate table B befor removing column "Data1"
dtC = dtB << Subset( All rows , /*private*/ ); // private is just for speed and memory
// remove column "Data1"
dtC << Delete Column( Data1 );
// alternativly you can use this generic column deleteing method
columnstokeep = {"ID", "Data2" /* , "Data3", "Data4"*/ };
columnstotrash = {};
For( icol = 1, icol <= N Col( dtC ), icol++,
colname = Column( dtC, icol ) << get name();
If( Contains( columnstokeep, colname ) < 1,
Insert Into( columnstotrash, colname )
);
);
dtC << delete columns( columnstotrash );
// now update the tables
dtA << Update( With( dtC ), Match Columns( :ID = :ID ) );
Wait( 0 );
// close dtC
Close( dtC, No save );
the generic way of deleting columns is based on these discussions in the forum
https://community.jmp.com/message/41338#41338
https://community.jmp.com/message/183010#183010
best,
ron