In SPSS, is there any way to define a use groups of data based on combinations of variables? I have a data file in which each participant is tested many times in several blocks. The data is formatted so that each trial contains a participant id, a block number and a score. What I want to do is group the data by participant and block, then rank the scores for each group, so I can use the top 50%.
For example:
p_id, block, score
------------------
1     1      35
1     1      84
1     1      12
1     1      76
1     2      51
1     2      67
1     2      54
1     2      18

With this data I would have 2 groups. Of the first (p_id=1,block=1) the second and fourth scores would be used (score=84,score=76). Of the second group, the second and third would be used (score=67,score=54).
How would I go about doing this in SPSS?
(I'm using v16, but have the option of upgrading if necessary.)
 A: Ignore my initial post and take Jon's advice, heres some sample code from the RANKS command where X1 is the variable to rank and GROUPVAR is the variable identifying groups:
RANK VARIABLES=X1 (A) BY GROUPVAR
  /RANK
  /PRINT=YES
  /TIES=MEAN.

You can either go through the GUI to see all of its options or look up the ranks command in the help file. I can't see any reason to prefer my prior code over this simpler command, and it has options to specify fractional ranks or ntiles the ranks fall within (which would be the number you need to specify your select statement to only take the top half of the scores.
Finally I would note there is a Google group forum that answers SPSS questions and the UGA SPSS listserv are both good places to ask SPSS questions.
A: Actually, if you want ranks, try the RANK command.  Or use the menus: Transform>Rank Cases.  It can generate ranks within groups.
If you prefer the AGGREGATE approach, note that it does NOT require sorting first.
HTH,
Jon Peck
A: I think one option is to split a SPSS file in groups. The menu approach is Data > Split file.
I have worked with the rank option, but I think that is better to split the file, for doing other analysis by groups. 
