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

Example: Binning Data by Using the If Function

Started ‎11-08-2022 by
Modified ‎11-08-2022 by
View Fullscreen Exit Fullscreen

So let's look at an example of using the If function. Suppose you have data from a public school in the US with grade levels for each student. Some grade levels are grouped into schools, and you want to use the numeric data to group the students by school. This is an example of binning data, where the bins represent ranges of values, and the If statement is an easy way to assign the different grades to the appropriate school. Now, the key to using the If function to bin data is to order the odd numbered arguments (the Boolean expressions, or conditions), in a way that the value to be tested changes monotonically in one direction or the other. In other words, the values either only increase or only decrease in successive tests. This simplifies your code, because then you don't need to provide both a lower and an upper bound for each condition -- because remember, once a true condition is evaluated, the script returns the corresponding result and doesn't evaluate the remaining conditions.