<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />안녕하세요 for 루프를 사용하여 2개의 열에서 기준을 충족하는 행 수를 계산하기 위해 선택 위치를 사용하려고 합니다. 내 스크립트의 시작 부분(표시되지 않음)에서 사용자가 2개의 열을 선택할 수 있도록 대화 상자를 사용하고 이는 목록(collist)에서 끝납니다. 그런 다음 각각에 대해 연관 배열을 사용하여 열당 고유한 값을 결정합니다. 두 번째 대화 상자에서는 사용자가 다른 목록(poschosen)으로 끝나는 열당 고유 값의 하위 집합을 선택할 수 있습니다. 내가 어려움을 겪고 있는 문제는 collist의 열을 select where 함수에 삽입하는 것입니다. eval, expr, eval expr, parse 등에서 적절하게 삽입하려고 시도했지만 올바른 방법을 찾을 수 없는 것 같습니다. 나는 누군가가 조언을 바랍니다.
샘플 데이터: Children's Popularity에 맞게 조정된 내 코드는 다음과 같습니다. 값(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);