我似乎已經找到了我自己的問題的解決方案。它看起來像這樣:
/*Computing strategy*/
/*Calculating dominant action*/
LOOP #i=1 TO 999. /*Assuming I have 999 cases.
/* Calculating the biggest value among activities.
VECTOR #act(4). /* This is a temporary array variable.
COMPUTE #act(1) = Act1.
COMPUTE #act(2) = Act2.
COMPUTE #act(3) = Act3.
COMPUTE #act(4) = Act4.
/*Bubble sorting the numbers.
LOOP #j=1 to 3.
LOOP #k=#j+1 TO 4.
DO IF (#act(#k) >= #act(#j)).
COMPUTE #temp = #k.
COMPUTE #act(#j) = #act(#k).
COMPUTE #act(#k) = #temp.
END IF.
END LOOP.
/*At this point we have the biggest value in the first position of the array variable, i.e. "#act(1)".
/*Here I check whether the specific action is equal to the highest score.
VECTOR #strat(4).
COMPUTE #strat(1) = Act1.
COMPUTE #strat(2) = Act2.
COMPUTE #strat(3) = Act3.
COMPUTE #strat(4) = Act4.
/*Here I create 2 temporary variables to fix the result.
COMPUTE #temp1 = 0.
COMPUTE #temp2 = 0.
/*Next step is hard to explain, but: firstly, an participant could use two strategies, which is ok; secondly, if a participant uses more than 2 strategies, I assume he was acting not strategicaly (it comes from my research design, it may not fit to yours; e.g. Act1 = 0, Act2 = 0, Act3 = 0, Act4=0; or all actions are euqal to 3).
LOOP #m=1 TO 4.
DO IF (#strat(#m) = #act(1)).
DO IF (#temp1 = 0).
COMPUTE #temp1 = #m. /* If the variable has the highest value it is assumed to be a strategy; the value is stored in the variable "#temp1".
ELSE.
DO IF (#temp2=0). /*if the first strtegy is assigned, then the second temporry variable is used, "#temp2".
COMPUTE #temp2 = #m.
ELSE.
COMPUTE #temp1 = 0. /*If all more than 2 variables have "highest" score, than no strategy was played; both temporary variables are defined as 0.
COMPUTE #temp2 = 0.
END IF.
END IF.
END IF.
END LOOP.
/*And finally we create variables which are stored in our dataset and prescribe them values of our temporary variables.
COMPUTE DominantStrategy1 = #temp1.
COMPUTE DominantStrategy2 = #temp2.
END LOOP.
END CASE. /*Making the same with the next case.
END LOOP.
EXECUTE.
這是我的解決方案,它似乎工作!
最佳, 尤金
我不太從你的描述一定要怎麼做排名。因此,對於'UserId'1,'Act2'是最高的,因爲這些行的總和最大(例如'For UserID = 1,Act2 = 3 + 5 + 3 = 11')?大多數排名策略也需要指定如何處理關係。 –