=========================================================================
Date: Mon, 24 Jul 2006 12:30:26 -0700
Reply-To: Frank Berry <frank.berry@yahoo.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Frank Berry <frank.berry@yahoo.com>
Subject: aggregate or matrix?
In-Reply-To: <1141260953.20060724085854@terra.es>
Content-Type: text/plain; charset=iso-8859-1
Hi all,
I have four variables (subj, region, eth - all char variables, and score - numeric variable) with a total of 20,000 records.
Below is a syntax used to get count (N), average, standard deviation (SD) and pct for each category (e1 to e5) in the variable of 'eth' BY 'subj' 'region' 'eth'.
AGGREGATE
/OUTFILE = 'C:\Data\Sum_A.sav'
/BREAK = subj region eth
/count = N
/avg = MEAN(score)
/sd = SD(score)
/eth1_frac = FIN(eth,1,1)
/eth2_frac = FIN(eth,2,2)
/eth3_frac = FIN(eth,3,3)
/eth4_frac = FIN(eth,4,4)
/eth5_frac = FIN(ethnic,5,5).
COMPUTE eth1_N = eth1_frac*count.
COMPUTE eth2_N = eth2_frac*count.
COMPUTE eth3_N = eth3_frac*count.
COMPUTE eth4_N = eth4_frac*count.
COMPUTE eth5_N = eth5_frac*count.
COMPUTE e1_Pct = eth1_N/count*100.
COMPUTE e2_Pct = eth2_N/count*100.
COMPUTE e3_Pct = eth3_N/count*100.
COMPUTE e4_Pct = eth4_N/count*100.
COMPUTE e5_Pct = eth5_N/count*100.
Execute.
Below is what I’d like to get in addition to the count, mean and SD BY 'subj' 'region' 'eth'.
region eth N pct prop
0001 e1 1 2% 0.015384615
0001 e2 5 8% 0.076923077
0001 e3 22 34% 0.338461538
0001 e4 30 46% 0.461538462
0001 e5 7 11% 0.107692308
0001 Total 65 100% 1
But the aggregate function above doesn't seem to work here. Is there a solution using matrix or other functions/syntax? Thank you.
Frank
---------------------------------
|