cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
ccharlie
Level II

How to select rows with multiple criteria combined

Hi,

 

I'm trying to isolate a specific group within a large data set using the following criteria: all subjects who answered yes to 2 particular questions AND all subjects who answered yes to any 3 other questions combined (total number of questions = 9). I was able to isolate subjects meeting the first criteria rather easily but don't know how to select subjects who meet the second criteria (assuming all subjects who met the 1st one were removed from the sample of interest to avoid counting them twice). Any help would be greatly appreciated!

 

 

13 REPLIES 13
txnelson
Super User

Re: How to select rows with multiple criteria combined

You seem to be missing how the logic is working.  What you have below can never have a sum greater than one.

a Boolean comparison always results in a 0 or a 1.

So if you were checking to see if a variable called X has a value of 22, the comparitor or

X==22 will return a 1 when it is true, and a 0 when it is false.

in your example below, the comparitor of

Fruit+Screener == "2" & Vegitables_Screener == "2" can only be true(1) or False(0).

The sum of this can only be a 0 or a 1, never a 4

Jim
ccharlie
Level II

Re: How to select rows with multiple criteria combined

Thanks Jim! I tried replacing that 4 with a 1 since I know this combination to be true of at least one row but still nothing was selected. Overall, I am looking to select rows which have "yes" (coded as 1) as answers for at least 3 questions out of a group of 7 total questions (so >=3 total). Any tips would be greatly appreciated.

 

Thanks again!

txnelson
Super User

Re: How to select rows with multiple criteria combined

I suspect that Fruit_scanner and Vegitable_Scanner columns are numeric, not character.  In your "Nonworking" example, you specified the comparison as:

Fruit_Scanner=="2". 

If Fruit_Scanner is a numerical column the comparison would be:

Fruit_Scanner==2

Also look at the actual values of Fruit_scanner.  I thought you indicated that the values were 0 or 1.  If that is true then you need to be looking for:

Fruit_Scanner==1

 

The original reply that I published is the format that needs to be used to get what you want.  What is needed are the actual names of the columns and the actual values in those columns.  If you can provide that, I think I could give you the JSL

Jim
ccharlie
Level II

Re: How to select rows with multiple criteria combined

Thanks for the information! Modifying the Fruit_Scanner=="2" to Fruit_Scanner==2 worked like a charm. Using that I was finally able to get the rows I was looking for using the following:

 

dt = Open( "myfile.jmp" );

dt << Select Where( :testendurance_T1 == 1 | :teststrong_T1 == 1 | Sum( :testenjoy_T1 == 1, :testsad_T1 == 1, :testsports_T1 == 1, :testsleep_T1 == 1, 

:testperform_T1 == 1, :testlibido_T1 == 1, :maleenergy_T1 == 1  ) >= 3 );

 

Thanks again all for everything!