Search code examples
averagespss

creating an average score variable


I have a dataset that goes as follows:

an ID then his/hers storenumber then the amount of units they bought there.

What i now need from that dataset is a variable that states the following: x buys per ID (for a specific store) (this score would thus be the same for different id's with the same storenumber) example:

ID 1 and 2 have respectively 3 and 5 buys at store 1. then the variable i want would be (3+5)/2=4 then both ID's would get the variable average buys per ID for ID 1 and 2 is 4.

I just cannot get the above done through spss.


Solution

  • This is to create some fake data to play with:

    data list list/storeNum IDinstore NumPurchased.
    begin data
    1 1 3
    1 2 5
    1 3 7
    1 4 9
    2 1 4
    2 2 8
    2 3 12
    end data.
    

    assuming what you want is the average number of units bought in each store, what you should do is aggregate:

    AGGREGATE
      /OUTFILE=* MODE=ADDVARIABLES
      /BREAK=storeNum
      /NumPurchased_mean=MEAN(NumPurchased).