cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
wade-liu
Level I

Copy Last Two Column data from Data table A to Data table B

Hi  Everyone

 

I have a two data table , table A and table B,

I want write a script that copy last two column data from table A then paste to table B,

Could you give me some kindly sugestion ?

 

Thanks.

3 REPLIES 3
jthi
Super User

Re: Copy Last Two Column data from Data table A to Data table B

Do the tables have exactly same amount of rows and order of data is exactly the same in both of the tables?

-Jarmo
wade-liu
Level I

Re: Copy Last Two Column data from Data table A to Data table B

Yes, But I don't know how to use script syntax to copy entire column information to another table.

jthi
Super User

Re: Copy Last Two Column data from Data table A to Data table B

You can use Join/Update or Data table subscripting . Below is one example using update which might work for you

Names Default To Here(1);

// Setup demo
dt = Open("$SAMPLE_DATA/Trial1.jmp");
dt2 = Open("$SAMPLE_DATA/Little.jmp");

dt << Delete Rows(5 :: N Rows(dt)); // to make tables equal in size
Column(dt2, "batch") << Set Name("B"); // names must be different
Column(dt2, "yield") << Set Name("Y"); // names must be different
Wait(0);


collist = dt2 << Get Column Names("String");
lastcols = Right(collist, 2);
dt << Update(
	With(dt2),
	Add Columns from Update Table(Eval(lastcols)),
	Replace Columns in Main Table(None) // important
);
-Jarmo