Date: Thu, 25 Nov 2004 02:01:01 -0500
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: Adding Group totals in the same file
In-Reply-To: <OF019FAA15.00328C6A-ONC2256F54.0057636D@csb.gov.lv>
Content-Type: text/plain; charset="us-ascii"; format=flowed
In response to,
>I have a set of Group Variables i.e. Year, Age, Gender and a series of
>Numeric Variables A1, A2, A3, A4[, and a set of cases for each group].
>I would like to create & insert a new case in the existing sav. file
>showing the Totals for each Numeric variable [for] each combination of
>Group Variable values. I.e a new case with group totals for A1, A2,
>A3, A4 should follow immediately after Year - 1999 , Age - 20, Gender
>- Male
at 10:55 AM 11/22/2004, Martins Liberts wrote:
>***Untested syntax***.
>
>agg out="temp.sav"
> /break year age gender
> /a1 a2 a3 a4=sum(a1 a2 a3 a4).
>
>add files
> /file=*
> /file="temp.sav"
> /in gr_tot.
>
>sort cases by year age gender gr_tot.
I think this is just right. However, if the input file is already
sorted by year-age-gender, the SORT CASES is unnecessary: the new total
case will automatically follow the existing cases in the group, as long
as the file with the totals is listed second on the ADD FILES (as you
have it). Syntax manual, for ADD CASES/BY:
"Cases in the resulting file are ordered by the values of the key
variables. All cases from the first file with the first value for the
key variable are first, followed by all cases from the second file with
the same value, followed by all cases from the third file with the same
value, and so forth. These cases are followed by all cases from the
first file with the next value for the key variable, and so on."
|