要创建列公式,您可以使用如果声明或匹配陈述;匹配语法更容易阅读:
New Table( "example",
New Column( "DOW", character, Set Values( {"Mon", "Tue", "Wed", "Thu"} ) ),
New Column( "T-28", Set Values( [38, 35, 26, 28] ) ),
New Column( "T-21", Set Values( [45, 47, 43, 48] ) ),
New Column( "T-14", Set Values( [60, 65, 54, 65] ) ),
New Column( "T-13", Set Values( [63, 68, 62, 70] ) ),
New Column( "T-12", Set Values( [65, 78, 72, 72] ) ),
New Column( "T-11", Set Values( [70, 82, 72, 72] ) ),
New Column( "Conditional",
Formula(
Match( :DOW,
"Mon", :Name( "T-28" ),
"Tue", :Name( "T-21" ),
"Wed", :Name( "T-14" ),
"Thu", :Name( "T-13" ),
-9999 // else...use . for missing value
)
)
)
)
因为列名包含连字符(减号),所以它们需要 name() 包装器。
使用 if 语句:
New Table( "example",
New Column( "DOW", character, Set Values( {"Mon", "Tue", "Wed", "Thu"} ) ),
New Column( "T-28", Set Values( [38, 35, 26, 28] ) ),
New Column( "T-21", Set Values( [45, 47, 43, 48] ) ),
New Column( "T-14", Set Values( [60, 65, 54, 65] ) ),
New Column( "T-13", Set Values( [63, 68, 62, 70] ) ),
New Column( "T-12", Set Values( [65, 78, 72, 72] ) ),
New Column( "T-11", Set Values( [70, 82, 72, 72] ) ),
New Column( "Conditional",
Formula(
if(
:DOW=="Mon", :Name( "T-28" ),
:DOW=="Tue", :Name( "T-21" ),
:DOW=="Wed", :Name( "T-14" ),
:DOW=="Thu", :Name( "T-13" ),
-9999 // else...use . for missing value
)
)
)
)
The else value handles unknown day namesThe else value handles unknown day nameselse 值处理未知的日期名称
JMP 确实更愿意使用 .对于缺失值而不是-9999;我在这个演示中使用了它,所以效果会很明显。
您还可以使用公式编辑器代替 JSL;单击数据表左侧面板(上图)中条件列旁边的 + 以查看公式编辑器(下图):
The Formula Editor has a list of functionsThe Formula Editor has a list of functions公式编辑器有一个函数列表
如果秘密博客文章
了解多种功能很有价值。 我喜欢使用列表的强大功能,并且不喜欢在表中使用函数,除非我附加脚本来设置列的值。
Names Default To Here( 1 );
dt = New Table("example",
New Column("DOW", character, values({"Mon", "Tue", "Wed", "Thu" }) ),
NewColumn("T-28", numeric, values({38,35,26,28})),
NewColumn("T-21", numeric, values({45, 47, 43, 48})),
NewColumn("T-14", numeric, values({60, 65, 54, 65})),
NewColumn("T-13", numeric, values({63, 68, 62, 70})),
NewColumn("T-12", numeric, values({65, 78,72,72})),
NewColumn("T-11", numeric, values({70,82,72,72}))
);
dt << newColumn("Conditional", numeric);
dowlist = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
clist = {"T-28", "T-21", "T-14", "T-13", "T-12", "T-11"};
dt:Conditional << set each value( Column(dt,clist[Contains(dowlist, :DOW)])[] ) ; 
@anjana ,
我建议你看看这里。 这是了解如何在 JMP 中使用不同功能的非常有用的资源

这是一个示例,如果 x 是您尝试分配给其中一列的值,那么如果列 DOW = "Mon" 中的值,则将 x 的值分配给列 "T-28" ,否则将其分配给“T-12”列
:Name("T-28") = x ; <BR /> , <BR /> // else <BR /> :Name(T-12) = x; <BR /> ); If(:DOW == "Mon",
// then <BR />