Posted by
Marks, Jim on
Oct 02, 2006; 8:02pm
URL: http://spssx-discussion.165.s1.nabble.com/How-to-calculate-the-average-for-many-observations-tp1071306p1071309.html
Is "0" defined as a missing value for lnwage? If so, 0 values will be
excluded from calculations.
This syntax creates a new dataset with the mean values.
*** sample data for illustration.
DATA LIST FREE /age (f8.0) sex (a8) educ0 educ1 educ2 educ3 (4f8.0)
lnwage (f8.2).
BEGIN DATA
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
END DATA.
** define missing value-- not included in aggregate calculations.
MISSING VALUE lnwage (0).
*** valid for v14 and higher.
DATASET NAME origdata.
DATASET DECLARE aggrdata.
** for older versions provide a filename within single apostrophes (e.g.
'c:\path\fname.sav' ) in place of aggrdata
AGGREGATE OUTFILE = aggrdata /BREAK = age sex educ0 educ1 educ2 educ3
/lnwage = MEAN(lnwage).
--jim
-----Original Message-----
From: SPSSX(r) Discussion [mailto:
[hidden email]] On Behalf Of
Dimitris Nikolaou
Sent: Monday, October 02, 2006 1: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/