Focal Point
Calculating MODE Average

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2241049891

November 30, 2006, 10:42 AM
mgrackin
Calculating MODE Average
Does anyone have a good technique for calculating the MODE average? MODE average is the value which appears most frequently in a set of values. I am able to calculate the MODE average by making two passes at the data.

The first pass creates a count for each value in a HOLD file.

The second pass sorts the data BY HIGHEST count and then uses a COMPUTE and WHERE TOTAL to capture the first one. BY HIGHEST 1 does not give me only one when there is a tie.

The twist in this thing is that I am looking for the MODE average for ratings. If there is a tie between ratings, then I want the HIGHEST rating. SO I need to sort BY HIGHEST count and then BY HIGHEST rating and then take only the first one.

the following is an example using the car file.

TABLE FILE CAR
SUM SEATS
BY COUNTRY
BY CAR
ON TABLE HOLD
END

TABLE FILE HOLD
PRINT SEATS
COMPUTE CNTR/I1=IF (COUNTRY EQ LAST COUNTRY) THEN 0 ELSE 1;
BY COUNTRY
BY HIGHEST SEATS
BY HIGHEST CAR
WHERE TOTAL CNTR EQ 1
END

Any thoughts are appreciated.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
November 30, 2006, 01:24 PM
hammo1j
Mickey

Your technique is great provided that you dont want to find the mode for more than one column of data. I used to use wf to work out quartiles and medians and the principle is the same.

The technique I used if I had 10 cols was to join to a table with 10 rows replicating the data and then use your technique on the set and then recombine it with across.

With multicolumns it's a pig to do in wf and much better done in some package.

Come to think of it where has the old focus statistical package gone.

Anyone know?



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
November 30, 2006, 03:26 PM
mgrackin
Fortunately I only need to do this for one column as you noted.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
December 01, 2006, 12:41 AM
susannah
John, ANALYZE FILE was written for mainframe by one of ibi's owners, Marty Stagowitz. It never got xlated completely in to wf. Once i asked Gerry if we could have some particular feature, and he said 'if you want ANALYZE we can give you ANALYZE' but it never happened, i think its too expensive to do in view of the number of good econometric packages out there. So IBI instead partnered with SPSS, which is a very very nice stat pack, i used to use it on the mainframe, back in the days of BIOMED and punch cards.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID