<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />您好我正在嘗試使用 select where 來計算使用 for 循環在 2 列中滿足條件的行數。 在我的腳本的開頭(未顯示),我使用一個對話框讓用戶選擇 2 列,這最終出現在一個列表 (collist) 中。 然後我在每個上使用關聯數組來確定每列的唯一值。 第二個對話框允許用戶選擇每列的那些唯一值的子集,這些值最終出現在另一個列表中(poschosen)。 我遇到的問題是將 collist 中的列插入到 select where 函數中。 我在 eval、expr、eval expr、parse 等方面進行了一系列不同的嘗試,以嘗試適當地插入它們,但我似乎無法找到正確的方法。 我希望有人有建議。
這是我為示例數據改編的代碼:兒童的受歡迎程度。 我想將值(第 14 行)School 和 Goals 分別替換為 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(dattable,collist[2])==Poschosen);