Here is an example script that I hope clears up what you need to do to concatenate new data to a master file
names default to here(1);
// Create 2 data tables and save them as excel files
// one will be the master and one will play the role of the new data
dtExample = open("$SAMPLE_DATA/big class.jmp");
theTables =dtExample << Subset(
By( :sex ),
All rows,
Selected columns only( 0 ),
columns( :name, :age, :height, :weight )
);
close( dtExample, nosave );
// Change the names of the first table to Master
theTables[1] << set name("Master");
data table("Master") << bring window to front;
// Add the new columns to the master, like your master file already
// has all of the columns. In this example, I will only add 1 column
data table("Master")<< new column("Ratio", set each value(:height/:weight));
// Wait 5 seconds so you can observe the master table
wait(5);
// save and close the Master table as an excel table
close( data table("Master"), save("$TEMP/master.xlsx"));
// Change the name of the second table to New Data
theTables[2] << set name("New Data");
data table("New Data") << bring to front;
// wait 5 seconds here too, so you can observe the New Data table
wait(5);
// now save and close the New Data table as an excel table
close( data table("New Data"), save("$TEMP/New Data.xlsx"));
// Now that there are a Master and a New Data table that have been
// created we can now illustrate how to read in some new data,
// add the required new columns, save it, then open the master file,
// and concatenate the new data to the master and then save the updated
// master file
// open the new data table. I am using the variable dt as the pointer
// to the file, since that is what you are doing in your script
dt = open("$TEMP/New Data.xlsx");
// Add the new columns (in this example, only 1 column) to the data table
// your syntax is
// new column("ratio", formula(:height/:weight);
// I suggest that you become more precise and point to the specific data table
// by using either
// dt << New Column(......);
// or
// data table("New Data") << New Column( ...... );
data table("New Data") << New Column( "Ratio", formula(:height/:weight));
// Now the data can be saved
// use either
// dt<< save(...........);
// or
// data table("New Data")<< save(................);
dt << save("$TEMP\test1 n=22.xlsx");
// now open the master table
dtMaster = open("$TEMP\master.xlsx");
// concatenate the new data table to the master
dtMaster << concatenate( dt, append to first table(1));
// now save the master
dtMaster << save("$TEMP\master.xlsx");
// uncomment the below code if you want to close the new data and the master tables
// close( dt, nosave );
// close( dtMaster, nosave );
Jim