calculating shares

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

calculating shares

Abdul Azeez

Dear All,

I have a large dataset, where I need to calculate the share of each observation in total value. That means, suppose I have a variable x, which has 5 observations (as given below), I need to construct another variable that calculates the share of each observation in total of X (as X1 in the following example.

 

 

X              x1

10           .12

12           .14

15           .18

22           .26

25           .30

 

The sum of X is 84 and hence the first observation in X1 = 10/84; second is 12/84 and so on. Is there any way to do this in spss?

 

Kind regards

 



AA Erumban



Marriage Simplified. Match chat marry.
Reply | Threaded
Open this post in threaded view
|

Re: calculating shares

Richard Ristow
At 10:36 AM 4/25/2007, Abdul Azeez wrote:

>I need to calculate the share of each observation in total value. That
>means, suppose I have a variable x, which has 5 observations (as given
>below), I need to construct another variable that calculates the share
>of each observation in total of X (as X1 in the following example.



>X              x1
>10           .12
>12           .14
>15           .18
>22           .26
>25           .30
>
>The sum of X is 84 and hence the first observation in X1 = 10/84;
>second is 12/84 and so on.

Heres's a fairly standard way. It's a disadvantage, that it clutters up
the final file with variables 'NoBreak' and 'Total'. This is SPSS 15
draft output (WRR-not saved separately):

|-----------------------------|---------------------------|
|Output Created               |27-APR-2007 17:19:43       |
|-----------------------------|---------------------------|
   X     x1

  10    .12
  12    .14
  15    .18
  22    .26
  25    .30

Number of cases read:  5    Number of cases listed:  5


NUMERIC  Share  (F6.2)
         /NoBreak(F2).
COMPUTE  NoBreak = 1.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES
        /BREAK   = NoBreak
        /TOTAL   = SUM(X).
FORMATS TOTAL (F5).
COMPUTE Share = X / Total.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |27-APR-2007 17:19:44       |
|-----------------------------|---------------------------|
   X     x1  Share NoBreak TOTAL

  10    .12    .12     1      84
  12    .14    .14     1      84
  15    .18    .18     1      84
  22    .26    .26     1      84
  25    .30    .30     1      84

Number of cases read:  5    Number of cases listed:  5

P.S. By golly, ran on the first try. Not common, even with simple
stuff. "Three things you should be wary of: A new kid in his prime..."
===================
APPENDIX: Test data
===================
DATA LIST LIST SKIP=1
  /X            x1.
BEGIN DATA
   X            x1
  10           .12
  12           .14
  15           .18
  22           .26
  25           .30
END DATA.

FORMATS X(F3) x1(F6.2).
LIST.