I am trying to update a table that sometimes contains new rows (based on an index).
It seems that I need to use join, as the following does not seem to work (here, the index is name column).
Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = New Table( "Little Class",
Add Rows( 3 ),
New Column( "name",
Character,
Nominal,
Set Values( {"ALICE", "NEW_NAME", "OTHER_NEW_NAME"} )
),
New Column( "height",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "weight",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "RANK",
Continuous,
Set Values( [3, 1, 2] )
),
New Column( "CODE",
Continuous,
Set Values( [0, 1, 1] )
)
);
dt1 << Update(
With( Data Table( "Little Class" ) ),
Match Columns( :name = :name ),
Add columns from Update table( {:RANK} )
);
Your stated assumption is correct, you will have to use the Join platform to do what you want.
Found similar post from community here and it was suggested to use Join instead of update when new rows are added:
Updating JMP Data Tables
Is there a reason why you couldn't use join instead of update (except that you will have to deal with extra tables)?
From JMP Help: Update Data Tables :
If you have two data tables and would like to update your original table with data from a new table, select Tables > Update. The Update command is a special case of Join in place. It is a Join with the Update option checked, and it does not result in a new table.
"Except that you will have to deal with extra tables"
Exactly. A new table is generated despite I am doing the join with the update option selected.
dt<< Join(
With( dt_new ),
Update, // this option is selected
By Matching Columns( :index= :index),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )<BR />);<BR /><BR />// Opens new table apart of dt and dt_new