LMED returns the median value out of a specified number of values. If the required number of values is not found within the search range the function returns no value (blank).
SYNTAX:
LMED(Cx, n, Range, Options)
where :
Cx is a conditional variable x
n specifies the number of values to get a median of
Range specifies the maximum range of days to search backward when looking for the specified number of values. Example: if you set this at 366, the function will look for the specified number of values (n) until it finds all of them or has looked in 366 days.
Options indicate when to start looking and when to calculate the value. The following lists the settings for the options parameter:
1 |
Today |
Every Day |
2 |
Today |
1st of month |
3 |
Today |
Last of Month |
4 |
Yesterday |
Every Day |
5 |
Yesterday |
1st of month |
6 |
Yesterday |
Last of Month |
NOTES:
This function will only calculate a median if the specified number of values (n) are found
EXAMPLE:
V97 = LMED(V70, 5, 183, 1)
This example searches variable 70 for the last 5 values, starting today and looking back up to 183 days. Once the last 5 values are found, the Median is calculated and stored in variable 97:
Example with MDL Rules:
V = LMED(V5261,3,30,1) and V = LMED(V5261,4,30,1)
On calculated variables, it is possible to elect to cascade MDL rules or not. Below is an example of cascading MOST frequent MDL symbol, ALL MDL symbols, and NONE or no MDL symbols. This also shows the difference between even number of data points and an odd number of data points when choosing a median value.
V9563 and V9564 - Most Frequent MDL Symbol
V9567 and V9565 - All MDL Symbols
V9568 and V9566 - No MDL Symbols
V9563, V9567, and V9568 have odd number of data points
V9564, V9565, and V9566 have even number of data points