Averaging and Computing Variables Based on Conditions

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

Averaging and Computing Variables Based on Conditions

Zachrey Santangelo
Hi all...I apologize if this was sent once before.  I think I sent it out before I subscribed.  Hopefully this email goes out.  

I have a dataset that looks something like this...

Code     q1      q2     ReadingScore

12345    1        0           521
12345    1        1           530
5421      1        1           651
5421      0        0           402

My goal is to average the ReadingScore based on the questions and Code.  So I want all of the people who answered 1 (Yes) from Code 12345 to have their ReadingScores averaged together and created into a new variable.  I would also like to have all of the people who answered No (0) from 5421 to have their ReadingScore's averaged together and have that created into a new variable.   Etc...

Is this possible?  I would appreciate any help...or just putting me down the right path.  
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Averaging and Computing Variables Based on Conditions

Kim Jinnett-2
I'm currently traveling on business and will return to the office on Tuesday, June 18th.  If you need to reach someone sooner please contact Janice Pearcy at [hidden email].

Thank you,
Kim Jinnett
Reply | Threaded
Open this post in threaded view
|

Re: Averaging and Computing Variables Based on Conditions

Maguin, Eugene
In reply to this post by Zachrey Santangelo

I think that you will want to  use Aggregate with the break variables being code and q1 (Is it q1, q2 or both q1 and q2? You don’t specify). I’m guessing you want to create a new data set with variables of code q1 and average reading score. But, if you want to add the new variable to the existing dataset use the mode=addvariables subcommand.

Gene Maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zachrey Santangelo
Sent: Monday, June 10, 2013 12:07 PM
To: [hidden email]
Subject: Averaging and Computing Variables Based on Conditions

 

Hi all...I apologize if this was sent once before.  I think I sent it out before I subscribed.  Hopefully this email goes out.  

 

I have a dataset that looks something like this...

 

Code     q1      q2     ReadingScore

 

12345    1        0           521

12345    1        1           530

5421      1        1           651

5421      0        0           402

 

My goal is to average the ReadingScore based on the questions and Code.  So I want all of the people who answered 1 (Yes) from Code 12345 to have their ReadingScores averaged together and created into a new variable.  I would also like to have all of the people who answered No (0) from 5421 to have their ReadingScore's averaged together and have that created into a new variable.   Etc...

 

Is this possible?  I would appreciate any help...or just putting me down the right path.  

Reply | Threaded
Open this post in threaded view
|

Re: Averaging and Computing Variables Based on Conditions

Zachrey Santangelo
Thank you for the response Gene.  It is q1, q2.  I did not want to combine them.  Sorry about not specifying.  

So this...?

AGGREGATE
/outfile = * Mode=addvariables
/break = Code q1
/RdgScoreMean = MEAN(ReadingScore).

I am guessing I need to redo this statement for q2.  

So this gives me two scores under RdgScoreMean.  One for Yes and one for No to q1.  Is there any way to break that up?  Have one column for Yes to Q1 and one for No to Q1?  


On Mon, Jun 10, 2013 at 1:19 PM, Maguin, Eugene <[hidden email]> wrote:

I think that you will want to  use Aggregate with the break variables being code and q1 (Is it q1, q2 or both q1 and q2? You don’t specify). I’m guessing you want to create a new data set with variables of code q1 and average reading score. But, if you want to add the new variable to the existing dataset use the mode=addvariables subcommand.

Gene Maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zachrey Santangelo
Sent: Monday, June 10, 2013 12:07 PM


To: [hidden email]
Subject: Averaging and Computing Variables Based on Conditions

 

Hi all...I apologize if this was sent once before.  I think I sent it out before I subscribed.  Hopefully this email goes out.  

 

I have a dataset that looks something like this...

 

Code     q1      q2     ReadingScore

 

12345    1        0           521

12345    1        1           530

5421      1        1           651

5421      0        0           402

 

My goal is to average the ReadingScore based on the questions and Code.  So I want all of the people who answered 1 (Yes) from Code 12345 to have their ReadingScores averaged together and created into a new variable.  I would also like to have all of the people who answered No (0) from 5421 to have their ReadingScore's averaged together and have that created into a new variable.   Etc...

 

Is this possible?  I would appreciate any help...or just putting me down the right path.  


Reply | Threaded
Open this post in threaded view
|

Re: Averaging and Computing Variables Based on Conditions

John F Hall
In reply to this post by Zachrey Santangelo
Gene's solution may save the averages as a new variable, but my way gives
you a chance to eyeball the data first.  Curiosity alone would draw me to
investigate the combinations as well.

From: Zachrey Santangelo [mailto:[hidden email]]
Sent: 10 June 2013 20:09
To: John F Hall
Cc: Bruce Weaver
Subject: Re: Averaging and Computing Variables Based on Conditions

Hi John,

Thank you for the quick reply.  I only have around 40 codes, so the first
option is definitely viable.

In the second option am I not combining q1 and q2?  I was trying to keep q1
and q2 separate.  Sorry I did not specify that in my initial question.

On Mon, Jun 10, 2013 at 12:42 PM, John F Hall <[hidden email]> wrote:
Quick reaction is (in syntax):

File > new > syntax, then type in:

means Readingscore by code by q1 q2.

. . and run the job.

Hope you haven't got thousands of codes!

You could also try:

compute comb = q1 * 10 + q2.
format q1q2 (n2).
means Readingscore by code by comb.


John F Hall (Mr)
[Retired academic survey researcher]

Email:   [hidden email]
Website: www.surveyresearch.weebly.com
SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html








From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Zachrey Santangelo
Sent: 10 June 2013 18:07
To: [hidden email]
Subject: Averaging and Computing Variables Based on Conditions

Hi all...I apologize if this was sent once before.  I think I sent it out
before I subscribed.  Hopefully this email goes out.

I have a dataset that looks something like this...

Code     q1      q2     ReadingScore

12345    1        0           521
12345    1        1           530
5421      1        1           651
5421      0        0           402

My goal is to average the ReadingScore based on the questions and Code.  So
I want all of the people who answered 1 (Yes) from Code 12345 to have their
ReadingScores averaged together and created into a new variable.  I would
also like to have all of the people who answered No (0) from 5421 to have
their ReadingScore's averaged together and have that created into a new
variable.   Etc...

Is this possible?  I would appreciate any help...or just putting me down the
right path.

=====================
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: Averaging and Computing Variables Based on Conditions

David Marso
Administrator
In reply to this post by Zachrey Santangelo
"Is there any way to break that up?  Have one column for Yes to Q1 and one for No to Q1?  "
Follow the AGGREGATE(s) with a CASESTOVARS.
OTOH:  If you are simply after the MEANS you might want to drop the MODE=ADDVARIABLES from the AGGREGATE commands.  When you combine aggregated data into a RAW file you end up with a mix of information at different levels of observation.  I will stop now because we have NO idea what you need to do with the summary data.
Zachrey Santangelo wrote
Thank you for the response Gene.  It is q1, q2.  I did not want to combine
them.  Sorry about not specifying.

So this...?

AGGREGATE
/outfile = * Mode=addvariables
/break = Code q1
/RdgScoreMean = MEAN(ReadingScore).

I am guessing I need to redo this statement for q2.

So this gives me two scores under RdgScoreMean.  One for Yes and one for No
to q1.  Is there any way to break that up?  Have one column for Yes to Q1
and one for No to Q1?


On Mon, Jun 10, 2013 at 1:19 PM, Maguin, Eugene <[hidden email]> wrote:

> I think that you will want to  use Aggregate with the break variables
> being code and q1 (Is it q1, q2 or both q1 and q2? You don’t specify). I’m
> guessing you want to create a new data set with variables of code q1 and
> average reading score. But, if you want to add the new variable to the
> existing dataset use the mode=addvariables subcommand. ****
>
> Gene Maguin****
>
> ** **
>
> *From:* SPSSX(r) Discussion [mailto:[hidden email]] *On Behalf
> Of *Zachrey Santangelo
> *Sent:* Monday, June 10, 2013 12:07 PM
>
> *To:* [hidden email]
> *Subject:* Averaging and Computing Variables Based on Conditions****
>
> ** **
>
> Hi all...I apologize if this was sent once before.  I think I sent it out
> before I subscribed.  Hopefully this email goes out.  ****
>
> ** **
>
> I have a dataset that looks something like this...****
>
> ** **
>
> Code     q1      q2     ReadingScore****
>
> ** **
>
> 12345    1        0           521****
>
> 12345    1        1           530****
>
> 5421      1        1           651****
>
> 5421      0        0           402****
>
> ** **
>
> My goal is to average the ReadingScore based on the questions and Code.
>  So I want all of the people who answered 1 (Yes) from Code 12345 to have
> their ReadingScores averaged together and created into a new variable.  I
> would also like to have all of the people who answered No (0) from 5421 to
> have their ReadingScore's averaged together and have that created into a
> new variable.   Etc...****
>
> ** **
>
> Is this possible?  I would appreciate any help...or just putting me down
> the right path.  ****
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Averaging and Computing Variables Based on Conditions

Zachrey Santangelo
I just wanted to report the Reading Score Averages for people that answered Yes to q1 and the Reading Score averages for people that responded no to question 1.  

Same thing with question 2.  

Also wanted them grouped by Code.  


On Mon, Jun 10, 2013 at 3:53 PM, David Marso <[hidden email]> wrote:
"Is there any way to break that up?  Have one column for Yes to Q1 and one
for No to Q1?  "
Follow the AGGREGATE(s) with a CASESTOVARS.
OTOH:  If you are simply after the MEANS you might want to drop the
MODE=ADDVARIABLES from the AGGREGATE commands.  When you combine aggregated
data into a RAW file you end up with a mix of information at different
levels of observation.  I will stop now because we have NO idea what you
need to do with the summary data.

Zachrey Santangelo wrote
> Thank you for the response Gene.  It is q1, q2.  I did not want to combine
> them.  Sorry about not specifying.
>
> So this...?
>
> AGGREGATE
> /outfile = * Mode=addvariables
> /break = Code q1
> /RdgScoreMean = MEAN(ReadingScore).
>
> I am guessing I need to redo this statement for q2.
>
> So this gives me two scores under RdgScoreMean.  One for Yes and one for
> No
> to q1.  Is there any way to break that up?  Have one column for Yes to Q1
> and one for No to Q1?
>
>
> On Mon, Jun 10, 2013 at 1:19 PM, Maguin, Eugene &lt;

> emaguin@

> &gt; wrote:
>
>> I think that you will want to  use Aggregate with the break variables
>> being code and q1 (Is it q1, q2 or both q1 and q2? You don’t specify).
>> I’m
>> guessing you want to create a new data set with variables of code q1 and
>> average reading score. But, if you want to add the new variable to the
>> existing dataset use the mode=addvariables subcommand. ****
>>
>> Gene Maguin****
>>
>> ** **
>>
>> *From:* SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] *On Behalf
>> Of *Zachrey Santangelo
>> *Sent:* Monday, June 10, 2013 12:07 PM
>>
>> *To:*

> SPSSX-L@.UGA

>> *Subject:* Averaging and Computing Variables Based on Conditions****
>>
>> ** **
>>
>> Hi all...I apologize if this was sent once before.  I think I sent it out
>> before I subscribed.  Hopefully this email goes out.  ****
>>
>> ** **
>>
>> I have a dataset that looks something like this...****
>>
>> ** **
>>
>> Code     q1      q2     ReadingScore****
>>
>> ** **
>>
>> 12345    1        0           521****
>>
>> 12345    1        1           530****
>>
>> 5421      1        1           651****
>>
>> 5421      0        0           402****
>>
>> ** **
>>
>> My goal is to average the ReadingScore based on the questions and Code.
>>  So I want all of the people who answered 1 (Yes) from Code 12345 to have
>> their ReadingScores averaged together and created into a new variable.  I
>> would also like to have all of the people who answered No (0) from 5421
>> to
>> have their ReadingScore's averaged together and have that created into a
>> new variable.   Etc...****
>>
>> ** **
>>
>> Is this possible?  I would appreciate any help...or just putting me down
>> the right path.  ****
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Averaging-and-Computing-Variables-Based-on-Conditions-tp5720647p5720657.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Averaging and Computing Variables Based on Conditions

Bruce Weaver
Administrator
If all you want to do is report results (i.e., there are no further computations involving those means), then go with John's one-liner:

MEANS Readingscore BY code BY q1 q2.


Zachrey Santangelo wrote
I just wanted to report the Reading Score Averages for people that answered
Yes to q1 and the Reading Score averages for people that responded no to
question 1.

Same thing with question 2.

Also wanted them grouped by Code.


On Mon, Jun 10, 2013 at 3:53 PM, David Marso <[hidden email]> wrote:

> "Is there any way to break that up?  Have one column for Yes to Q1 and one
> for No to Q1?  "
> Follow the AGGREGATE(s) with a CASESTOVARS.
> OTOH:  If you are simply after the MEANS you might want to drop the
> MODE=ADDVARIABLES from the AGGREGATE commands.  When you combine aggregated
> data into a RAW file you end up with a mix of information at different
> levels of observation.  I will stop now because we have NO idea what you
> need to do with the summary data.
>
> Zachrey Santangelo wrote
> > Thank you for the response Gene.  It is q1, q2.  I did not want to
> combine
> > them.  Sorry about not specifying.
> >
> > So this...?
> >
> > AGGREGATE
> > /outfile = * Mode=addvariables
> > /break = Code q1
> > /RdgScoreMean = MEAN(ReadingScore).
> >
> > I am guessing I need to redo this statement for q2.
> >
> > So this gives me two scores under RdgScoreMean.  One for Yes and one for
> > No
> > to q1.  Is there any way to break that up?  Have one column for Yes to Q1
> > and one for No to Q1?
> >
> >
> > On Mon, Jun 10, 2013 at 1:19 PM, Maguin, Eugene <
>
> > emaguin@
>
> > > wrote:
> >
> >> I think that you will want to  use Aggregate with the break variables
> >> being code and q1 (Is it q1, q2 or both q1 and q2? You don’t specify).
> >> I’m
> >> guessing you want to create a new data set with variables of code q1 and
> >> average reading score. But, if you want to add the new variable to the
> >> existing dataset use the mode=addvariables subcommand. ****
> >>
> >> Gene Maguin****
> >>
> >> ** **
> >>
> >> *From:* SPSSX(r) Discussion [mailto:
>
> > SPSSX-L@.UGA
>
> > ] *On Behalf
> >> Of *Zachrey Santangelo
> >> *Sent:* Monday, June 10, 2013 12:07 PM
> >>
> >> *To:*
>
> > SPSSX-L@.UGA
>
> >> *Subject:* Averaging and Computing Variables Based on Conditions****
> >>
> >> ** **
> >>
> >> Hi all...I apologize if this was sent once before.  I think I sent it
> out
> >> before I subscribed.  Hopefully this email goes out.  ****
> >>
> >> ** **
> >>
> >> I have a dataset that looks something like this...****
> >>
> >> ** **
> >>
> >> Code     q1      q2     ReadingScore****
> >>
> >> ** **
> >>
> >> 12345    1        0           521****
> >>
> >> 12345    1        1           530****
> >>
> >> 5421      1        1           651****
> >>
> >> 5421      0        0           402****
> >>
> >> ** **
> >>
> >> My goal is to average the ReadingScore based on the questions and Code.
> >>  So I want all of the people who answered 1 (Yes) from Code 12345 to
> have
> >> their ReadingScores averaged together and created into a new variable.
>  I
> >> would also like to have all of the people who answered No (0) from 5421
> >> to
> >> have their ReadingScore's averaged together and have that created into a
> >> new variable.   Etc...****
> >>
> >> ** **
> >>
> >> Is this possible?  I would appreciate any help...or just putting me down
> >> the right path.  ****
> >>
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Averaging-and-Computing-Variables-Based-on-Conditions-tp5720647p5720657.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).