<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />您好,我正在尝试使用 select where 来使用 for 循环计算两列中满足条件的行数。 在我的脚本的开头(未显示),我使用一个对话框让用户选择 2 列,最终形成一个列表(collist)。 然后,我对每个列使用关联数组来确定每列的唯一值。 第二个对话框允许用户选择每列的唯一值的子集,该子集最终出现在另一个列表中(poschosen)。 我正在努力解决的问题是将 collist 中的列插入到 select where 函数中。 我在 eval、expr、eval expr、parse 等方面尝试了很多不同的尝试,试图正确插入它们,但我似乎找不到正确的方法。 我希望有人有建议。
这是我针对示例数据改编的代码:儿童的受欢迎程度。 我想将学校和目标的值(第 14 行)分别替换为 collist[1] 和 collist[2]。 提前谢谢你的帮助伊丽莎白
dattable=Open( "$SAMPLE_DATA/Children's Popularity.jmp" );
poschosen={"Ridge","Sand","main","stop","Popular","Grades","stop"};
stoppos={4,7}; //determine the position of the separator "stop"
Test1pos=subtract(stoppos[1],1); //determine the # of school column values chosen
Test2posStart=add(stoppos[1],1); //determine where in the list the Goals column values start
collist={"School", "Goals"};
sumpositives=0;
For (i = 1, i <= Test1pos, i++, //loop through the chosen school column values
For(f=Test2posStart, f
dattable< & Goals==Poschosen);
num_selected=nrows(dattable<
sumpositives=sumpositives+num_selected; //add the current selection count to previous count
print(sumpositives); //should be 56 in this example
); //end of inner for loop
); //end of outer for loop
我一直在尝试解决这个问题,终于找到了这个线程。 谢谢你!
没关系,我刚刚想明白了(当然,就在我发布问题之后,doh)...当我这样做时,第 14 行有效:
dattable< & as column(datable,collist[2])==Poschosen);