Choose
Choose using New Column
Summary: Creates a new column in a JMP data table with a custom formula based on multiple conditions, including age and height.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Pred Formula",
formula(
If( :height < 65,
If( :height < 60,
79,
Choose( Match( :age, 12, 1, 13, 1, 14, 2, 15, 2, 16, 2, 17, 2, 3 ), 109.833333333333, 97.1538461538462, 101.157894736842 )
),
123.214285714286
)
)
);
Code Explanation:
- Open data table;
- Create new column "Pred Formula".
- Define formula for "Pred Formula".
- Check if height < 65.
- If height < 60, set value to 79.
- If height >= 60, match age.
- For age 12-17, choose formula values.
- If age doesn't match, use default value.
- If height >= 65, set value to 123.214285714286.