cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMPĀ® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dilipkumar
Level II

Updating data from one jmp table to another jmp table

Hi All,

i have written a script where , i will be creating several columns in  JMP table (Say table-1) based on some  calculation. Now i want to populate few selected Row and columns of Table-1 to another JMP table (say table-2). I need help in populating the second table with selected Rows and coloumns.

 

Kindly suggest.

 

Regards,

Dilip

1 REPLY 1
txnelson
Super User

Re: Updating data from one jmp table to another jmp table

Here are a couple of ways to do what you are asking.  The first method, using the Update platform is far more efficient than the cell to cell updating, but they both work well, and each have their place where you would want to use each technique.

Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/big class.jmp" );
dt2 = Open( "$SAMPLE_DATA/big class families.jmp" );

// Add a new columns
dt1 << New Column( "Height, Weight ratio", formula( :weight / :height ) );
dt1 << New Column( "Age, Height ratio", formula( :height / :Age ) );

// Add the Height, Weight ratio to the dt2 data table, for only the 
// females, using a simple subset and a join
dt1 << select where( :sex == "F" );

dtSubset = dt1 << subset(
	private,
	selected rows( 1 ),
	columns( {"name", "Height, Weight ratio"} )
);

dt2 << Update( With( dtSubset ), Match Columns( :name = :name ) );

Close( dtSubset, nosave );

// Add the Age, Height ratio to the dt2 data table for only the
// 13 year olds, using cell by cell processing
dt2 << New Column( "Age, Height ratio" );

For( i = 1, i <= N Rows( dt1 ), i++,
	If( dt1:age[i] == 13,
		foundRow = dt2 << get rows where( dt1:name[i] == dt2:name & dt2:age == 13 );
		If( N Rows( foundRow ) == 1,
			theRow = foundRow[1];
			dt2:Name( "Age, Height ratio" )[theRow] = dt1:Name( "Age, Height ratio" )[i];
		);
	)
);

Also, there are other methods that can be used.  I suggest you read the Scripting Guide, to get a good feel for the variety of options available

     Help==>Books==>Scripting Guide

Jim