Dear Members,
I am trying to compute mode for the grouped data using Aggregate command in spss. Aggregate command in SPSS does not show any option for mode, although it shows mean, sd and other options. Is it possibly to compute mode using aggregate command? or is there any other way to do the same? I shall be grateful for any help in this regard. Below is the Aggregate Command I am using for Mean calculations now I need to calculate MODE values for the same criteria. Thanks in advance. AGGREGATE /OUTFILE='D:\Project\2013\13-001\New\Fortnight\Canola\SHOPTYPE.sav' /BREAK=UR LOCATION SHOPTYPE SKU TYPE BrandID /DEC_SF2012_mean=MEAN(DEC_SF2012) /JAN_FF2013_mean=MEAN(JAN_FF2013) /JAN_SF2013_mean=MEAN(JAN_SF2013) /FEB_FF2013_mean=MEAN(FEB_FF2013) /FEB_SF2013_mean=MEAN(FEB_SF2013) /MAR_FF2013_mean=MEAN(MAR_FF2013) /MAR_SF2013_mean=MEAN(MAR_SF2013) /APR_FF2013_mean=MEAN(APR_FF2013) /APR_SF2013_mean=MEAN(APR_SF2013) /MAY_FF2013_mean=MEAN(MAY_FF2013) /MAY_SF2013_mean=MEAN(MAY_SF2013) /JUN_FF2013_mean=MEAN(JUN_FF2013) /JUN_SF2013_mean= MEAN(JUN_SF2013) /JUL_FF2013_mean=MEAN(JUL_FF2013) /JUL_SF2013_mean=MEAN(JUL_SF2013) /AUG_FF2013_mean=MEAN(AUG_FF2013) /AUG_SF2013_mean=MEAN(AUG_SF2013) /SEP_FF2013_mean=MEAN(SEP_FF2013) /SEP_SF2013_mean=MEAN(SEP_SF2013) /OCT_FF2013_mean=MEAN(OCT_FF2013) /OCT_SF2013_mean=MEAN(OCT_SF2013) /NOV_FF2013_mean=MEAN(NOV_FF2013) /NOV_SF2013_mean=MEAN(NOV_SF2013) /DEC_FF2013_mean=MEAN(DEC_FF2013) /DEC_SF2013_mean=MEAN(DEC_SF2013) /JAN_FF2014_mean=MEAN(JAN_FF2014) /JAN_SF2014_mean=MEAN(JAN_SF2014) /FEB_FF2014_mean=MEAN(FEB_FF2014) /FEB_SF2014_mean=MEAN(FEB_SF2014) /MAR_FF2014_mean=MEAN(MAR_FF2014) /MAR_SF2014_mean=MEAN(MAR_SF2014). |
Also attaching the sav file for reference.ALL_PERIODS_Canola.sav
|
This has come up a few times that I remember on the list-serve. See this post for a general code snippet, http://spssx-discussion.1045642.n5.nabble.com/Computing-a-Variable-in-SPSS-Mode-of-Many-Variables-td5713850.html#a5713857. It is amenable to grouped data, although will take some editing to insert the grouping variable where appropriate.
The older post you commented on with the OMS solution would work if you used split file before the OMS. Note though that the frequencies procedure only produces one of the modal values, even if there are multiple modes in the data. I was confused looking at your data as so much of it was missing - off-handedly I would say missings are the model value in that set ;) |
In reply to this post by Asghar Hussaini
OMS, SPLIT FILE, and FREQUENCIES.
This assumes that a group id variable has been computed. Here is an example using the employee data.sav file shipped with Statistics. dataset declare statistics. oms select tables /if subtypes='Statistics' /destination outfile=statistics format=sav. sort cases by jobcat. split file layered by jobcat. frequencies variables=educ /format=notable /statistics=mode. omsend. dataset activate statistics. select if var2 eq "Mode". Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Asghar Hussaini <[hidden email]> To: [hidden email], Date: 04/18/2014 08:39 AM Subject: [SPSSX-L] Mode Calculation in Grouped Data By SPSS Aggregate Command Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear Members, I am trying to compute mode for the grouped data using Aggregate command in spss. Aggregate command in SPSS does not show any option for mode, although it shows mean, sd and other options. Is it possibly to compute mode using aggregate command? or is there any other way to do the same? I shall be grateful for any help in this regard. Below is the Aggregate Command I am using for Mean calculations now I need to calculate MODE values for the same criteria. Thanks in advance. AGGREGATE /OUTFILE='D:\Project\2013\13-001\New\Fortnight\Canola\SHOPTYPE.sav' /BREAK=UR LOCATION SHOPTYPE SKU TYPE BrandID /DEC_SF2012_mean=MEAN(DEC_SF2012) /JAN_FF2013_mean=MEAN(JAN_FF2013) /JAN_SF2013_mean=MEAN(JAN_SF2013) /FEB_FF2013_mean=MEAN(FEB_FF2013) /FEB_SF2013_mean=MEAN(FEB_SF2013) /MAR_FF2013_mean=MEAN(MAR_FF2013) /MAR_SF2013_mean=MEAN(MAR_SF2013) /APR_FF2013_mean=MEAN(APR_FF2013) /APR_SF2013_mean=MEAN(APR_SF2013) /MAY_FF2013_mean=MEAN(MAY_FF2013) /MAY_SF2013_mean=MEAN(MAY_SF2013) /JUN_FF2013_mean=MEAN(JUN_FF2013) /JUN_SF2013_mean= MEAN(JUN_SF2013) /JUL_FF2013_mean=MEAN(JUL_FF2013) /JUL_SF2013_mean=MEAN(JUL_SF2013) /AUG_FF2013_mean=MEAN(AUG_FF2013) /AUG_SF2013_mean=MEAN(AUG_SF2013) /SEP_FF2013_mean=MEAN(SEP_FF2013) /SEP_SF2013_mean=MEAN(SEP_SF2013) /OCT_FF2013_mean=MEAN(OCT_FF2013) /OCT_SF2013_mean=MEAN(OCT_SF2013) /NOV_FF2013_mean=MEAN(NOV_FF2013) /NOV_SF2013_mean=MEAN(NOV_SF2013) /DEC_FF2013_mean=MEAN(DEC_FF2013) /DEC_SF2013_mean=MEAN(DEC_SF2013) /JAN_FF2014_mean=MEAN(JAN_FF2014) /JAN_SF2014_mean=MEAN(JAN_SF2014) /FEB_FF2014_mean=MEAN(FEB_FF2014) /FEB_SF2014_mean=MEAN(FEB_SF2014) /MAR_FF2014_mean=MEAN(MAR_FF2014) /MAR_SF2014_mean=MEAN(MAR_SF2014). -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Mode-Calculation-in-Grouped-Data-By-SPSS-Aggregate-Command-tp5725524.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 |
But remember that there can be more than
one modal value. FREQUENCIES reports the lowest value.
Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: Jon K Peck/Chicago/IBM@IBMUS To: [hidden email], Date: 04/18/2014 10:04 AM Subject: Re: Mode Calculation in Grouped Data By SPSS Aggregate Command Sent by: "SPSSX(r) Discussion" <[hidden email]> OMS, SPLIT FILE, and FREQUENCIES. This assumes that a group id variable has been computed. Here is an example using the employee data.sav file shipped with Statistics. dataset declare statistics. oms select tables /if subtypes='Statistics' /destination outfile=statistics format=sav. sort cases by jobcat. split file layered by jobcat. frequencies variables=educ /format=notable /statistics=mode. omsend. dataset activate statistics. select if var2 eq "Mode". Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Asghar Hussaini <[hidden email]> To: [hidden email], Date: 04/18/2014 08:39 AM Subject: [SPSSX-L] Mode Calculation in Grouped Data By SPSS Aggregate Command Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear Members, I am trying to compute mode for the grouped data using Aggregate command in spss. Aggregate command in SPSS does not show any option for mode, although it shows mean, sd and other options. Is it possibly to compute mode using aggregate command? or is there any other way to do the same? I shall be grateful for any help in this regard. Below is the Aggregate Command I am using for Mean calculations now I need to calculate MODE values for the same criteria. Thanks in advance. AGGREGATE /OUTFILE='D:\Project\2013\13-001\New\Fortnight\Canola\SHOPTYPE.sav' /BREAK=UR LOCATION SHOPTYPE SKU TYPE BrandID /DEC_SF2012_mean=MEAN(DEC_SF2012) /JAN_FF2013_mean=MEAN(JAN_FF2013) /JAN_SF2013_mean=MEAN(JAN_SF2013) /FEB_FF2013_mean=MEAN(FEB_FF2013) /FEB_SF2013_mean=MEAN(FEB_SF2013) /MAR_FF2013_mean=MEAN(MAR_FF2013) /MAR_SF2013_mean=MEAN(MAR_SF2013) /APR_FF2013_mean=MEAN(APR_FF2013) /APR_SF2013_mean=MEAN(APR_SF2013) /MAY_FF2013_mean=MEAN(MAY_FF2013) /MAY_SF2013_mean=MEAN(MAY_SF2013) /JUN_FF2013_mean=MEAN(JUN_FF2013) /JUN_SF2013_mean= MEAN(JUN_SF2013) /JUL_FF2013_mean=MEAN(JUL_FF2013) /JUL_SF2013_mean=MEAN(JUL_SF2013) /AUG_FF2013_mean=MEAN(AUG_FF2013) /AUG_SF2013_mean=MEAN(AUG_SF2013) /SEP_FF2013_mean=MEAN(SEP_FF2013) /SEP_SF2013_mean=MEAN(SEP_SF2013) /OCT_FF2013_mean=MEAN(OCT_FF2013) /OCT_SF2013_mean=MEAN(OCT_SF2013) /NOV_FF2013_mean=MEAN(NOV_FF2013) /NOV_SF2013_mean=MEAN(NOV_SF2013) /DEC_FF2013_mean=MEAN(DEC_FF2013) /DEC_SF2013_mean=MEAN(DEC_SF2013) /JAN_FF2014_mean=MEAN(JAN_FF2014) /JAN_SF2014_mean=MEAN(JAN_SF2014) /FEB_FF2014_mean=MEAN(FEB_FF2014) /FEB_SF2014_mean=MEAN(FEB_SF2014) /MAR_FF2014_mean=MEAN(MAR_FF2014) /MAR_SF2014_mean=MEAN(MAR_SF2014). -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Mode-Calculation-in-Grouped-Data-By-SPSS-Aggregate-Command-tp5725524.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 |
Administrator
|
In reply to this post by Asghar Hussaini
Study the following:
VARSTOCASES /MAKE Values FROM DEC_SF2012 TO MAR_SF2014 /INDEX=DateIndex(Values) /KEEP=UR LOCATION SHOPTYPE SKU TYPE BrandID /NULL=DROP. DATASET DECLARE agg. AGGREGATE OUTFILE agg /BREAK=UR LOCATION SHOPTYPE SKU TYPE BrandID DateIndex Values /Count=N. SORT CASES BY UR LOCATION SHOPTYPE SKU TYPE BrandID DateIndex (A) Count (D). MATCH FILES /FILE * /BY UR LOCATION SHOPTYPE SKU TYPE BrandID DateIndex /FIRST=@MODE@.
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?" |
Administrator
|
Edited: needed to activate the agg dataset! ;-)
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?" |
Free forum by Nabble | Edit this page |