A filter is a logical expression which evaluates to 1 (= TRUE) or 0 (=FALSE). For every case in the spreadsheet, this expression is evaluated and if the result is TRUE, the case is included in the analysis or graph but if the result is not TRUE, then the case is excluded from the statistical analysis or graph.
1. Simple filter
A basic filter exists of a variable, a logical operator and a constant value. The relational operators, in order of precedence, are:
|<=||Less than or equal to|
|>=||Greater than or equal to|
For example, if you have the following data in the spreadsheet:
then the expression AGE>40 can be used as a filter:
When MedCalc calculates the summary statistics for the variable WEIGHT, it will evaluate the expression AGE>40 for every case. MedCalc will only include the cases for which the expression evaluates to the logical value TRUE.
Other examples of filters:
TREATMENT="A" : Treatment must be equal to "A" - notice the use of quotation marks for a text constant in formula.
AGE<=60 : Age must be less than or equal to 60
ROW<21 : Only the first 20 cases in the spreadsheet will be selected (see ROW)
VARY<>"" : Only process cases where the variable VARY is not empty (can contain text or numbers)
ISNUMBER(VARY) : Only process cases where the variable VARY is a number
2. Combined filter
Different filters can be combined into one single filter using the logical functions AND, OR and NOT, e.g.
AND(AGE>40,AGE<60) : only cases with age more than 40 and less than 60 will be selected.
AND(AGE>40,TREATMENT="A") : only cases with age more than 40 and treatment "A".
OR(AGE>40,TREATMENT="A") : cases with age more than 40 or treatment "A" will be selected.
AND(AGE>40,OR(TREATMENT="A",TREATMENT="B")) : cases with age more than 40 and treatments "A" or "B" will be selected.
When you have used a filter, you should check the resulting sample size and verify that the cases you intended to be selected have indeed been selected, and that you did not make a logical error in composing the filter formula.