Login  Register

Re: How to calculate the average for many observations?

Posted by Naila Baig-Ansari-2 on Oct 03, 2006; 6:10pm
URL: http://spssx-discussion.165.s1.nabble.com/How-to-calculate-the-average-for-many-observations-tp1071306p1071307.html

 Hi Dimitris,

Try this syntax.  It basically selects only those variables that have a wage
and then splits the file into the groups you wanted.  In the final step, it
calculates the MEAN:

USE ALL.
COMPUTE filter_$=(lnwage > 0).
VARIABLE LABEL filter_$ 'lnwage > 0 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

SORT CASES BY age sex educ0 educ1 educ2 educ3 .
SPLIT FILE
  LAYERED BY age sex educ0 educ1 educ2 educ3 .

FREQUENCIES
  VARIABLES=lnwage
  /STATISTICS=MEAN
  /ORDER=  ANALYSIS .

Best
Naila
-------------------------------------------------------------------------
"Our lives begin to end the day we become silent about things that matter"
Dr. Martin Luther King, Jr


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Dimitris Nikolaou
Sent: Monday, October 02, 2006 11:21 PM
To: [hidden email]
Subject: How to calculate the average for many observations?

Hi to everybody!

I have recently come up with a problem. This is a general example:



age      sex       educ0   educ1   educ2   educ3     lnwage
20      male         1        0           0          0            0
20      male         1        0           0          0          9.65
20      male         1        0           0          0          8.56
20      male         0        1           0          0          7.65
20      male         0        1           0          0            0
20      male         0        0           1          0          8.23
20      male         0        0           1          0          8.15
20      male         0        0           1          0          8.00
20      male         0        0           1          0            0
20      male         0        0           0          1          8.88
20      male         0        0           0          1            0
20      male         0        0           0          1          6.57
20   female         1        0           0          0            0
20   female         1        0           0          0          9.65
20   female         1        0           0          0          8.56
20   female         0        1           0          0          7.65
20   female         0        1           0          0            0
20   female         0        0           1          0          8.23
20   female         0        0           1          0          8.15
20   female         0        0           1          0          8.00
20   female         0        0           1          0            0
20   female         0        0           0          1          8.88
20   female         0        0           0          1            0
20   female         0        0           0          1          6.57


I would like to find a way so as the spss to calculate the average for
eevery team. By this I mean I want to calculate the following:

if (age=20 and sex=male and educ0=1) then calculate (9.65+8.56)/2. The
average only for those who have wages.
if (age=20 and sex=male and educ1=1) then calculate (7.65)/1.
....
....
....
if (age=20 and sex=female and educ3=1) then calculate (8.88+6.57)/2.

And I want to do this for every age from 17 to 65. I tried to calculate it
but with no success. My only alternative is to make the calculations
manually. But I have to do this for about 800.000 observation and for more
than once.So I was wondering if there is a faster way.

Thanks in advance!

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/