Hi,
I want to compare more than 2 tables in JMP for a common column present in all the tables. Now i want to return a 1 if the values in that specific column exists in each table otherwise 0. This im able to do for some predefined tables and by using a JSL script which adds an extra column in each table and return 0 or 1.
But i want to make this script generic so that i dont need to predefine the name of tables. It should be like, whenever i run this script, it should ask me which tables i want to compare.
After that, i also want this script to work in such a way it can also give me the option to select which column i want to compare
Currently, Im using this script
// Get references to the three tables
dt1 = Data Table("Untitled 9");
dt2 = Data Table("Untitled 10");
dt3 = Data Table("Untitled 11");
// Extract ID values from each table
ids1 = dt1:ID << Get Values;
ids2 = dt2:ID << Get Values;
ids3 = dt3:ID << Get Values;
// Find common IDs manually
commonIDs = {};
For(i = 1, i <= N Items(ids1), i++,
If(Contains(ids2, ids1[i]) & Contains(ids3, ids1[i]),
Insert Into(commonIDs, ids1[i])
)
);
// Function to add indicator column
AddIndicatorColumn = Function({dt},
dt << New Column("PresentInAll",
Numeric,
Formula(If(Contains(commonIDs, :ID), 1, 0))
)
);
// Apply to all tables
AddIndicatorColumn(dt1);
AddIndicatorColumn(dt2);
AddIndicatorColumn(dt3);
Edit (jthi): added jsl formatting
Selecting three tables Untitled 9, Untitled 10 and Untitled 11 and the column im comparing is "ID"
Please help on this,
Thanks
