cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
student
Level III

Comparing strings not working for variables

Hi, I am using JMP 15 on Mac. The following code works:

 

dt = current data table();
Current Data Table() << Row Selection(
Select where( (:Stat == "Max"), Current Selection( Extend ))
);

But this doesn't:

dt = current data table();
Current Data Table() << Row Selection(
var = "Max"
Select where( (:Stat == var), Current Selection( Extend ))
);

Can someone explains what is wrong with the second one?

1 ACCEPTED SOLUTION

Accepted Solutions
student
Level III

Re: Comparing strings not working for variables

Ok I solved it. This is what was missing:

 

(:Stat == (myStat)) 

So, the variable needs to be inside two parentheses! 

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Comparing strings not working for variables

Try moving var = "Max" outside the << Row Selection(). And add missing ;

-Jarmo
student
Level III

Re: Comparing strings not working for variables

No change (thanks for your reply though).

student
Level III

Re: Comparing strings not working for variables

Ok I solved it. This is what was missing:

 

(:Stat == (myStat)) 

So, the variable needs to be inside two parentheses! 

jthi
Super User

Re: Comparing strings not working for variables

Seems like there is something a bit weird going on (tested with JMP16.0 on Windows 10). Take careful look on the brackets when using Row Selection

 

Example from scripting index (works fine):

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Row Selection(Select where(:age < 15));
Wait(2);
dt << Row Selection(
	Select where(:age == 15),
	current selection("extend")
);

Adding variable before second row selection and using it (returns Scriptable[]):

 

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Row Selection(Select where(:age < 15));
Wait(2);
ageVar = 15;
dt << Row Selection(
	Select where(:age == ageVar),
	current selection("extend")
);

 

Moving the bracket from end of Select Where to after current selection (seems to work fine, but this syntax seems wrong for Row Selection based on Scripting Index):

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Row Selection(Select where(:age < 15));
Wait(2);
ageVar = 15;
dt << Row Selection(
	Select where(:age == ageVar,
	current selection("extend"))
);

jthi_0-1619588178969.png

 

When using Select Where platform the script generated seems to be:

Data Table("Big Class") << Row Selection(
	Select where(:age == 15, Current Selection("Extend")),
	Dialog(Edit(Equal(Source Column(:age))), Keep dialog open(1))
);

 

Selection when not using Row Selection:

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Row Selection(Select where(:age < 15));
Wait(2);
ageVar = 15;
dt << Select where(:age == ageVar, current selection("extend"));

 

If there is no need for dialog, I would most likely always just use << Select Where (without Row Selection) as the syntax is easier and I'm not sure if Row Selection brings anything extra to the table besides the dialog.

 

Not sure who to tag here from JMP/SAS to take a look into this.

 

-Jarmo