cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
JensRiege
Level IV

How do I compare a variables values to a table column value

I have what should be a simple problem, but I don't know the right way to phrase it.

I have a few variables;

  A1 = "44";

  A2 = "47";

  A3 = "50";

//numbers are in string format intentionally

 

And a data table, dt,  where these variables are included among many others in one column, column "LOT". If I create a for loop, to find these variables in the table, and mark the rows when they are found, I am not able to find them..

 

For( i = 1, i <= 3, i++,
    foundlot = "A" || Char( i );
    Show( foundlot );
    dt << Select Where( :LOT = foundlot ) << Colors = (5);
);

 

I realize the problem is that foundlot is a string "A1", "A2", "A3", ... and does not substitute the value of A1, A2 and A3 to allow a comparison of the value of A1 to the column value in the table.

What would I need to do to have it substitute the value, rather than compare the column value to the string "A1" which always is not a match?

Thank you for your help! 

 

1 ACCEPTED SOLUTION

Accepted Solutions
JensRiege
Level IV

Re: How do I compare a variables values to a table column value

This worked really well. Thank you!

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How do I compare a variables values to a table column value

I believe these two simple scripts below will handle what you want.  The issue you are having, is having the need to indicate that A1, A2 and A3 are not variable values, but are the names of variables.  Script 1 will do that for you.  The second script is probably a better way to think of your issue.  By using a JMP list, you can reference the variables value by using subscripts

names default to here(1);
dt=current data table();
A1 = "44";
A2 = "47";
A3 = "50";

For( i=1, i<=3, i++,
	foundlot = "A" || char(i);  Show (foundlot);
	Eval(Parse(EvalInsert("\[dt << Select Where(:LOT == ^foundlot^, current selection("extend") ) ;]\")));
);
dt << colors( "red");
// or

names default to here(1);
dt=current data table();
aList = {"44", "47", "50" };
For( i=1, i<=3, i++,
	dt << Select Where( :Lot == aList[i], current selection("extend"));
);
dt << colors( "red");

 

 

Jim
JensRiege
Level IV

Re: How do I compare a variables values to a table column value

Thank you! I will give this a try!
JensRiege
Level IV

Re: How do I compare a variables values to a table column value

This worked really well. Thank you!