how to compute mean of one variable

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

how to compute mean of one variable

LUCINDA M TEAR
Hello,

I am sorry to bother you all with such a simple question, but I do not seem to be able to understand from documentation how to compute the mean of a variable so that it becomes available to me as a constant.  

I would like to be able to compute x = mean(variable y) but do not seem to be able to figure out how to loop through the cases of a variable to either sum or average or count them.  It seems that arithmetic functions apply only across variables within a case.  I have tried to use the aggregate function, but since I want the mean of an entire variable (not by any break variable), the command won't process.  From what I can tell, the index for vectors refers to an entire vector and not to a case within a vector.

I am sure that this is very simple and I really apologize for being so unable to crack the documentation about it.  It probably requires a macro and I am still struggling with these...

Thank you for any pointers (even to previous list answers.).

Lucinda Tear
Reply | Threaded
Open this post in threaded view
|

Re: how to compute mean of one variable

Beadle, ViAnn
Use AGGREGATE to do this. Since AGGREGATE expects a break variable, create a constant variable and break on that.
1. First compute your constant variable with:

COMPUTE constant=1.

Then go to Data>Aggregate.

Add the constant as your break variable and y as your aggregated variable. Make sure to check the third radio button in the Save group box. Paste or run the syntax which will look like this:

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=constant
  /y_mean=MEAN(y).

The MODE=ADDVARIABLES keyword is the critical thing that adds that mean back as a new variable to the active file.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of LUCINDA M TEAR
Sent: Friday, May 11, 2007 7:19 PM
To: [hidden email]
Subject: how to compute mean of one variable

Hello,

I am sorry to bother you all with such a simple question, but I do not seem to be able to understand from documentation how to compute the mean of a variable so that it becomes available to me as a constant.

I would like to be able to compute x = mean(variable y) but do not seem to be able to figure out how to loop through the cases of a variable to either sum or average or count them.  It seems that arithmetic functions apply only across variables within a case.  I have tried to use the aggregate function, but since I want the mean of an entire variable (not by any break variable), the command won't process.  From what I can tell, the index for vectors refers to an entire vector and not to a case within a vector.

I am sure that this is very simple and I really apologize for being so unable to crack the documentation about it.  It probably requires a macro and I am still struggling with these...

Thank you for any pointers (even to previous list answers.).

Lucinda Tear
Reply | Threaded
Open this post in threaded view
|

Re: how to compute mean of one variable

Albert-Jan Roskam
Wow, is the MODE=ADDVARIABLES new? I've been using v11
for a long time, but recently we upgraded to v14. I
never knew about this feature. VERY HANDY!

More generally, is there a "What's knew" document for
each new release of SPSS?

Albert-Jan


--- "Beadle, ViAnn" <[hidden email]> wrote:

> Use AGGREGATE to do this. Since AGGREGATE expects a
> break variable, create a constant variable and break
> on that.
> 1. First compute your constant variable with:
>
> COMPUTE constant=1.
>
> Then go to Data>Aggregate.
>
> Add the constant as your break variable and y as
> your aggregated variable. Make sure to check the
> third radio button in the Save group box. Paste or
> run the syntax which will look like this:
>
> AGGREGATE
>   /OUTFILE=* MODE=ADDVARIABLES
>   /BREAK=constant
>   /y_mean=MEAN(y).
>
> The MODE=ADDVARIABLES keyword is the critical thing
> that adds that mean back as a new variable to the
> active file.
>
> -----Original Message-----
> From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of
> LUCINDA M TEAR
> Sent: Friday, May 11, 2007 7:19 PM
> To: [hidden email]
> Subject: how to compute mean of one variable
>
> Hello,
>
> I am sorry to bother you all with such a simple
> question, but I do not seem to be able to understand
> from documentation how to compute the mean of a
> variable so that it becomes available to me as a
> constant.
>
> I would like to be able to compute x = mean(variable
> y) but do not seem to be able to figure out how to
> loop through the cases of a variable to either sum
> or average or count them.  It seems that arithmetic
> functions apply only across variables within a case.
>  I have tried to use the aggregate function, but
> since I want the mean of an entire variable (not by
> any break variable), the command won't process.
> From what I can tell, the index for vectors refers
> to an entire vector and not to a case within a
> vector.
>
> I am sure that this is very simple and I really
> apologize for being so unable to crack the
> documentation about it.  It probably requires a
> macro and I am still struggling with these...
>
> Thank you for any pointers (even to previous list
> answers.).
>
> Lucinda Tear
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



____________________________________________________________________________________Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
Reply | Threaded
Open this post in threaded view
|

Re: how to compute mean of one variable

Beadle, ViAnn
Search for What's New in Help--You'll find a topic for every release going back about release 7.

-----Original Message-----
From: Albert-jan Roskam [mailto:[hidden email]]
Sent: Saturday, May 12, 2007 5:14 AM
To: Beadle, ViAnn; [hidden email]
Subject: Re: how to compute mean of one variable

Wow, is the MODE=ADDVARIABLES new? I've been using v11
for a long time, but recently we upgraded to v14. I
never knew about this feature. VERY HANDY!

More generally, is there a "What's knew" document for
each new release of SPSS?

Albert-Jan


--- "Beadle, ViAnn" <[hidden email]> wrote:

> Use AGGREGATE to do this. Since AGGREGATE expects a
> break variable, create a constant variable and break
> on that.
> 1. First compute your constant variable with:
>
> COMPUTE constant=1.
>
> Then go to Data>Aggregate.
>
> Add the constant as your break variable and y as
> your aggregated variable. Make sure to check the
> third radio button in the Save group box. Paste or
> run the syntax which will look like this:
>
> AGGREGATE
>   /OUTFILE=* MODE=ADDVARIABLES
>   /BREAK=constant
>   /y_mean=MEAN(y).
>
> The MODE=ADDVARIABLES keyword is the critical thing
> that adds that mean back as a new variable to the
> active file.
>
> -----Original Message-----
> From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of
> LUCINDA M TEAR
> Sent: Friday, May 11, 2007 7:19 PM
> To: [hidden email]
> Subject: how to compute mean of one variable
>
> Hello,
>
> I am sorry to bother you all with such a simple
> question, but I do not seem to be able to understand
> from documentation how to compute the mean of a
> variable so that it becomes available to me as a
> constant.
>
> I would like to be able to compute x = mean(variable
> y) but do not seem to be able to figure out how to
> loop through the cases of a variable to either sum
> or average or count them.  It seems that arithmetic
> functions apply only across variables within a case.
>  I have tried to use the aggregate function, but
> since I want the mean of an entire variable (not by
> any break variable), the command won't process.
> From what I can tell, the index for vectors refers
> to an entire vector and not to a case within a
> vector.
>
> I am sure that this is very simple and I really
> apologize for being so unable to crack the
> documentation about it.  It probably requires a
> macro and I am still struggling with these...
>
> Thank you for any pointers (even to previous list
> answers.).
>
> Lucinda Tear
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



____________________________________________________________________________________Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
Reply | Threaded
Open this post in threaded view
|

When it happened (was, re: how to compute mean of one variable)

Richard Ristow
At 09:01 AM 5/12/2007, Beadle, ViAnn wrote:

>Search for What's New in Help--You'll find a topic for every release
>going back about release 7.

Thanks. Hadn't realized that whole list was there. Comes of being too
wedded to syntax. As for not knowing when things happened, I went
direct from 9 to 14, which bypasses a lot of history. So I had a stroll
through the updates, and collected these, on the data-management side:

Virtual Active File, and CACHE: 10.0.

AGGREGATE /MEDIAN function:     11.0  (earlier than I'd thought)
CASESTOVARS and VARSTOCASES:    11.0  (a good release for
data-handlers)_

AGGREGATE MODE=ADDVARIABLES:    13.0.
Reply | Threaded
Open this post in threaded view
|

Re: When it happened (was, re: how to compute mean of one variable)

Oliver, Richard
FWIW, starting with release 16, the documentation for every command that has had any changes since release 12 will have a release history (this includes new commands added since then). There will also be a summary release history in the introductory section of the Command Syntax Reference.

________________________________

From: SPSSX(r) Discussion on behalf of Richard Ristow
Sent: Sat 5/12/2007 1:46 PM
To: [hidden email]
Subject: When it happened (was, re: how to compute mean of one variable)



At 09:01 AM 5/12/2007, Beadle, ViAnn wrote:

>Search for What's New in Help--You'll find a topic for every release
>going back about release 7.

Thanks. Hadn't realized that whole list was there. Comes of being too
wedded to syntax. As for not knowing when things happened, I went
direct from 9 to 14, which bypasses a lot of history. So I had a stroll
through the updates, and collected these, on the data-management side:

Virtual Active File, and CACHE: 10.0.

AGGREGATE /MEDIAN function:     11.0  (earlier than I'd thought)
CASESTOVARS and VARSTOCASES:    11.0  (a good release for
data-handlers)_

AGGREGATE MODE=ADDVARIABLES:    13.0.
Reply | Threaded
Open this post in threaded view
|

Re: When it happened (was, re: how to compute mean of one variable)

Richard Ristow
At 07:05 PM 5/12/2007, Oliver, Richard wrote:

>FWIW, starting with release 16, the documentation for every command
>that has had any changes since release 12 will have a release history
>(this includes new commands added since then). There will also be a
>summary release history in the introductory section of the Command
>Syntax Reference.

FWIW? It's worth a heck of a lot!

Excellent practice, very useful, and I know it was a good deal of work
for somebody, to put it together.

-Thanks and congratulations,
  Richard
Reply | Threaded
Open this post in threaded view
|

Re: When it happened (was, re: how to compute mean of one variable)

Art Kendall
Great idea!

Thanks.

Art Kendall
Social Research Consultants

Richard Ristow wrote:

> At 07:05 PM 5/12/2007, Oliver, Richard wrote:
>
>> FWIW, starting with release 16, the documentation for every command
>> that has had any changes since release 12 will have a release history
>> (this includes new commands added since then). There will also be a
>> summary release history in the introductory section of the Command
>> Syntax Reference.
>
> FWIW? It's worth a heck of a lot!
>
> Excellent practice, very useful, and I know it was a good deal of work
> for somebody, to put it together.
>
> -Thanks and congratulations,
>  Richard
>
>
Art Kendall
Social Research Consultants