Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Statistical Function : MEDIAN
Message
 
 
To
10/12/2001 09:29:43
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00592035
Message ID:
00592047
Views:
18
>>Hi all
>>
>>Does anyone has a function to calulate MEDIAN for VFP?
>>
>>Thanks in advance
>>Petros
>
>That is the value in the middle, right?
>
>Here is a sample:
>
>
>select MyValue from MyTable into cursor Temp;
>  order by MyValue;
>  nofilter
>goto reccount() / 2
>? MyValue
>
>
>HTH, Hilmar.

It's little bit more complicated. :)
lnRecCnt = RECCOUNT()
IF (lnRecCnt % 2 ) =1       && Odd # of records
    GOTO ( CEILING( lnRecCnt/2 ) )
    lnMedian = MyValue
ELSE
    GOTO ( lnRecCnt/2  )
    lnMedian = MyValue
    SKIP
    lnMedian = (lnMedian + MyValue) / 2
ENDIF
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform