aggregate

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

aggregate

Yawen LI
hi, all,

It seems that Aggregate function in spss does not support aggregating
on mode (instead of mean or median). how can i do that using other
methods?
Thanks
--
Yawen

=====================
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
|

AW: aggregate

la volta statistics
Hi Yawen

a while ago there was a solution by Simon Freidin for this problem.
Hope this helps, Christian


get FILE="1991 U.S. General Social Survey.sav'.

compute nobreak=1.

oms /if command=["Frequencies"] subtypes=["Statistics"]
  / destination format=sav outfile="d:\Temp\mode.sav" viewer=no.

freq vars=SPEDUC
  /format=notable
  /statistics=mode.

omsend.
save outfile="d:\Temp\temp.sav".

get file="d:\Temp\mode.sav".
sel if var1='Mode'.
rename vars (var4=SPEDMODE).
compute nobreak=1.
match file file=*
  /keep=nobreak SPEDMODE.

match file file="d:\Temp\temp.sav"
  /table=*
  /by nobreak.
exe.
New File.
Dataset close all.
Erase File = "d:\Temp\temp.sav".
Erase File = "d:\Temp\mode.sav" .

-----Ursprüngliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von
Yawen LI
Gesendet: Montag, 20. Oktober 2008 08:50
An: [hidden email]
Betreff: aggregate

hi, all,

It seems that Aggregate function in spss does not support aggregating
on mode (instead of mean or median). how can i do that using other
methods?
Thanks
--
Yawen

=====================
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

Albert-Jan Roskam
In reply to this post by Yawen LI
Hi Yawen,

The solution below was posted by ViAnn Beadble a while ago. It requires two data passes, but I think it's a nicer solution than working with OMS (maybe it's just me, but I always find OMS something like a last resort, or a poor man's choice ;-P)

Cheers!!
Albert-Jan


--- On Tue, 8/21/07, ViAnn Beadle <[hidden email]> wrote:

> From: ViAnn Beadle <[hidden email]>
> Subject: Re: Modal value in aggregate function
> To: [hidden email]
> Date: Tuesday, August 21, 2007, 5:51 PM
> Try this:
>
> AGGREGATE
>   /OUTFILE=*
>   /BREAK=company product
>   /N_BREAK=N.
>
> SORT CASES BY company N_BREAK(D).
>
> AGGREGATE
>   /OUTFILE=*
>   /PRESORTED
>   /BREAK=company
>   /product=FIRST(product)
>   /modalvalue=FIRST(N_BREAK).
>
> The first aggregate command gets the count of product by
> company.
>
> The sort then sorts the product code counts in descending
> value by company.
>
> The second aggregate then picks up the first instance of
> product by company.
>
> This also saves the modal value. Note that it treats ties
> arbitrarily and
> can be used with either string or numeric company and
> product codes.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]]
> On Behalf Of
> Hoover, Matthew
> Sent: Tuesday, August 21, 2007 9:29 AM
> To: [hidden email]
> Subject: Re: Modal value in aggregate function
>
> Hello,
>
>
>
> The product code is numeric (I converted it from a string
> so it would be
> easier to aggregate).  If there is an exact tie, I could
> take either one
> them (which one wouldn't matter).  Basically, we are
> being forced to
> give a "main" product code to each company and
> the only fair way to do
> that is by the most occurring code.
>
>
>
> Matt
>
>
>
> ________________________________
>
> From: King Douglas [mailto:[hidden email]]
> Sent: Tuesday, August 21, 2007 11:21 AM
> To: Hoover, Matthew; [hidden email]
> Subject: Re: Modal value in aggregate function
>
>
>
> Hi, Matthew,
>
> Is your product code a numeric? or a string variable?
>
> What do you want to do in the case of ties, if any (e.g., a
> bi-modal
> situation)?
>
> King Douglas
> American Airlines Customer Research
>
> "Hoover, Matthew"
> <[hidden email]> wrote:
>
> Hi list,
>
>
>
> I want to do something that I thought was relatively
> simple, but I can't
> see it as an option in the windows interface. I have a
> dataset with 2
> variables. One variable is a list of companies and another
> variable is
> a specific product code for that company. There are several
> lines per
> company corresponding to many different product codes
> associated with
> that company. What I would like to do is to aggregate the
> file to just
> 1 line per company taking the modal product code (the
> product code that
> repeats the most per company). In the aggregate function, I
> see only
> "mean" and "median" but no
> "modal".
>
>
>
> BTW, I'm currently using SPSS 14.
>
>
>
> Is there some other way I could do this?
>
>
>
> Thanks,
>
>
>
> Matt


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.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