There are several approaches. The following is an example that uses the eval insert function.
This page is also helpful to understand expression.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
create tabulate = Expr(
Parse(
Eval Insert(
"\[
tabulate box = dt << Tabulate(
Set Format(
Mean(
:Name( "age" )(6, "Best"),
:Name( "height" )(6, "Best"),
:Name( "weight" )(6, "Best"),
Analysis Columns(
Transform Column(
"age rate",
Formula ( if(:age ^aglf^ ^agel^ & :age ^aguf^ ^ageu^ ,1,0) ),
Format( 9, 2, "Percent" )
)
),
Analysis Columns(
Transform Column(
"height rate",
Formula( if(:height ^helf^ ^heil^ & :height ^heuf^ ^heiu^ ,1,0) )
),
//强行修改格式
Format( 9, 2, "Percent" )
),
Analysis Columns(
Transform Column(
"weight rate",
Formula( if(:weight ^welf^ ^weil^ & :weight ^weuf^ ^weiu^ ,1,0) )
),
Format( 9, 2, "Percent" )
)
),
N( 9, "Best" )
),
Add Table(
Column Table(
//具体固定统计列
Analysis Columns( :Name( "age" ), :Name( "weight" ), :Name( "height" ) ),
Statistics( Mean, Range )
),
//调整样本量列的实际位置
Column Table( Statistics( N ) ),
column table(
Analysis Columns(
Transform Column(
"rate age",
Formula( if(:age ^aguf^ ^agel^ & :age ^aguf^ ^ageu^ ,1,0) )
)
),
Statistics( Mean )
),
Column Table(
Analysis Columns(
Transform Column(
"height rate",
Formula( if(:height ^helf^ ^heil^ & :height ^heuf^ ^heiu^ ,1,0) )
)
),
Statistics( Mean )
),
Column Table(
Analysis Columns(
Transform Column(
"weight rate",
Formula( if(:weight ^welf^ ^weil^ & :weight ^weuf^ ^weiu^ ,1,0) )
)
),
Statistics( Mean )
),
//临时固定类别列,且可以通过拖拽进行增删
Row Table( Grouping Columns( :sex ) )
)
)
]\"
)
)
);
nw = New Window( "合格率报表",
Data Filter Context Box(
H List Box(
dfsb = Current Data Table() << Data Filter( Local ),
Platform(
Current Data Table(),
V List Box(
Outline Box( "请输入所有参数规格限",
Lineup Box( N Col( 3 ), Spacing( 5 ),
Panel Box( "age",
Lineup Box( N Col( 3 ), Spacing( 5 ),
Text Box( "upper " ),
dluf = Combo Box( {"<=", "<"} ),
dlu = Number Edit Box( 15 ),
Text Box( "lower " ),
dlbf = Combo Box( {">=", ">"} ),
dlb = Number Edit Box( -3 )
)
),
Panel Box( "height",
Lineup Box( N Col( 3 ), Spacing( 5 ),
Text Box( "upper " ),
dauf = Combo Box( {"<=", "<"} ),
dau = Number Edit Box( 15 ),
Text Box( "lower " ),
dabf = Combo Box( {">=", ">"} ),
dab = Number Edit Box( 1 )
)
),
Panel Box( "weight",
Lineup Box( N Col( 3 ), Spacing( 5 ),
Text Box( "upper " ),
dbuf = Combo Box( {"<=", "<"} ),
dbu = Number Edit Box( 15 ),
Text Box( "lower " ),
dbbf = Combo Box( {">=", ">"} ),
dbb = Number Edit Box( 1 )
)
),
Button Box( "确定",
//获取规格限数字
ageu = dlu << get;
agel = dlb << get;
heiu = dau << get;
heil = dab << get;
weiu = dbu << get;
weil = dbb << get;
//获取规格限数字是否包含
aguf = ((dluf << XPath( "//ComboBox" )) << get selected)[1];
aglf = ((dlbf << XPath( "//ComboBox" )) << get selected)[1];
heuf = ((dauf << XPath( "//ComboBox" )) << get selected)[1];
helf = ((dabf << XPath( "//ComboBox" )) << get selected)[1];
weuf = ((dbuf << XPath( "//ComboBox" )) << get selected)[1];
welf = ((dbbf << XPath( "//ComboBox" )) << get selected)[1];
Try( tabulate box << delete );
tabulate << append( Eval( create tabulate ) );
)
)
),
//
tabulate = V List Box();
//
)
)
)
)
);