Hi I'm trying to use select where to count the number of rows which meet criteria in 2 columns using a for loop. In the beginning of my script (not shown) I use a dialog to let the user choose 2 columns and this ends up in a list (collist). I then use an associative array on each to determine the unique values per column. A second dialog allows the user to choose a subset of those unique values per column which ends up in another list (poschosen). The problem I'm struggling with is inserting the columns from collist into the select where function. I've tried a bunch of different attempts at eval, expr, eval expr, parse, etc. to try to insert them appropriately but I just can't seem to find the correct way. I'm hoping someone has advice.
Here is my code adapted for the Sample Data: Children's Popularity. I'd like to replace the values (line 14) School and Goals to be collist[1] and collist[2] respectively. Thank you for your help in advance Elizabeth
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<stoppos[2],f++, //loop through the chosen Goals column values
dattable<<select where(School==poschosen & Goals==Poschosen);
num_selected=nrows(dattable<<get selected rows); //count the rows selected
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