我將使用一種交互式方法來為此捕獲腳本。 首先,讓我們從數據表開始:

我離開了Count,因為我們不需要它,但是如果有的話它不會受到傷害。
我選擇了“分數”列,然後導航至“列數”,“實用程序”,“建立合併公式”:

並將“偏移”設置為0.5,並將bin寬度設置為0.1:

右鍵單擊新列(“分值”),然後單擊“複製列屬性”:

然後打開一個新的腳本窗口並粘貼(ctrl-V),這將導致此JSL:
Add Column Properties(
Value Labels(
{-0.5 = "-0.5 — -0.4", -0.4 = "-0.4 — -0.3", -0.3 = "-0.3 — -0.2", -0.2 =
"-0.2 — -0.1", -0.1 = "-0.1 — 0", 0 = "0 — 0.1", 0.1 = "0.1 — 0.2", 0.2 =
"0.2 — 0.3", 0.3 = "0.3 — 0.4", 0.4 = "0.4 — 0.5", 0.5 = "0.5 — 0.6", 0.6 =
"0.6 — 0.7", 0.7 = "0.7 — 0.8", 0.8 = "0.8 — 0.9", 0.9 = "0.9 — 1", 1 =
"1 — 1.1", 1.1 = "1.1 — 1.2", 1.2 = "1.2 — 1.3", 1.3 = "1.3 — 1.4", 1.4 =
"1.4 — 1.5", 1.5 = "1.5 — 1.6", 1.6 = "1.6 — 1.7", 1.7 = "1.7 — 1.8", 1.8 =
"1.8 — 1.9", 1.9 = "1.9 — 2"}
),
Use Value Labels( 1 ),
Formula( 0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 ) )
)這裡有兩件事:我們不在乎任何分數小於0.5(在您的描述中不存在)或大於1,因此我們可以稍微更改屬性並編輯標籤名稱以匹配您想要的分數。 我還添加了一個If語句來捕獲分數恰好為1的極端情況
Add Column Properties(
Value Labels(
{0.5 = "0.5 — 0.59", 0.6 = "0.6 — 0.69", 0.7 = "0.7 — 0.79", 0.8 = "0.8 — 0.89", 0.9 =
"0.9 — 1"}
),
Use Value Labels( 1 ),
Formula(
If(
(0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )) == 1, 0.9,
0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )
)
)
);(順便說一下,這些標籤在技術上並不准確,因為0.599會被標記為介於0.5和0.59之間)
我們可以在此代碼段周圍包裝一些代碼以使其可重用,在這裡使用當前數據表,添加一個名為Score Binned的新列,並將這些屬性添加到該列:
dt = Current Data Table();
dt << New Column("Score Binned", Character);
dt:"Score Binned"n << Add Column Properties(
Value Labels(
{0.5 = "0.5 — 0.59", 0.6 = "0.6 — 0.69", 0.7 = "0.7 — 0.79", 0.8 = "0.8 — 0.89", 0.9 =
"0.9 — 1"}
),
Use Value Labels( 1 ),
Formula(
If(
(0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )) == 1, 0.9,
0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )
)
)
);現在,回到表上,“表>摘要”將我們帶到了想要去的地方。 我們將“分組”和“分數綁定”放入“分組”,這就是我們實際需要的:


現在,N Rows是我們想要的,它只是被命名錯誤,所以讓我們雙擊左側的“ Source”一詞並複製表創建腳本,並將命名的表引用替換為工作表中的“ dt”變量“ summ”中的新表:

dt = Current Data Table();
dt << New Column("Score Binned", Character);
dt:"Score Binned"n << Add Column Properties(
Value Labels(
{0.5 = "0.5 — 0.59", 0.6 = "0.6 — 0.69", 0.7 = "0.7 — 0.79", 0.8 = "0.8 — 0.89", 0.9 =
"0.9 — 1"}
),
Use Value Labels( 1 ),
Formula(
If(
(0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )) == 1, 0.9,
0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )
)
)
);
summ = dt << Summary(
Group( :Group, :Score Binned ),
Freq( "None" ),
Weight( "None" )
);最後,根據需要將N行重命名為“ Total_Count”:
dt = Current Data Table();
dt << New Column("Score Binned", Character);
dt:"Score Binned"n << Add Column Properties(
Value Labels(
{0.5 = "0.5 — 0.59", 0.6 = "0.6 — 0.69", 0.7 = "0.7 — 0.79", 0.8 = "0.8 — 0.89", 0.9 =
"0.9 — 1"}
),
Use Value Labels( 1 ),
Formula(
If(
(0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )) == 1, 0.9,
0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )
)
)
);
summ = dt << Summary(
Group( :Group, :Score Binned ),
Freq( "None" ),
Weight( "None" )
);
summ:"N Rows"n << Set Name("Total_Count");現在,關閉摘要表,從源表中刪除“得分綁定”列,然後測試腳本:

最終的JSL:
dt = Current Data Table();
dt << New Column("Score Binned", Character);
dt:"Score Binned"n << Add Column Properties(
Value Labels(
{0.5 = "0.5 — 0.59", 0.6 = "0.6 — 0.69", 0.7 = "0.7 — 0.79", 0.8 = "0.8 — 0.89", 0.9 =
"0.9 — 1"}
),
Use Value Labels( 1 ),
Formula(
If(
(0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )) == 1, 0.9,
0.5 + 0.1 * Floor( (:Score - 0.5) / 0.1 )
)
)
);
summ = dt << Summary(
Group( :Group, :Score Binned ),
Freq( "None" ),
Weight( "None" )
);
summ:"N Rows"n << Set Name("Total_Count");測試了您所附的數據,我剛剛才注意到:flushed_face:

這裡有幾種方法可以做到這一點。但是由於下面的示例實際上僅基於主要的JMP功能,因此我強烈建議您從“幫助”下拉菜單下的“ JMP文檔庫”中閱讀“發現JMP”和“使用JMP”文檔。
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Score Category",
character,
formula(
If(
:Score < .6, "0.50-0.59",
:Score < .8, "0.60-0.79",
:Score < .9, "0.80-0.89",
"0.90-1.00",
)
)
);
dtSum = dt << Summary(
Group( :Group, :Score Category ),
Sum( :Count ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 )
);
dtSum << delete columns( :N Rows );
dtSum:Name( "Sum(Count)" ) << set name( "Total_Count" );
// or
dt:score << set property(
"value labels",
{0.5 <= "0.50-0.59" < 0.6, 0.6 <= "0.60-0.79" < 0.8, 0.8 <= "0.80-0.89" < 0.9, 0.9
<= "0.90-1.00" <= 1}
);
dtSum = dt << Summary(
Group( :Group, :Score ),
Sum( :Count ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 )
);
dtSum << delete columns( :N Rows );
dtSum:Name( "Sum(Count)" ) << set name( "Total_Count" );