如果 SPSS 中的列,如何从列表中获取具有最大值的列的标签?

How to get the label of a column which has the max value from the list if columns in SPSS?

假设我有一个具有以下结构的 table。

Column1(integer), Column2(integer), Column3(integer)

我想在Column1、Column2、Column3中做一个max运算,并将具有最大值的列的标签分配给新的列。

Column1(integer), Column2(integer), Column3(integer), Max_among_columns

例如

Column1, Column 2, Column3, Max_among_columns
   2         3        5        Column3

有人知道我该怎么做吗?

应该这样做:

string Max_among_columns (a10).
compute #maxnum=-1000. /* please select some number that's certain to be smaller than the minimum.
do repeat clmn = column1 column2 column3 / clmnName = "column1" "column2" "column3".
    do if clmn > #maxnum.
        compute #maxnum = clmn.
        compute Max_among_columns = clmnName.
    end if.
end repeat.
exe.

如果有多个列包含最大值,将选择其中的第一个。 如果您希望选择最后一个,请替换为:

do if clmn > maxnum.

有了这个:

do if clmn >= maxnum.