For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Data Tables > Advanced Data Table Scripting > Replace Data in Data Tables
Publication date: 11/29/2021

Replace Data in Data Tables

Note: Merge Update() is an alias for Update().

Update() replaces data in one table with data from a second table.

dt << Update( // message to first table
	With( dataTable ), // the other data table
	By Row Number, /* default join type; alternative is
							By Matching Columns( col1 == col2 ) */
	Ignore Missing, // optional, does not replace values with missing values
	);

To try this, make a subset of Big Class.jmp:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
NewHt = dt << Subset( Columns( :name, :height), Output Table Name( "hts" ) );

Next, add 0-6 inches to each student’s height:

diff = Random Uniform( 0, 6 );
For Each Row( NewHt, :height = :height + diff );

Finally, update the heights of students in Big Class.jmp with the new heights from the subset table:

dt << Update(
	With( NewHt ),
	By Matching Columns( :name == :name),
	);

Controlling the Columns Added to an Updated Table

Your updated table might contain more columns than your original table. You can select which columns are included in your updated table using the option Add Column from Update Table().

To add no additional columns:

Data Table( "table" ) << Update(
	With( Data Table( "update data" ) ),
	Match Columns( :ID = :ID ),
	Add Columns from Update Table( None )
);

To add some columns:

Data Table( "table" ) << Update(
	With( Data Table( "update data" ) ),
	Match Columns( :ID = :ID ),
	Add Columns from Update table( :col1, :col2, :col3 )
);
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).