Choose Language Hide Translation Bar
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.




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" );
dt2 = Open( "$SAMPLE_DATA/big class" );

// 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(
	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

Article Labels

    There are no labels assigned to this post.