Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

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.)

share|improve this question
    
I'm pretty confused by what you are asking to do. Can you describe the format of your data and why using if statements won't accomplish what you are trying to do? –  Andy W Nov 10 '10 at 18:40
    
Hi Andy. I've updated my question to include an example. Hope it's clearer now. –  Tom Wright Nov 10 '10 at 18:55
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
    
Hi Jon, could you explain how to generate ranks within groups? –  Tom Wright Nov 14 '10 at 17:32
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.