Calculating points

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculating points

Vanessa K
Hi there,

I am a beginner SPSS user and would like some help please.This is
something that I have normally done in excel and I am wondering how I can
do it in SPSS.

I have three variables that ask respondents to select the first, second
and third most valuable product. Each variable contains the same list of
six options. I would like to allocate points (3 for most valuable, 2 for
second and 1 for third) and then sum the points to find out the most
valuable to least valuable products.

I would really appreciate your help for this one.

Cheers,
Vanessa

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re:Calculating points

Jerabek Jindrich
Hi Vanessa,

One of many possible ways is this:

Let's have three varibles called First Second Third that contain code for product (1 to 6).

*CREATE NEW VARS, points for products 1-6
COMPUTE P1=0.
COMPUTE P2=0.
COMPUTE P3=0.
COMPUTE P4=0.
COMPUTE P5=0.
COMPUTE P6=0.

*Add points for products named as the best.
IF First=1 P1=P1+3.
IF First=2 P2=P2+3.
IF First=3 P3=P3+3.
IF First=4 P4=P4+3.
IF First=5 P5=P5+3.
IF First=6 P6=P6+3.

*Second best.
IF Second=1 P1=P1+2.
IF Second=2 P2=P2+2.
IF Second=3 P3=P3+2.
IF Second=4 P4=P4+2.
IF Second=5 P5=P5+2.
IF Second=6 P6=P6+2.

IF Third=1 P1=P1+1.
IF Third=2 P2=P2+1.
IF Third=3 P3=P3+1.
IF Third=4 P4=P4+1.
IF Third=5 P5=P5+1.
IF Third=6 P6=P6+1.

*Compute sum of the P1 to P6 .

DESCRIPTIVES
  VARIABLES=P1 P2 P3 P4 P5 P6
  /STATISTICS=SUM .



regards
Jindra


> ------------ Původní zpráva ------------
> Od: Vanessa K <[hidden email]>
> Předmět: Calculating points
> Datum: 10.10.2008 02:31:13
> ----------------------------------------
> Hi there,
>
> I am a beginner SPSS user and would like some help please.This is
> something that I have normally done in excel and I am wondering how I can
> do it in SPSS.
>
> I have three variables that ask respondents to select the first, second
> and third most valuable product. Each variable contains the same list of
> six options. I would like to allocate points (3 for most valuable, 2 for
> second and 1 for third) and then sum the points to find out the most
> valuable to least valuable products.
>
> I would really appreciate your help for this one.
>
> Cheers,
> Vanessa
>
> =====================
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Calculating points

Richard Ristow
In reply to this post by Vanessa K
At 08:23 PM 10/9/2008, Vanessa K wrote:

>I have three variables that ask respondents to select the first,
>second and third most valuable product. Each variable contains the
>same list of six options. I would like to allocate points (3 for
>most valuable, 2 for second and 1 for third) and then sum the points
>to find out the most valuable to least valuable products.

Jerabek Jindrich's solution is simple and direct. It does take a line
of code for every product for every response, which can be shorted
using VECTOR and DO REPEAT (tested code):

VECTOR  P(6,F2).
RECODE  P1 TO P6 (ELSE = 0) /* A short way to make all values 0     */.

DO REPEAT Response = First Second Third
          /Value    = 3     2      1.
.  COMPUTE P(Response) = VALUE.
END REPEAT.

*Compute sum of the P1 to P6 .

DESCRIPTIVES
   VARIABLES=P1 P2 P3 P4 P5 P6
   /STATISTICS=SUM .

Or, here's a solution (also tested) by unrolling the data to one line
per response. It will work unchanged for any number of products.

|-----------------------------|---------------------------|
|Output Created               |10-OCT-2008 13:33:51       |
|-----------------------------|---------------------------|
[TestData]

Respondent First Second Third

Alpha         4     6      3
Beta          6     4      2
Gamma         3     1      2
Delta         2     1      5
Epsilon       4     3      6
Zeta          6     1      2
Eta           2     4      1
Theta         4     3      6
Iota          6     2      4
Kappa         1     6      5

Number of cases read:  10    Number of cases listed:  10


DATASET COPY     Unroll.
DATASET ACTIVATE Unroll   WINDOW=FRONT.

VARSTOCASES  /MAKE Product FROM First  Second Third
   /INDEX = Rank "Product's importance rank"(3)
   /KEEP =  Respondent
   /NULL =  KEEP.

Variables to Cases
|-----------------------------|---------------------------|
|Output Created               |10-OCT-2008 13:33:53       |
|-----------------------------|---------------------------|
[Unroll]

Generated Variables
|-------|---------------|
|Name   |Label          |
|-------|---------------|
|Rank   |Product's      |
|       |importance rank|
|-------|---------------|
|Product|Most valuable  |
|       |product        |
|-------|---------------|

Processing Statistics
|-------------|-|
|Variables In |4|
|-------------|-|
|Variables Out|3|
|-------------|-|


NUMERIC    Points(F2).
VAR LABEL  Points 'Point score for this product, from this respondent'.

RECODE RANK (1 = 3)
             (2 = 2)
             (3 = 1) INTO Points.

AGGREGATE OUTFILE=*
    /BREAK=Product
    /Mentions 'No. of times product mentioned' = N
    /Score    "Product's total point score"    = SUM(Points).

FORMATS Mentions Score (F4).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |10-OCT-2008 13:33:54       |
|-----------------------------|---------------------------|
Product Mentions Score

     1        5      10
     2        6      11
     3        4       8
     4        6      14
     5        2       2
     6        7      15

Number of cases read:  6    Number of cases listed:  6
==================================================
APPENDIX: Test data, and all code (both solutions)
==================================================
*  ................................................................. .
*  .................   Test data               ..................... .
SET RNG = MT       /* 'Mersenne twister' random number generator  */ .
SET MTINDEX = 2244 /*  Providence, RI telephone book              */ .

*  Letters from the Greek alphabet, as 'respondent' identifiers: ... .
DATA LIST FIXED/
     Respondent  04-11 (A).
BEGIN DATA
1  Alpha
2  Beta
3  Gamma
4  Delta
5  Epsilon
6  Zeta
7  Eta
8  Theta
9  Iota
10 Kappa
END DATA.

NUMERIC   First  Second Third (F2).
VAR LABEL First  'Most valuable product'
           Second 'Second most valuable product'
           Third  'Third  most valuable product'.

COMPUTE     First   = MIN(6,1+TRUNC(RV.EXP(1/4))).

LOOP        #Try   = 1 TO 20.
.  COMPUTE  Second = MIN(6,1+TRUNC(RV.EXP(1/4))).
END LOOP IF Second NE First .

LOOP        #Try   = 1 TO 20.
.  COMPUTE  Third  = MIN(6,1+TRUNC(RV.EXP(1/4))).
END LOOP IF Third  NE First
         AND Third  NE Second.

DATASET NAME TestData.


.  /**/  FREQUENCIES                     /*-*/
    /**/  VARIABLES=First  Second Third   /*-*/
    /**/  /STATISTICS=MEAN MEDIAN         /*-*/
    /**/  /ORDER=  ANALYSIS               /*-*/.


*  .................   Post after this point   ..................... .
*  ................................................................. .

*  .....  Solution by 'unrolling' the file of responses     .......  .
DATASET ACTIVATE TestData WINDOW=FRONT.
LIST.

DATASET COPY     Unroll.
DATASET ACTIVATE Unroll   WINDOW=FRONT.

VARSTOCASES  /MAKE Product FROM First  Second Third
   /INDEX = Rank "Product's importance rank"(3)
   /KEEP =  Respondent
   /NULL =  KEEP.

NUMERIC    Points(F2).
VAR LABEL  Points 'Point score for this product, from this respondent'.

RECODE RANK (1 = 3)
             (2 = 2)
             (3 = 1) INTO Points.

AGGREGATE OUTFILE=*
    /BREAK=Product
    /Mentions 'No. of times product mentioned' = N
    /Score    "Product's total point score"    = SUM(Points).

FORMATS Mentions Score (F4).
LIST.

*  .....  Solution by counting current points in a vector   .......  .
*         (Modification of solution by Jerabek Jindrich)             .

DATASET ACTIVATE TestData WINDOW=FRONT.
LIST.

DATASET COPY     Vector.
DATASET ACTIVATE Vector   WINDOW=FRONT.

VECTOR  P(6,F2).
RECODE  P1 TO P6 (ELSE = 0) /* A short way to make all values 0     */.

DO REPEAT Response = First Second Third
          /Value    = 3     2      1.
.  COMPUTE P(Response) = VALUE.
END REPEAT.


*Compute sum of the P1 to P6 .

DESCRIPTIVES
   VARIABLES=P1 P2 P3 P4 P5 P6
   /STATISTICS=SUM .

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Calculating points

Vanessa K
In reply to this post by Vanessa K
Great thanks for you help :)

=====================
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