手册:
1。 我有2个数据表,一个是具有控制限制的参数列表,另一个是主数据表。


2。我必须根据模板中的顺序手动对每个列进行排序[升序]。如果Contact小于2 [DC为6]或Contact大于10 [DC为7]并将其放在DC列中-在DC中输入值之后,我将隐藏和排除具有DC值的行,然后继续执行下一个参数,然后再次排序
如果我有多个参数和一个大数据集,该如何进行循环?
首先,我相信,鉴于您提供的示例数据表,您在谈论时出现了错误。
” 接触大于10 [DC为7] ”。 给定Parameter数据表中的值,我相信您打算写:
“接触大于23 [DC为7]”
假设如此,我相信以下脚本将满足您的需求。 它不需要在数据表中逐行浏览,这意味着不必对其进行排序。 我希望这是你所需要的
Names Default To Here( 1 );
// Create Sample data tables
dtParms = New Table("Parameters",
Add Rows(4),
New Column("Order",formula(Row())),
New Column("Parameter", character,values({"Contact","MST","Height","Weight"})),
New Column("CL_LL", values([2,23,59,35])),
New Column("CL_UL", values([23,100,109,105])),
New Column("DC_LL", values([6,10,21,33])),
New Column("DC_UL", values([7,11,22,39]))
);
dtMain = New Table("Main",
Add Rows(100),
New Column("Contact", formula(randominteger(1,27))),
New Column("MST", formula(randominteger(18,115))),
New Column("Height", formula(randominteger(50,120))),
New Column("Weight", formula(randominteger(30,110))),
New Column("DC")
);
dtMain << run formulas;
dtMain:Contact << delete formula;
dtMain:MST << delete formula;
dtMain:Height << delete formula;
dtMain:Weight << delete formula;
// Loop through the data and assign the above and below limits
For(i=1,i<=N Rows(dtParms),i++,
foundRows = dtMain << get rows where( as column(dtMain, dtParms:Parameter[i]) < dtParms:CL_LL[i] & isMissing(dtMain:DC) == 1 );
dtMain:DC[foundRows] = dtParms:DC_LL[i];
foundRows = dtMain << get rows where( as column(dtMain, dtParms:Parameter[i]) > dtParms:CL_UL[i] & isMissing(dtMain:DC) == 1);
dtMain:DC[foundRows] = dtParms:DC_UL[i];
);后续问题:
我不必将dtParms编码,而是将它们存储到同名的数据表中,但是使用脚本编写的结果不会产生结果-但它确实说“ 范围数据表访问需要数据表列或变量{1}“-我该如何解决?
对于代码:
For(i=1,i<=N Rows(dtParms),i++,
foundRows = dtMain << get rows where( as column(dtMain, dtParms:Parameter[i]) < dtParms:CL_LL[i] & isMissing(dtMain:DC) == 1 );
dtMain:DC[foundRows] = dtParms:DC_LL[i];
foundRows = dtMain << get rows where( as column(dtMain, dtParms:Parameter[i]) > dtParms:CL_UL[i] & isMissing(dtMain:DC) == 1);
dtMain:DC[foundRows] = dtParms:DC_UL[i];
);
为了正常工作,您需要将变量“ dtParms”与包含“参数”的数据表相关联。 您说过用相同的名称保存了数据表,所以我假设您将数据表命名为“ Parameters”。 因此,您需要做的是在运行脚本之前打开该数据表,并将以下语句添加到脚本中
dtParms = Data Table("Parameters");