Aggregate Syntax Errors

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

Aggregate Syntax Errors

Bill Oglesby
Good Morning,

Thanks to the recent assistance of a fellow poster, I have made several attempts to use the
AGGREGATE command, some successfully and some not. I am stymied by this morning's efforts to
use what I would think to be a rather simple syntax, the output of which I have pasted below. To
be brief, each 'cipcode' is associated with X number of hours ('crhrsqtr') and one person, so that
another way of looking at this is that each person is associated with a code and a given number of
hours. What I would like to do is sum both the number of hours and the number of people
associated with each cipcode. If I do not include the last line (i.e., the 'headcount' line), then the
syntax runs perfectly vis-a-vis number of hours per cipcode. If the last line is included, then the
following errors detailed below ensue. I'm new at this, so it may be that I'm overlooking
something simple -- or not! Thanks in advance for any assistance that anyone might provide.

Bill

AGGREGATE
     /OUTFILE = 'C:\Documents and Settings\boglesby\Desktop/test.sav'
     /BREAK = cipcode
     /crhrsqtr = SUM (crhrsqtr)
     /headcount = SUM (headcount).

>Error # 10934 in column 24.  Text: headcount
>The AGGREGATE command specifies an unknown existing variable name.
>This command not executed.

>Error # 10921 in column 33.  Text: )
>The number of existing variables does not match the number of new variables in
>a new variable definition on the AGGREGATE command.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Melissa Ives
If each CIPcode is associated with 1 person, then breaking on CIPCode would result in headcount of 1, wouldn't it?
Anyway, check if the n(headcount) would get what you want (as opposed to sum(headcount).

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bill Oglesby
Sent: Friday, October 10, 2008 10:11 AM
To: [hidden email]
Subject: [SPSSX-L] Aggregate Syntax Errors

Good Morning,

Thanks to the recent assistance of a fellow poster, I have made several attempts to use the AGGREGATE command, some successfully and some not. I am stymied by this morning's efforts to use what I would think to be a rather simple syntax, the output of which I have pasted below. To be brief, each 'cipcode' is associated with X number of hours ('crhrsqtr') and one person, so that another way of looking at this is that each person is associated with a code and a given number of hours. What I would like to do is sum both the number of hours and the number of people associated with each cipcode. If I do not include the last line (i.e., the 'headcount' line), then the syntax runs perfectly vis-a-vis number of hours per cipcode. If the last line is included, then the following errors detailed below ensue. I'm new at this, so it may be that I'm overlooking something simple -- or not! Thanks in advance for any assistance that anyone might provide.

Bill

AGGREGATE
     /OUTFILE = 'C:\Documents and Settings\boglesby\Desktop/test.sav'
     /BREAK = cipcode
     /crhrsqtr = SUM (crhrsqtr)
     /headcount = SUM (headcount).

>Error # 10934 in column 24.  Text: headcount The AGGREGATE command
>specifies an unknown existing variable name.
>This command not executed.

>Error # 10921 in column 33.  Text: )
>The number of existing variables does not match the number of new
>variables in a new variable definition on the AGGREGATE command.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Bill Oglesby
In reply to this post by Bill Oglesby
Melissa,

Thanks for taking a look. I must apologize for not being too clear, with respect to 'headcount'. The
file that I am working with is duplicated by 'cipcode' (and not by 'ssn', which is my student
identifier). As such, headcount is intended to provide the number of students per cipcode in the
final file. In the working file, the number of students in headcount in each of 2,792 cases is 1.

I reran the syntax using 'N' in lieu of 'SUM', and I received the following output:

AGGREGATE
     /OUTFILE = 'C:\Documents and Settings\boglesby\Desktop/test.sav'
     /BREAK = cipcode
     /crhrsqtr = SUM (crhrsqtr)
     /headcount = N (headcount).

>Error # 10934 in column 22.  Text: headcount
>The AGGREGATE command specifies an unknown existing variable name.
>This command not executed.

>Error # 10921 in column 31.  Text: )
>The number of existing variables does not match the number of new variables in
>a new variable definition on the AGGREGATE command.

What do you think?

Bill

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Richard Ristow
In reply to this post by Bill Oglesby
At 11:10 AM 10/10/2008, Bill Oglesby wrote:

>[In my file], each 'cipcode' is associated with X number of hours
>('crhrsqtr') and one person, so that another way of looking at this
>is that each person is associated with a code and a given number of
>hours. What I would like to do is sum both the number of hours and
>the number of people associated with each cipcode.

[...]

>
>AGGREGATE
>      /OUTFILE = 'C:\Documents and Settings\boglesby\Desktop/test.sav'
>      /BREAK = cipcode
>      /crhrsqtr = SUM (crhrsqtr)
>      /headcount = SUM (headcount).
>
>>Error # 10934 in column 24.  Text: headcount
>>The AGGREGATE command specifies an unknown existing variable name.
>>This command not executed.

So far, so simple. It means what it says: that there's no variable
named 'headcount' in your file, before the AGGREGATE.

 From your follow-up, it looks like you want 'headcount' to be the
count of records for each value of 'cipcode'. For that, you don't
need to specify a variable to the right of the '='. Try,

AGGREGATE
      /OUTFILE = 'C:\Documents and Settings\boglesby\Desktop/test.sav'
      /BREAK = cipcode
      /crhrsqtr = SUM (crhrsqtr)
      /headcount = N.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Bill Oglesby
In reply to this post by Bill Oglesby
Richard,

You nailed it in one try! The file that I was cross-referencing against my output didn't contain the
updated variable name. Hmmm...perhaps it's Friday? Thank you (and Melissa) for your assistance,

Bill

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Albert-Jan Roskam
In reply to this post by Bill Oglesby
Hi,

This is not legal code:
    /headcount = N (headcount).
it's either:
    /headcount = N .
or perhaps (if you only want to count non-missing records):
if (not missing(headcount)) n_headcount = 1.
...
    /n_headcount = sum (n_headcount).

Cheers!!
Albert-Jan



--- On Fri, 10/10/08, Bill Oglesby <[hidden email]> wrote:

> From: Bill Oglesby <[hidden email]>
> Subject: Re: Aggregate Syntax Errors
> To: [hidden email]
> Date: Friday, October 10, 2008, 5:38 PM
> Melissa,
>
> Thanks for taking a look. I must apologize for not being
> too clear, with respect to 'headcount'. The
> file that I am working with is duplicated by
> 'cipcode' (and not by 'ssn', which is my
> student
> identifier). As such, headcount is intended to provide the
> number of students per cipcode in the
> final file. In the working file, the number of students in
> headcount in each of 2,792 cases is 1.
>
> I reran the syntax using 'N' in lieu of
> 'SUM', and I received the following output:
>
> AGGREGATE
>      /OUTFILE = 'C:\Documents and
> Settings\boglesby\Desktop/test.sav'
>      /BREAK = cipcode
>      /crhrsqtr = SUM (crhrsqtr)
>      /headcount = N (headcount).
>
> >Error # 10934 in column 22.  Text: headcount
> >The AGGREGATE command specifies an unknown existing
> variable name.
> >This command not executed.
>
> >Error # 10921 in column 31.  Text: )
> >The number of existing variables does not match the
> number of new variables in
> >a new variable definition on the AGGREGATE command.
>
> What do you think?
>
> Bill
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body
> text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the
> command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Richard Ristow
At 03:57 AM 10/13/2008, Albert-jan Roskam wrote:

>This is not legal code:
>     /headcount = N (headcount).

Interestingly, it >is< legal code; the 'N' function does accept a
variable as argument. As far as I know, it doesn't do anything with
it. Though, as Bill Oglesby noted, it objects if the variable doesn't exist:
|-----------------------------|---------------------------|
|Output Created               |13-OCT-2008 23:36:15       |
|-----------------------------|---------------------------|
Category Sub Headcount

Alpha    A         3
Alpha    B         5
Beta     A         2
Beta     B         4
Beta     Y         6
Beta     Z         8

Number of cases read:  6    Number of cases listed:  6


AGGREGATE OUTFILE=*
    /BREAK=Category
    /headcount = N   (headcount)
    /Total     = SUM (headcount).

LIST.
List
|-----------------------------|---------------------------|
|Output Created               |13-OCT-2008 23:39:13       |
|-----------------------------|---------------------------|
Category headcount    Total

Alpha           2      8.00
Beta            4     20.00

Number of cases read:  2    Number of cases listed:  2
=============================
APPENDIX: Test data, and code
=============================
NEW FILE.
DATA LIST LIST
    /Category  Sub  Headcount
    (A8,       A2,  F4).
BEGIN DATA
     Alpha     A    3
     Alpha     B    5
     Beta      A    2
     Beta      B    4
     Beta      Y    6
     Beta      Z    8
END DATA.

LIST.

AGGREGATE OUTFILE=*
    /BREAK=Category
    /headcount = N   (headcount)
    /Total     = SUM (headcount).

LIST.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Aggregate Syntax Errors

Art Kendall
In reply to this post by Albert-Jan Roskam
Although the documentation in help does not say so the N function
appears to work the way it says in the version 9 Syntax Reference Guide.
keep in mind: The varlist has a 1:1 relation to the variables being
created and for this procedure
following a function with a period says to include user missing values
in the count.
Open a new instance of SPSS. Cut, paste, and run this syntax to see some
details.

data list list/ id(f2) a (f1) b(f1).
begin data
1 1 1
2 1 2
3 1 -1
4 1 .
5 2 1
6 2 2
7 2 2
end data.
missing values b(-1).
aggregate outfile=* /break = a
 / test1 = n
 / test2 = n(a)
 / test3 = n(b)
 / test4 = n.(b)
 / test5 = nmiss(b)
 / test6 = nmiss.(b)
 / test7 test8 = nmiss(a,b).
list.

Art Kendall
Social Research Consultants

Albert-jan Roskam wrote:

> Hi,
>
> This is not legal code:
>     /headcount = N (headcount).
> it's either:
>     /headcount = N .
> or perhaps (if you only want to count non-missing records):
> if (not missing(headcount)) n_headcount = 1.
> ...
>     /n_headcount = sum (n_headcount).
>
> Cheers!!
> Albert-Jan
>
>
>
> --- On Fri, 10/10/08, Bill Oglesby <[hidden email]> wrote:
>
>
>> From: Bill Oglesby <[hidden email]>
>> Subject: Re: Aggregate Syntax Errors
>> To: [hidden email]
>> Date: Friday, October 10, 2008, 5:38 PM
>> Melissa,
>>
>> Thanks for taking a look. I must apologize for not being
>> too clear, with respect to 'headcount'. The
>> file that I am working with is duplicated by
>> 'cipcode' (and not by 'ssn', which is my
>> student
>> identifier). As such, headcount is intended to provide the
>> number of students per cipcode in the
>> final file. In the working file, the number of students in
>> headcount in each of 2,792 cases is 1.
>>
>> I reran the syntax using 'N' in lieu of
>> 'SUM', and I received the following output:
>>
>> AGGREGATE
>>      /OUTFILE = 'C:\Documents and
>> Settings\boglesby\Desktop/test.sav'
>>      /BREAK = cipcode
>>      /crhrsqtr = SUM (crhrsqtr)
>>      /headcount = N (headcount).
>>
>>
>>> Error # 10934 in column 22.  Text: headcount
>>> The AGGREGATE command specifies an unknown existing
>>>
>> variable name.
>>
>>> This command not executed.
>>>
>>> Error # 10921 in column 31.  Text: )
>>> The number of existing variables does not match the
>>>
>> number of new variables in
>>
>>> a new variable definition on the AGGREGATE command.
>>>
>> What do you think?
>>
>> Bill
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>> [hidden email] (not to SPSSX-L), with no body
>> text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the
>> command
>> INFO REFCARD
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants