Median 

20040318 
http://www.barefeetware.com/appleworks/median/ 

Description 
This AppleWorks addon function allows a spreadsheet to calculate the statistical median of a set of data. 

This is one of over 40 features in the Enhancement Pack for AppleWorks. 

DetailAdvanced
The “Median” custom function does not appear in the Scripts menu. You invoke it by using the “MACRO” function in a spreadsheet cell or calculated field. The easiest way to do this is to use the “Function...” menu item in the Scripts menu. It copies the syntax:Sample
MACRO("Median",2,"calculate", data)
You paste this into a spreadsheet cell after an “=” (equals) sign, then replace the parameter “data” with a range of cells.
To view this sample included with the Enhancement Pack, open the document:Example
AppleWorks/ AppleWorks Essentials/ Scripts Support/ Documentation/ Script Function Samples.cwk
The example explains how the above sample was constructed.
 In a spreadsheet, enter your raw data, such as I the sample data in cells B17 through B24:
 In the cell where you want the calculation (I used cell E18 in the sample document), type an equals sign and leave the cursor flashing.
 Select the "Function..." command from the Scripts menu, select "Median" from the list.
 Paste (from the Edit menu) the function into your formula, so it reads:
=MACRO("Median",2,"calculate", data)
 Select the "data" parameter in your formula and drag a selection over the cells containing your data. For instance, if your data was entered into cells B2 to B8, then the formula would now appear as:
=MACRO("Median",2,"calculate", B2..B8)
 Hit the Enter key. Your calculation should update, as shown in the sample document:
Because the functions are dynamically calculated, you can change the precedent data points to see the median update automatically.Requirements
The “Median” function can be placed in any spreadsheet cell.Download
This script works with AppleWorks 6 and AppleWorks 5.
Only registered users are permitted to use the supplied files after 14 days or edit them.
This script is included in the Enhancement Pack for AppleWorks, not supplied separately.Scripting
To make the script editable, drag and drop it onto the “Show/Hide in Scripts Menu” applet in the Scripts Support folder, then double click to open in your script editor. After closing the script, drop it on the applet again to hide it in the AppleWorks menu.Please email us any queries about this page.
Here’s an extract from the script:
on calculate(theCells)
set rawList to theCells
set cellCount to count of rawList
set sortedList to anyLib's SortList(rawList)
set theMedian to item (1 + cellCount div 2) of sortedList
if cellCount mod 2 = 0 then  even number of cells
set theMedian to (theMedian + (item (cellCount div 2) of sortedList)) / 2
end if
return theMedian
end calculate