|
I need to aggregate cases to obtain the maximum score but I also need to capture the term period of when the maximum score took place.
Original data example: ID term T1 T2 T3 1 20071 45 13.47 1 20083 35 17 27.58 2 20091 18 3 20061 19 14.23 3 20093 43 17.47 3 20101 13 10.35 I need to end up with: ID T1 T1term T2 T2term T3 T3term 1 45 20071 47.58 20083 2 18 20091 3 43 20093 19 20061 17.47 20093 I’ve used the MAX option in the AGG procedure but I don’t know how to capture the term for the MAX value. Thanks in advance, David ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
David,
This is probably a pretty clunky solution and it's untested but it's what occurs to me at the moment. Suppose you ran Aggregate but set the mode to addvariables. So, you get the max T1, T2, and T3 value for each case. Call those new variables T1Max, T2Max, and T3Max. But, you still have as many cases as you have now. Then, create three new variables. Call them T1Time, T2Time, and T3Time. Then, If (T1Max eq T1) T1Time=term. (repeat for T2 and T3) Then aggregate again and keep the first values for T1Max to T3Max T1Time to T3Time. I think that will give you what you want. Gene Maguin >>I need to aggregate cases to obtain the maximum score but I also need to capture the term period of when the maximum score took place. Original data example: ID term T1 T2 T3 1 20071 45 13.47 1 20083 35 17 27.58 2 20091 18 3 20061 19 14.23 3 20093 43 17.47 3 20101 13 10.35 I need to end up with: ID T1 T1term T2 T2term T3 T3term 1 45 20071 47.58 20083 2 18 20091 3 43 20093 19 20061 17.47 20093 I've used the MAX option in the AGG procedure but I don't know how to capture the term for the MAX value. Thanks in advance, David ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
