cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Pro extension simulates Bayesian Optimization runs. Prediction formulas stand in for experimental results. Run simulations and compare results. Download and use the extension.

Discussions

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

How can I write a good condition if else if in JMP

Hello I have several columns with data and I want to add another col which will get a formula like this:

A B C

2 5

3 4

5 5

4 7

C column will get an if else formula for example: If(A&B==4 then C ==Good) else if(A&B==3 then C ==bad) else if(A&B==1 then C ==Good)

How can I write this in a formula ?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: How can I write a good condition if else if in JMP

If Secrets has a good description of how to use the If() function.

Craige

View solution in original post

pmroz
Super User

Re: How can I write a good condition if else if in JMP

This code will do what you described:

New Table( "Untitled", Add Rows( 6 ),
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [2, 3, 5, 4, 4, 1] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [5, 4, 5, 7, 4, 1] ) ),
	New Column( "C", Character, "Nominal", Formula(
			If( :A == 4 & :B == 4, "Good",
				:A == 3 & :B == 3, "Bad",
				:A == 1 & :B == 1, "Good"
			)
		)
	)
);

Craig's link is excellent, especially because it discusses what happens with null values. 

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: How can I write a good condition if else if in JMP

If Secrets has a good description of how to use the If() function.

Craige
pmroz
Super User

Re: How can I write a good condition if else if in JMP

This code will do what you described:

New Table( "Untitled", Add Rows( 6 ),
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [2, 3, 5, 4, 4, 1] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [5, 4, 5, 7, 4, 1] ) ),
	New Column( "C", Character, "Nominal", Formula(
			If( :A == 4 & :B == 4, "Good",
				:A == 3 & :B == 3, "Bad",
				:A == 1 & :B == 1, "Good"
			)
		)
	)
);

Craig's link is excellent, especially because it discusses what happens with null values. 

Recommended Articles