级别:初学者
Mike Muhlada,SAS JMP 开发测试员
Audrey Shull,SAS JMP 高级开发测试经理
本入门演示将通过示例讲解公式编辑器的机制,探究和修复常见错误,并巩固公式创建的最佳实践和实用技巧。详细的演示将涵盖公式生成器的各个方面,包括如何使用拖放操作、键盘快捷键和函数按钮来创建公式。在演示过程中,我们将讨论一些实用函数,发现并纠正常见错误等等。最佳实践主题包括自定义格式、使用公式进行数据“清理”、列转换、字符串操作、JMP 日期函数以及使用中间列构建更复杂的公式。我们将特别强调 JMP 14 的新功能,包括用户定义函数、结果预览、“实时”公式错误/警告检测以及可自定义的函数列表。
// custom function
funcDef=function( {height, weight},
{Default Local},
(weight * 0.45) / (height * 0.025) ^ 2
);
description="This function calculates BMI, given a person's weight and height. Weight is presumed to be in pounds and Height is presumed to be in inches. The conversion to metric is done inside the function itself.";
// Examples can be multiple statements inside expr()
ex2=expr(
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
custom:BMI(:height[4], :weight[4])
);
parmHint1="Height in inches";
parmHint2="Weight in pounds";
//create function using variables
bmi_=New Custom Function("custom", "BMI", funcDef);
bmi_ << Description(description);
bmi_ << Prototype("custom:BMI(height,weight)");
bmi_ << Example("custom:BMI(72,225)");
// expr() Examples need to be passed inside NameExpr()
bmi_ << Example(NameExpr(ex2));
bmi_ << Parameter("Number", parmHint1);
bmi_ << Parameter("Number", parmHint2);
bmi_ << Formula Category( "Discovery" );
bmi_ << Scripting Index Category( "Frankfurt Functions" );
//add myNamespace:AddTen function to system
Add Custom Functions(bmi_);