這是我對使用每列的 Column 屬性中的規格限制來測試每一行的看法。用於測試的方法是對每一列應用範圍檢查。之所以使用它,是因為它是一種通過一次操作處理列中所有數據的非常有效的方法。鑑於您要處理的列數,此方法應該比測試每個單元格更有效。在腳本中,我使用示例數據文件夾中的半導體數據表。它為所有 128 個測量列設置了所有規格限制。
Names Default To Here( 1 );
dtOrig = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
colNamesList = dtOrig << get column names( continuous, string );
// Create a work table of just the continuous columns
dt = dtOrig << subset( columns( colNamesList ), selected rows( 0 ) );
// Loop across all of the columns and apply a Range Check to eliminate
// all data outside of the upper and lower spec limits
For( theCol = 1, theCol <= N Items( colNamesList ), theCol++,
specs = Column( dt, colNamesList[theCol] ) << get property( "spec limits" );
Eval(
Substitute(
Expr(
Column( dt, colNamesList[theCol] ) << set property(
"Range Check",
(LELE( __LSL__, __USL__ ))
)
),
Expr( __LSL__ ), specs["LSL"],
Expr( __USL__ ), specs["USL"]
)
);
// Now convert the column to numeric
Column( dt, colNamesList[theCol] ) << data type( character );
// Now find all cells where values were eliminated
dt << select where( As Column( dt, colNamesList[theCol] ) == "" );
// If non passing rows were found, process the column to change the passing rows to
// a blank, and non passing to the name of the column
If( N Rows( dt << get selected rows ) > 0,
// Now set all eliminated cells to have the value of the name of the column
Column( dt, colNamesList[theCol] )[dt << get selected rows] = Column( dt, colNamesList[theCol] ) <<
get name;
// Invert the row selection, to select all rows where values passed and set them to a blank
dt << invert row selection;
Column( dt, colNamesList[theCol] )[dt << get selected rows] = "";
, // else set all
Column( dt, colNamesList[theCol] )[Index( 1, N Rows( dt ) )] = ""
);
);
// Now create a new column to hold the information on either that the row Passed or
// which columns failed
dt << New Column( "Pass_Fail", Character );
// Loop across all rows and set the values for the new column
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
If( Trim( Concat Items( dt[theRow, 0, ""] ) ) == "",
:Pass_Fail[theRow] = "Pass"
,
thePass_Fail = Concat Items( dt[theRow, 0], "," );
For( i = Length( thePass_Fail ), i >= 2, i--,
If( Substr( thePass_Fail, i, 1 ) == ",",
If( Substr( thePass_Fail, i - 1, 1 ) == ",",
thePass_Fail = Substr( thePass_Fail, 1, i - 1 ) || Substr( thePass_Fail, i + 1 )
)
)
);
If( Right( thePass_Fail, 1) == ",", thePass_Fail = Left( thePass_Fail, length( thePass_Fail ) - 1 ) );
:Pass_Fail[theRow] = thePass_Fail;
)
);
// Only the new column is what is needed, so delete all other columns
dt << delete columns( eval(colNamesList) );
// Add the new column to the original data table
dtOrig << Update(
With( dt )
);
// Delete the no longer needed work table
close(dt, nosave );好吧,我不熟悉那個加載項,但也許是它的作者@txnelson可以在此處討論如何集成來自該加載項的信息。 我已經寫了一個小例子來做你正在尋找的東西,針對你的 7 列示例表進行了測試,我希望它可以擴展到你的 1000 列版本。 我假設我們有一個上限列表 (UL) 和一個下限列表 (LL),它們與列的順序相同。 如果需要,您可以從數據表中讀取列,我只是不知道從加載項中訪問數據表的位置。
有許多不同的方法可以實現它。 我寫的只是一種方式。 我使用的總體計劃是:根據各自的限制檢查每一列。 如果它不符合規範,請附加到一個列表中並註明這一點。 在循環結束時,如果列表為空,則寫入 PASS。 否則,連接列表中的所有項目。
dt = current data table(); // Process Measurements.jmp
// I just made these up.
// Assuming they are in the same order as the column names
ul = {10.5, 13.8, 2, 5, 1.1, 0.8, 11.8};
ll = {5.5, 13.4, 0.1, 1, 0.2, 0.2, 7};
col_list = dt << get column names(String);
dt << New Column("Check", Character, Nominal); // make blank column
// note that the new column is not in col_list
For Each Row( // in current data table
failcheck = {}; // initialize empty list
For(c=1, c<=N Items(col_list), c++, // loop over columns in col_list
// check if lower than LL or higher than UL
If(column(dt,col_list[c])[] < ll[c] | column(dt,col_list[c])[] > ul[c],
// if so, add this column to the failcheck list
Insert Into(failcheck, col_list[c])
)
);
If(N Items(failcheck)==0, // is the list empty?
column(dt,"Check")[] = "PASS",
column(dt,"Check")[] = Concat Items(failcheck,", ")
);
);這有意義嗎? 如果您對正在發生的事情有任何疑問,請告訴我。