Table of means

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

Table of means

Marcos Sanches
Hi all,

Hope you can help me with a problem I am struggling with for a while. 

I have a questionnaire where the respondents are asked to evaluate the same attribute across several brands. The resulting data file has variables like this:

brand1_attrib1
brand1_attrib2
brand1_attrib3
brand1_attrib4
brand2_attrib1
brand2_attrib2
brand2_attrib3
brand2_attrib4
brand3_attrib1
brand3_attrib2
brand3_attrib3
brand3_attrib4

I need a simple table of means for these variables, but I wonder if it would be possible to have a table with Brands in the rows and attributes in the columns with the means in the cells.

Thanks a lot!

Marcos









Reply | Threaded
Open this post in threaded view
|

Re: Table of means

bruce phillips-2
If you have the CTABLES module you could use that.  A crude solution that I typically us is MEANS/TABLES=ATTRIB1 ATTRIB2 ATTRIB3 BY BRAND1 BRAND2 BRAND3/CELLS=MEAN. Then I paste it into EXCEL and move things around.  I'm sure someone on the list will come up with something more elegant, but you can try that if you are in a hurry.

Bruce Phillips
Hebrew Union College/University of Southern California, Los Angeles




----- Original Message -----
From: Marcos Sanches <[hidden email]>
Date: Monday, May 10, 2010 8:39 am
Subject: Table of means
To: [hidden email]

> Hi all,
>
> Hope you can help me with a problem I am struggling with for a while.
>
> I have a questionnaire where the respondents are asked to evaluate
> the same
> attribute across several brands. The resulting data file has
> variables like
> this:
>
> brand1_attrib1
> brand1_attrib2
> brand1_attrib3
> brand1_attrib4
> brand2_attrib1
> brand2_attrib2
> brand2_attrib3
> brand2_attrib4
> brand3_attrib1
> brand3_attrib2
> brand3_attrib3
> brand3_attrib4
>
> I need a simple table of means for these variables, but I wonder if
> it would
> be possible to have a table with Brands in the rows and attributes
> in the
> columns with the means in the cells.
>
> Thanks a lot!
>
> Marcos
>

=====================
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: Table of means

John Fiedler
In reply to this post by Marcos Sanches

Easiest way is to “stack” the data using the VARSTOCASES command.

Then your data file would look like this:

Brand attrib1 attrib2 attrib3 attrib4

 

Each respondent would have as many records as he/she rated brands.

 

Then you get your table with

MEANS attrib1 TO attrib4 BY brand.

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marcos Sanches
Sent: Monday, May 10, 2010 9:37 AM
To: [hidden email]
Subject: Table of means

 

Hi all,

 

Hope you can help me with a problem I am struggling with for a while. 

 

I have a questionnaire where the respondents are asked to evaluate the same attribute across several brands. The resulting data file has variables like this:

 

brand1_attrib1

brand1_attrib2

brand1_attrib3

brand1_attrib4

brand2_attrib1

brand2_attrib2

brand2_attrib3

brand2_attrib4

brand3_attrib1

brand3_attrib2

brand3_attrib3

brand3_attrib4

 

I need a simple table of means for these variables, but I wonder if it would be possible to have a table with Brands in the rows and attributes in the columns with the means in the cells.

 

Thanks a lot!

 

Marcos

 

 

 

 

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Table of means

Maguin, Eugene
In reply to this post by Marcos Sanches
Marcos,

I'm going to assume that your data is in wide format (one row per person)
rather than long format (12 rows per person). It sounds like the resulting
table should look like

           Attrib 1     Attrib 2     Attrib 3     Attrib 4
Brand 1    (mean)
Brand 2
Brand 3

You can do this with the Means command if you restructure your file from
wide to long. The problem is that the variable order in the file needs to be
different. To fix this problem, you need to save file with the required
order specified on the keep subcommand and then reopen that file (OR,
manually reorder the columns in the data editor). However, it gets done the
order needs to be

brand1_attrib1
brand2_attrib1
brand3_attrib1
brand1_attrib2
brand2_attrib2
brand3_attrib2
brand1_attrib3
brand2_attrib3
brand3_attrib3
brand1_attrib4
brand2_attrib4
brand3_attrib4

Then do a varstocases.

Vartocases /make attrib1 from brand1_attrib1 to brand3_attrib1/
   make attrib2 from brand1_attrib2 to brand3_attrib2/
   make attrib3 from brand1_attrib3 to brand3_attrib3/
   make attrib4 from brand1_attrib4 to brand3_attrib4/index=brand.

With that done you use the following means command.

Means attrib1 attrib2 attrib3 attrib4 by brand/cells=count mean stddev.

I haven't tested this but, of course, I will respond to problems you have.

Another alternative may be Ctables (complex tables); howerver, I don't have
enough experience to know whether you can use Ctables without restructuring
the dataset. If others know how, I also would be interested see how to do
it.

Gene Maguin


>>I have a questionnaire where the respondents are asked to evaluate the
same attribute across several brands. The resulting data file has variables
like this:

brand1_attrib1
brand1_attrib2
brand1_attrib3
brand1_attrib4
brand2_attrib1
brand2_attrib2
brand2_attrib3
brand2_attrib4
brand3_attrib1
brand3_attrib2
brand3_attrib3
brand3_attrib4

I need a simple table of means for these variables, but I wonder if it would
be possible to have a table with Brands in the rows and attributes in the
columns with the means in the cells.

Thanks a lot!

Marcos

=====================
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: Table of means

Mike
In reply to this post by Marcos Sanches
One way of achieving what you want is to use Aggregate to
create files for each brand with the means for the attributes
and then combining the files.  Consider:

compute B1=1.
Aggregate outfile="C:\brand001.sav"/
  brand=mean(B1)/
  attribute01=mean(brand1_attrib1)/
  attribute02=mean(brand1_attrib2)/
  attribute03=mean(brand1_attrib3)/
  attribute04=mean(brand1_attrib4).

compute B2=2.
Aggregate outfile="C:\brand002.sav"/
  brand=mean(B2)/
  attribute01=mean(brand2_attrib1)/
  attribute02=mean(brand2_attrib2)/
  attribute03=mean(brand2_attrib3)/
  attribute04=mean(brand2_attrib4).


compute B3=3.
Aggregate outfile="C:\brand003.sav"/
  brand=mean(B3)/
  attribute01=mean(brand3_attrib1)/
  attribute02=mean(brand3_attrib2)/
  attribute03=mean(brand3_attrib3)/
  attribute04=mean(brand3_attrib4).

compute B4=4.
Aggregate outfile="C:\brand004.sav"/
  brand=mean(B4)/
  attribute01=mean(brand4_attrib1)/
  attribute02=mean(brand4_attrib2)/
  attribute03=mean(brand4_attrib3)/
  attribute04=mean(brand4_attrib4).

add files file="C:\brand001.sav"/
  file="C:\brand002.sav"/
  file="C:\brand003.sav"/
  file="C:\brand004.sav".

list.

I haven't tried the above syntax, so I can't say if it will work.
Also, you might want to add specifications to the procedures
to get additional info.

-Mike Palij
New York University
[hidden email]


----- Original Message -----
From: Marcos Sanches
To: [hidden email]
Sent: Monday, May 10, 2010 11:37 AM
Subject: Table of means

>
>Hi all,
>
>Hope you can help me with a problem I am struggling with for a while.
>
>I have a questionnaire where the respondents are asked to evaluate the
>same attribute across several brands. The resulting data file has variables
>like this:
>
>brand1_attrib1
>brand1_attrib2
>brand1_attrib3
>brand1_attrib4
>brand2_attrib1
>brand2_attrib2
>brand2_attrib3
>brand2_attrib4
>brand3_attrib1
>brand3_attrib2
>brand3_attrib3
>brand3_attrib4
>
>I need a simple table of means for these variables, but I wonder
>if it would be possible to have a table with Brands in the rows and
>attributes in the columns with the means in the cells.
>
>Thanks a lot!
>
>Marcos

=====================
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: Table of means

Bruce Weaver
Administrator
In reply to this post by Maguin, Eugene
Gene Maguin wrote
Marcos,

I'm going to assume that your data is in wide format (one row per person)
rather than long format (12 rows per person). It sounds like the resulting
table should look like

           Attrib 1     Attrib 2     Attrib 3     Attrib 4
Brand 1    (mean)
Brand 2
Brand 3

You can do this with the Means command if you restructure your file from
wide to long. The problem is that the variable order in the file needs to be
different. To fix this problem, you need to save file with the required
order specified on the keep subcommand and then reopen that file (OR,
manually reorder the columns in the data editor). However, it gets done the
order needs to be

brand1_attrib1
brand2_attrib1
brand3_attrib1
brand1_attrib2
brand2_attrib2
brand3_attrib2
brand1_attrib3
brand2_attrib3
brand3_attrib3
brand1_attrib4
brand2_attrib4
brand3_attrib4

Then do a varstocases.

Vartocases /make attrib1 from brand1_attrib1 to brand3_attrib1/
   make attrib2 from brand1_attrib2 to brand3_attrib2/
   make attrib3 from brand1_attrib3 to brand3_attrib3/
   make attrib4 from brand1_attrib4 to brand3_attrib4/index=brand.

With that done you use the following means command.

Means attrib1 attrib2 attrib3 attrib4 by brand/cells=count mean stddev.

I haven't tested this but, of course, I will respond to problems you have.

Another alternative may be Ctables (complex tables); howerver, I don't have
enough experience to know whether you can use Ctables without restructuring
the dataset. If others know how, I also would be interested see how to do
it.

Gene Maguin
Hi Gene.  Although it may be convenient to re-order the variables in some cases*, I don't think it's necessary to do so.  E.g., I think the following will work without re-ordering the variables:

Vartocases /
   make attrib1 from brand1_attrib1 brand2_attrib1 brand3_attrib1/
   make attrib2 from brand1_attrib2 brand2_attrib2 brand3_attrib2/
   make attrib3 from brand1_attrib3 brand2_attrib3 brand3_attrib3/
   make attrib4 from brand1_attrib4 brand2_attrib4 brand3_attrib4/
   index=brand.

* Obviously, if each MAKE sub-command was going to have a very long variable list, re-ordering the variables to make the "var1 TO varX" approach possible would be eminently sensible.

Cheers,
Bruce
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: Table of means

Maguin, Eugene
Bruce,

Thanks for your posting. I had always understood the make subcommand to
require a 'to' in the from list (e.g., /make vx from v1 to v4), which also
requires that the variables be in sequential order for the index to make
sense. Thus the statement about save and keep. After seeing your example
syntax, I looked at the documentation and yeah, I don't need the 'to'.
Always good to learn something.

Gene Maguin

=====================
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: Table of means

David Marso
Administrator
In reply to this post by Marcos Sanches
COMPUTE SubID=$CASENUM.
VECTOR V=Brand1_Attrib1 TO Brand3_Attrib4.
LOOP Brand=1 to 3.
+    DO REPEAT A=1 TO 4 /NewA=Attrib1 TO Attrib4.
+        COMPUTE NEWA=V((B-1)*4 + A).
+    END REPEAT.
+   XSAVE OUTFILE "Restructured.sav" / KEEP SubID Brand Attrib1 TO Attrib4
END LOOP.
EXE.
GET FILE  "Restructured.sav" .
Then your TABLE or MEANS command as previous ;-)
I just couldn't resist the OLD SKOOL intrusion here !!!!
We don't needs to spell out any stinking variable names ;-)
Name that movie.....

=====================
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
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: Table of means

Richard Ristow
At 06:32 AM 5/11/2010, David Marso wrote:

COMPUTE SubID=$CASENUM.
VECTOR V=Brand1_Attrib1 TO Brand3_Attrib4.
LOOP Brand=1 to 3.
+    DO REPEAT A=1 TO 4 /NewA=Attrib1 TO Attrib4.
+        COMPUTE NEWA=V((B-1)*4 + A).
+    END REPEAT.
+    XSAVE OUTFILE "Restructured.sav"
         /KEEP SubID Brand Attrib1 TO Attrib4
END LOOP.
EXE.
GET FILE  "Restructured.sav" .
Then your TABLE or MEANS command as previous ;-)
I just couldn't resist the OLD SKOOL intrusion here !!!!
We don't needs to spell out any stinking variable names ;-)

Good old XSAVE. I reluctantly converted to VARSTOCASES myself, but yes, XSAVE can do marvelous things including, as you say, not need as many variable names written explicitly.

The many-to-many merge algorithm for which I claim joint credit with you, David, takes advantage of just this feature of XSAVE. In the process, neatly solving a problem that's been around the list, off and on, for years.
===================== 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: Table of means

Bruce Weaver
Administrator
In reply to this post by David Marso
David Marso wrote
COMPUTE SubID=$CASENUM.
VECTOR V=Brand1_Attrib1 TO Brand3_Attrib4.
LOOP Brand=1 to 3.
+    DO REPEAT A=1 TO 4 /NewA=Attrib1 TO Attrib4.
+        COMPUTE NEWA=V((B-1)*4 + A).
+    END REPEAT.
+   XSAVE OUTFILE "Restructured.sav" / KEEP SubID Brand Attrib1 TO Attrib4
END LOOP.
EXE.
GET FILE  "Restructured.sav" .
Then your TABLE or MEANS command as previous ;-)
I just couldn't resist the OLD SKOOL intrusion here !!!!
We don't needs to spell out any stinking variable names ;-)
Name that movie.....

"The Treasure of the Sierra Madre", apparently.  ;-)

    http://www.maniacworld.com/we-dont-need-no-stinking-badges.html

--
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/).