November 30, 2006, 10:42 AM
mgrackinCalculating 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.
November 30, 2006, 01:24 PM
hammo1jMickey
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?
November 30, 2006, 03:26 PM
mgrackinFortunately I only need to do this for one column as you noted.
December 01, 2006, 12:41 AM
susannahJohn, 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.