Hi all,
I am trying to filter out rows where two conditions are met (e.g., sex and age over 40). I can create a filter that removes all cases that are males and all cases that are over 40 years (sex != "M" and age < 40), but what if I only want to filter out males who are over 40? So all males under the age of 40 remain active?
My apologies if this question has been answered already. I have tried a number of variations but cant seem to work it out.
Thanks,
Talitha
Filter based on multiple conditions
Re: Filter based on multiple conditions
Hi Talitha,
The filter has the purpose of selecting only the data that supports it and excluding the others for the statistics that you are going to use, but also updating those you have already done.
In your case, if you want to run statistics that only include cases where the Sex variable is "M" to select only males and the Age variable must only have values greater than 40 years, you can filter:
Sex == 'M' and Age> 40
You can see the attached screenshot. Greetings and Happy Easter.
Maurizio
The filter has the purpose of selecting only the data that supports it and excluding the others for the statistics that you are going to use, but also updating those you have already done.
In your case, if you want to run statistics that only include cases where the Sex variable is "M" to select only males and the Age variable must only have values greater than 40 years, you can filter:
Sex == 'M' and Age> 40
You can see the attached screenshot. Greetings and Happy Easter.
Maurizio
Re: Filter based on multiple conditions
maurizio is spot-on,
but another thing you can do is use the '+' button to the top left of the filters. this way you can create separate filters:
the first one: `Sex == 'M'`, and `Age > 40` for the second one. the nice thing about doing them separately, is you can see at a glance why a row was excluded. but both ways work.
cheers
jonathon
but another thing you can do is use the '+' button to the top left of the filters. this way you can create separate filters:
the first one: `Sex == 'M'`, and `Age > 40` for the second one. the nice thing about doing them separately, is you can see at a glance why a row was excluded. but both ways work.
cheers
jonathon
-
- Posts: 15
- Joined: Fri Oct 23, 2020 9:12 am
Re: Filter based on multiple conditions
Hi Jonathon,jonathon wrote:maurizio is spot-on,
but another thing you can do is use the '+' button to the top left of the filters. this way you can create separate filters:
the first one: `Sex == 'M'`, and `Age > 40` for the second one. the nice thing about doing them separately, is you can see at a glance why a row was excluded. but both ways work.
cheers
jonathon
Good day. Can i ask you for the command if i want to filter the following: I only want to include ages between 25 and 34, and countries only like Sweden, Norway, Finland, Denmark in my analysis. I am using GEM data set. Hope you can help me on this. Thank you very much.
Warm regards,
Enrico Mendoza
Re: Filter based on multiple conditions
i'd create two filters
25 < age < 34
country == 'Sweden' or country == 'Norway' or country == 'Finland' or country == 'Denmark'
jonathon
25 < age < 34
country == 'Sweden' or country == 'Norway' or country == 'Finland' or country == 'Denmark'
jonathon
Re: Filter based on multiple conditions
Hello, I'm back again. What if I want to filter out rows where 2 conditions are met. For example have a column of participant IDs (1,2,3, etc) and a column of treatments (A,B). Each participant has 4 rows (4 time points [T1-T4]), where they have treatment A for 2 time-points and treatment B for the other 2.
How would I exclude the rows for participant 1 AND ONLY condition B, leaving participant 1 and condition A as active in the data?
Thanks for your help!
How would I exclude the rows for participant 1 AND ONLY condition B, leaving participant 1 and condition A as active in the data?
Thanks for your help!
Re: Filter based on multiple conditions
> leaving participant 1 and condition A as active in the data?
participant == 1 and condition == 'A'
participant == 1 and condition == 'A'