I hope this works for you. I got if from jmp8 scripting guide so ...
Compare two data tables
Here is a script to open two data tables, compare them, and report all results to the log window. This
script makes heavy use of the For operator to loop operations over all the rows (loops with i), nested
with another For operator to loop operations over all the columns (loops with j).
/* COMPARE THE CONTENTS OF TWO DATA TABLES */
// First identify the two data tables to be compared.
// Since you don't specify arguments, Open() presents the
// host-system dialog box for opening a file.
caption("Please locate the first data table.",spoken(1));
dt1=open();
caption("Please locate the second data table.");
dt2=open();
// Check for differing sizes.
if(nrow(dt1)!=nrow(dt2),
write("Differing number of rows. "),
write("Same number of rows. "));
if(ncol(dt1)!=ncol(dt2),write("Differing number of columns. "),
write("Same number of columns. "));
nr = min(nrow(dt1),nrow(dt2));
nc = min(ncol(dt1),ncol(dt2));
// Check for differing column names.
for(j=1,j<=nc,j++,
current data table(dt1);n1=char(ColumnName(j));
current data table(dt2);n2=char(ColumnName(j));
if(n1!=n2,
write("\!rDiffering column names in column "||char(j));
show(n1,n2)));
// check for differing values
e=0;
for(i=1,i<=nr,i++,
for(j=1,j<=nc,j++,
v1 = Column(dt1,j);
v2 = Column(dt2,j);
if(v1!=v2,
write("\!rDiffering values at row "||char(i)||
" in column "||char(j));show(v1,v2);e++)));
if(e==0,
write("Matching cells have the same values."),
write("\!rNumber of cells that exist in both tables ");
write("and have differing values: "||char(e)));
// check for differing row states
for(i=1,i<=nr,i++,
current data table(dt1);r1 = char(rowstate(i));
current data table(dt2);r2 = char(rowstate(i));
if(r1!=r2,
write("\!r\!rDiffering row states at row "||char(i));
show(r1,r2)));
//Observe how Current Data Table is used to switch between two open windows.