cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Sebastienlg
Level II

JMP script: If N categories > 5 script

Hello Everyone,

I would like to create a condition in case there is more than 5 categories in my variable (column), and then the rest of my script is ran.

I think the "n items" function is the one I need: 

 

If(N items(:Y1)>5,	

 

However, it doesn't work and I received a error saying: bar argument (:Y)...

Please someone can help me?

Sebastien

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JMP script: If N categories > 5 script

You will have to first get a list of possible categories before using N Items. One fairly simple one is using associative array:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
If(N Items(Associative Array(:age)) > 5,
	show(N Items(Associative Array(:age)));
	show("if");
,
	show(N Items(Associative Array(:age)));
	show("else");
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: JMP script: If N categories > 5 script

You will have to first get a list of possible categories before using N Items. One fairly simple one is using associative array:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
If(N Items(Associative Array(:age)) > 5,
	show(N Items(Associative Array(:age)));
	show("if");
,
	show(N Items(Associative Array(:age)));
	show("else");
);
-Jarmo
Sebastienlg
Level II

Re: JMP script: If N categories > 5 script

That is exactly that I wanted!

Thank's a lot for your answer.

Sebastien

Recommended Articles