根據另一個數據表中的數據更新列軸參考線我正在尋找基於來自另一個數據能力的數據添加列參考線。 例如,使用“Big Class”將使用查找數據表中的 P50 和 P95 值更新“體重”和“高度”列。
查找數據表上的行對應於主表中的列名稱。 參考線需要從查找表列名稱“P50”或“P95”分配標籤值,並且該值來自該列中的行。
顯示添加的列軸參考線的示例:

查找數據表示例:

我不太熟悉 JSL,因此非常感謝您在這個主題上提供的任何幫助。 我已經創建了一個腳本,但它沒有執行我想要的操作。
它似乎損壞了列,有時在繪製分佈時顯示所有“0”值。 另外,如果我嘗試添加 P50 和 P95 參考線,則只有最後一個參考線會保存到該列中,並且會將其保存在兩列中。
dt = Open ("C:\Program Files\SAS\JMP\15\Samples\Data\big class.jmp");
dtLookup = New Table( "Lookup Table",
Add Rows( 2 ),
New Column( "Column Name",
Character,
Nominal,
Set Values( {"weight", "height"} )
),
New Column( "P50",
"Continuous",
Set Values( [100, 61] )
),
New Column( "P95",
"Continuous",
Set Values( [120, 70] )
)
);
col_name_list = dt << get column names(string);
col_name_list_lookup = dtLookup << get column names(string);
numRowsLookup = N Rows( dtLookup );
numColsLookup = N Cols( dtLookup );
for(n=1,n<=numRowsLookup,n++,
col_name = dtLookup[n,1];
If(contains(col_name_list,col_name),
for(j=2,j<=numColsLookup,j++,
col = Column(dt, col_name);
col_name_Lookup = col_name_list_lookup[j];
value = Column(dtLookup,col_name_Lookup)[n];
col <<
Set Property("Axis",
{
//Add Ref Line( 63, "Dashed", "Orange", "P50", 2 )
Add Ref Line( value, "Dashed", "Orange", col_name_Lookup, 2 )
});
);
);
);
謝謝你,
羅傑
自動化和腳本編寫數據混合和清理大規模定制回复:根據另一個數據表中的數據更新列軸參考線最後更新在這裡。 特別感謝賈莫。
我能夠按預期工作。 最終代碼在這裡供將來參考。
Names Default To Here(1);
namespace("here")<<REMOVE></REMOVE> New Column("P99", "Continuous", Set Values([125, 75]))
);
col_name_list = dt << get column names(string);
col_name_list_lookup = dtLookup << get column names(string);
For Each Row(dtLookup,
col_name =:"Analysis Columns"n; //Ref column name
new_properties = {}; // re-init
old_properties = {}; // re-init
If(contains(col_name_list,col_name),
old_properties = Column(dt, col_name) << get property("Axis");
//Add Multiple Ref Lines
For( i = 2, i <= N Items( col_name_list_lookup ), i++,
new_properties_temp =
EvalExpr({
Add Ref Line(Expr(as column(dtLookup,col_name_list_lookup[i])), "Dashed", Expr(Color To RGB( 67 )),Expr(char(col_name_list_lookup[i])), 1)
});
new_properties = Insert(new_properties, new_properties_temp);
);
//end Add Multiple
//Add Specified Reference Lines
//new_properties = EvalExpr({
// Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2),
// Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)
//});
If(!IsList(old_properties),
prop_to_add = Name Expr(new_properties),
prop_to_add = Insert(old_properties, new_properties);
);
//show(prop_to_add); // for debug
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",expr(prop_to_add)))); //Applies the new axis settings.
);
);
回复:根據另一個數據表中的數據更新列軸參考線嗨,賈莫,
我很感謝對此的幫助。 不幸的是,我沒有看到這裡更新舊的和新的軸屬性。 我看到“prop_to_add”列表附加了舊屬性和新屬性,但是當我檢查實際的軸設置時,我只看到了兩個新屬性。
從設置的屬性中刪除大括號後,它能夠按預期工作!
現在我只需要在 N 個查找列上完成這項工作。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dtLookup = New Table("Lookup Table",
Add Rows(2),
New Column("Column Name", Character, Nominal, Set Values({"weight", "height"})),
New Column("P50", "Continuous", Set Values([100, 61])),
New Column("P95", "Continuous", Set Values([120, 70]))
);
col_name_list = dt << get column names(string);
col_name_list_lookup = dtLookup << get column names(string);
Column(dt, "weight") << Set Property("Axis", {Add Ref Line(10, "Dashed", "Red", "P10", 2)}); //debugging axis property
//stop();
For Each Row(dtLookup,
//stop();
Row() = 1;
col_name = Column(dtLookup, "Column Name")[Row()]; //easier to work with without For Each Row
If(contains(col_name_list,col_name),
old_properties = Column(dt, col_name) << get property("Axis");
//stop();
new_properties = EvalExpr({Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2), Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)});
//stop();
If(!IsList(old_properties),
prop_to_add = Name Expr(new_properties),
prop_to_add = Insert(old_properties, new_properties);
);
show(prop_to_add);
//stop();
//Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",{Expr(prop_to_add)}))); // Didn't work with the braces.
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",expr(prop_to_add)))); //Worked when removing the braces.
);
);回复:根據另一個數據表中的數據更新列軸參考線您可以嘗試分段調試代碼。 您可以使用 Row() = rownumber 而不是循環來逐行“運行”For Each Row。
//For Each Row(dtLookup,
Row() = 1;
col_name =:"Column Name"n;
If(contains(col_name_list,col_name),
old_properties = Column(dt, col_name) << get property("Axis");
old_with_new = Insert(old_properties,
{Expr( Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2),
Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)
)
});
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",{
Expr(old_with_new)
})));
);
);
然後開始逐行運行代碼:
old_properties = Column(dt, col_name) << get property("Axis");
//Empty()
一些調試斷點(我不使用調試器,但使用它很可能會更容易):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dtLookup = New Table("Lookup Table",
Add Rows(2),
New Column("Column Name", Character, Nominal, Set Values({"weight", "height"})),
New Column("P50", "Continuous", Set Values([100, 61])),
New Column("P95", "Continuous", Set Values([120, 70]))
);
col_name_list = dt << get column names(string);
col_name_list_lookup = dtLookup << get column names(string);
Column(dt, "weight") << Set Property("Axis", {Add Ref Line(10, "Dashed", "Red", "P10", 2)}); //debugging axis property
stop();
For Each Row(dtLookup,
stop();
Row() = 1;
col_name = Column(dtLookup, "Column Name")[Row()]; //easier to work with without For Each Row
If(contains(col_name_list,col_name),
old_properties = Column(dt, col_name) << get property("Axis");
stop();
new_properties = EvalExpr({Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2), Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)});
stop();
If(!IsList(old_properties),
prop_to_add = Name Expr(new_properties),
prop_to_add = Insert(old_properties, new_properties);
);
show(prop_to_add);
stop();
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",{Expr(prop_to_add)})));
);
);
插入的腳本索引:

一些協助編寫腳本的鏈接:
JSL 語法參考
腳本指南
JMP 16 幫助
回复:根據另一個數據表中的數據更新列軸參考線Insert() 函數在這裡做什麼? 我覺得它無法工作。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dtLookup = New Table("Lookup Table",
Add Rows(2),
New Column("Column Name", Character, Nominal, Set Values({"weight", "height"})),
New Column("P50", "Continuous", Set Values([100, 61])),
New Column("P95", "Continuous", Set Values([120, 70]))
);
col_name_list = dt << get column names(string);
col_name_list_lookup = dtLookup << get column names(string);
For Each Row(dtLookup,
col_name =:"Column Names"n;
If(contains(col_name_list,col_name),
old_properties = Column(dt, col_name) << get property("Axis");
old_with_new = Insert(old_properties,
{Expr( Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2),
Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)
)
});
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis",{
Expr(old_with_new)
})));
);
);回复:根據另一個數據表中的數據更新列軸參考線我不是 100% 確定,但也許您可以首先使用 << Get Propery("Axis") 獲取舊的 Axis 屬性,然後添加到其中。
也許是這樣的(也可能有更簡單的方法):
old_properties = Column(dt, "height") << get property("Axis");
old_with_new = Insert(old_properties, Expr(Add Ref Line(1, "Dashed", "Orange", "P45", 2)));
Eval(EvalExpr(column(dt, "height") << Set Property("Axis",{expr(old_with_new)})));回复:根據另一個數據表中的數據更新列軸參考線謝謝賈莫。 這個解決方案要簡單得多,但它似乎會覆蓋任何現有的軸參考線。 您知道是否有辦法保留該列中已存在的任何軸參考線?
回复:根據另一個數據表中的數據更新列軸參考線這是一個示例腳本。 我的猜測是,如果您嘗試多次這樣做,軸就會被覆蓋,因此您可能必須將它們添加到相同的 << Set Property 中(構建表達式的多種不同方式來執行此操作)。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dtLookup = New Table("Lookup Table",
Add Rows(2),
New Column("Column Name", Character, Nominal, Set Values({"weight", "height"})),
New Column("P50", "Continuous", Set Values([100, 61])),
New Column("P95", "Continuous", Set Values([120, 70]))
);
For Each Row(dtLookup,
col_name =:"Column Name"n;
//because we know we have only two lines to add and they are always added
Eval(EvalExpr(Column(dt, col_name) << Set Property("Axis", {
Add Ref Line(Expr(:P50), "Dashed", "Orange", "P50", 2),
Add Ref Line(Expr(:P95), "Dashed", "Orange", "P95", 2)
}))
);
);

不知道評估(EvalExpr())這裡是必要的,但不會造成傷害。
回覆:根據另一個資料表中的資料更新列軸參考線這是一個非常有用的 JSL 腳本,可以直接將資料匯入到 Axis 中。請問是否可以將以下標籤設定新增至上面的 JSL 腳本?
我嘗試添加/修改您的代碼並添加其他設置,但出現了錯誤。
對於(i = 2,i <= N 項(col_name_list_lookup),i++,
new_properties_temp =
EvalExpr({
新增 Ref Line(Expr(as column(dtLookup,col_name_list_lookup[i])), "虛線", Expr(Color To RGB( 0 )),Expr(char(col_name_list_lookup[i])), 1,
標籤位置("內聯"),相反軸(1))
)
});
new_properties = Insert(new_properties, new_properties_temp);
);

回覆:根據另一個資料表中的資料更新列軸參考線請確保所有支架都處於正確位置。
看更多...
For(i = 2, i <= N Items(col_name_list_lookup), i++,
new_properties_temp = Eval Expr(
{Add Ref Line(
Expr(As Column(dtLookup, col_name_list_lookup[i])),
"Dashed",
Expr(Color To RGB(0)),
Expr(Char(col_name_list_lookup[i])),
1,
Label Position("Inside Inline"),
Opposite Axis(1)
)}
);
new_properties = Insert(new_properties, new_properties_temp);
);