PRB: CALCULATE STD--Standard Deviation--Gives Numeric Overflow (172084)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Macintosh, Professional Edition 3.0
This article was previously published under Q172084 SYMPTOMS
When calculating the standard deviation using the CALCULATE STD() function,
FoxPro can return results with a numeric overflow on certain numerical
values over various ranges of records.
RESOLUTION
Use a custom routine that calculates the standard deviation. The following
program accepts two parameters for the table and the field. Then it
calculates the various sums and products of the fields before computing the
standard deviation. Create a program called std and enter the following
code:
* Call this program by ?std("TableName","FieldName") or
* by assigning the result to a variable, y= std("TableName","FieldName")
*
PARAMETER mtable mfield
SELECT SUM(&mfield^2) FROM (mtable) INTO ARRAY yy
SELECT SUM(&mfield)^2 FROM (mtable) INTO ARRAY zz
SELECT COUNT(&mfield) FROM (mtable) INTO ARRAY xx
stdev=((xx*yy-zz)/xx^2)^.5
RETURN ROUND(stdev,12)
If a table named values contains the field num, enter this command in the
Command Window:
?std("values","num")
STATUS
Microsoft is researching this problem and will post new information here in
the Microsoft Knowledge Base as it becomes available.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbcode kbprb KB172084 |
---|
|