Check if wafer from an input string is contained within a data tableI have an input string from below:
For( i = 1, i <= N Rows( dtWaferIDList ), i++,
tempi = Column( dtWaferIDList, 1 )[i];
InputString = If( i == 1, "'", "" ) || InputString || tempi || If( i < N Rows( dtWaferIDList ), "','", "'" );
);
And a table1 that I pull from a database. I would like to check to see if (in the Wafer column of table 1) all the wafers from the input string are contained in that column.
- if all wafers have data: display message = "data for all wafers available".
- if not: display message = "no data available".
Thank you!
Data TableScriptingRe: Check if wafer from an input string is contained within a data tableYou could most likely use Associative Array for this comparison Applications for Associative Arrays . Check out the part Compare Columns in Two Different Data Tables
Re: Check if wafer from an input string is contained within a data table@jthi has pointed you in the right direction. Your proposed approach is using a very long literal string. I suggest that you either use associative arrays, or a JMP list.
Below is a simple script that opens a data table that contains wafers. It then creates a data table that has a random set of wafers. Finally it checks to see if the random set contains all wafers from the first data table.
names default to here(1);
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
unique wafers = associative array(dt:Wafer);
// Create a random wafer table and see if it contains all wafers
dtRand = new table("Random",
add rows(60),
new column("Rand Wafer", set each value(random integer(1,24)));
);
random wafers = associative array(dtRand:Rand wafer);
Random wafers << Intersect( unique wafers );
if(n items(Random wafers) == n items( unique wafers),
msg = "data for all wafers available",
msg = "no data available"
);
new window("Message", <<MODAL></MODAL>Re: Check if wafer from an input string is contained within a data tableHello Nelson,
I appreciate the help! I am a bit new to JMP still and haven't used Associative Arrays at all yet. I have read up on it on the scripting guide and index; but am still having some confusion. Here is where I am at in my code: (directly after opening the table WaferRgDt from a database)
unique wafers = Associative Array( WaferRgDt:Wafer );
given wafers = Associative Array( dtWaferIDList:WaferList );
intersection = unique wafers; intersection << Intersect( given wafers); //intersection between arrays
//uncommmon2 represents wafers that have no data associated with it.
uncommon2 = given wafers; uncommon2 <<REMOVE></REMOVE>
When I run this I get an empty messagebox with a period... so something seems wrong still. Wondering if its a logic issue or syntax. I have had some trouble finding how to write keys in a messagebox if its even possible to do. Hope that was clear enough. Thanks again!
Re: Check if wafer from an input string is contained within a data tableTo convert a list of strings into a string you can use Concat Items()
Names Default To Here(1);
aa = Associative Array({"bun",
"shoe",
"tree",
"door"}
);
uniqKeys = aa << get keys;
Show(uniqKeys);
Show(Concat Items(uniqKeys, ", "));
Re: Check if wafer from an input string is contained within a data tableAlso used this discussion post to aid in writing the code aboveRe: Quick way to compare two lists (uncommon elements)?