Subscribe Bookmark RSS Feed

Question on JMP Row Selection.

zainilmin

Community Trekker

Joined:

Jun 22, 2015

Can we use the following query

dt = Open("tablename");

r = dt << Get Rows Where(:testid in ('1','2'));

5 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

there are probably other ways, here's one:

r = dt << Get Rows Where( contains( {"F", "M" }, sex ) );

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,

24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]

Craige
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

JMP doesn't have an In() function the way SQL does.

You'll need to test each value individually, like this:


dt = Open("tablename");


r = dt << Get Rows Where(:testid == '1' | :testid == '2');


-Jeff

-Jeff
pmroz

Super User

Joined:

Jun 23, 2011

If you have a lot of values to look for C Hales solution is the way to go.  Works in a similar manner to a SQL IN list.

BTW when is JMP going to put SQL into the product????  PROC SQL has been in SAS for a long time now.

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

PMroz and Craige@JMP are right.

I misunderstood Craige@JMP's example.

Here's one that might be clearer.


dt=open("$SAMPLE_DATA\Big Class.jmp");



//get the rows for ages 13 and 17


age13and17=dt<<get rows where(contains({"13", "17"}, char(:age)));



//select those rows


dt<<select rows(age13and17);



-Jeff

-Jeff
Craige_Hales

Staff

Joined:

Mar 21, 2013

Thanks Jeff, that does illuminate the example quite a bit.

Craige