Calculating Median

Peter Bateman ppfb@hotmail.com
Mon, 02 Aug 2004 12:42:13 -0300


Two pass QUIZ solution with executable FINAL FOOTING :
access file
sort on x
define x-count integer = 1
report summary x x-count subtotal noreset
set subfile name xsub

Final Footing  ' define R2 = Floor ( ('  x-count subtotal noreset '  + 1) /2 
) ' skip 1 &
	    ' define R3 = Floor ( ('  x-count subtotal noreset '  + 2) /2 ) ' skip 
1

set report device disc name usefile
set page width 72 length 0
set nohead
set close
go ; this gives the values in sequence with a sequence number
use usefile
; assuming the first record is record 1
access *xsub link to record ( R2) of *xsub alias low &
                     link to record (R3) of *xsub  alias high
define median = ( x of low + x of high ) / 2
report median
set report limit 1
go

Regards,
Peter Bateman

_________________________________________________________________
MSNŽ Calendar keeps you organized and takes the effort out of scheduling 
get-togethers. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
  Start enjoying all the benefits of MSNŽ Premium right now and get the 
first two months FREE*.