Filters
1. Basic filter
A basic filter exist of a variable, a logical operator and a constant value. The relational operators, in order of precedence, are:
= | Equality |
<> | Inequality |
< | Less than |
> | Greater than |
<= | Less than or equal to |
>= | Greater than or equal to |
For example, if you have a variable AGE then the expression AGE>40 can be used as a filter.
Other examples of filters:
- TREATMENT="A" : Treatment must be equal to "A" - notice the use of quotation marks for a text constant in the formula.
- AGE<=60 : Age must be less than or equal to 60
- ROW<21 : Only the first 20 cases in the data table will be selected
2. Combined filters
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 selection filter.
How to create a filter
The example file ExampleFile2 contains data on body weight and length and included a variable Group. The Group variable contains the numbers 0 and 1 that identify two subgroups (controls and treated). You want to have a filter that select the cases belonging to group 0 and a filter that selects the cases belonging to group 1.
Click Data in the SciStat.com menu. Next click Filters. The browser displays the following (there are no filters defined yet for this data table):
Click the New filter hyperlink. A new input panel is displayed which you complete as follows:
Click Save and the new filter is added to the filters list:
You proceed in a similar way for the second group, where group=1 for the treated cases.