cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
vince_faller
Super User (Alumni)

get rows where and select where

I'm seeing a weird issue with get rows where when trying to make it dynamic.

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

dt << get rows Where(:Sex == "F"); //Works

dt << Get Rows Where(Column("Sex") == "F"); // Doesn't Work

//but ...

col = :Sex; //doesn't work

col = Column("Sex"); //Works

//so trying to do

dt << Get Rows Where (col == "F");

//can't work in any way that I can see


Tried a few different versions.  Anyone else getting this?  I swear I've done this before.  I tried :Name as well but it doesn't like using a variable and doing some type of Eval seems pretty hacky for this. 

Vince Faller - Predictum
1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: get rows where and select where

An empty index appears to be needed to access the data of a column when the current row is implicit. Alternatively As Column() can be applied to a column name (as string) or a variable.

dt << Get Rows Where(Column("Sex")[] == "F"); // Works

col = Column("Sex"); //Works

dt << Get Rows Where(col[] == "F"); // Works

dt << Get Rows Where(As Column(col) == "F"); // Works

dt << Get Rows Where(As Column("sex") == "F"); // Works

View solution in original post

5 REPLIES 5
vince_faller
Super User (Alumni)

Re: get rows where and select where

I could do

col = Column("Sex")<<Get Values;

Loc(col,"F");


But I still think something within the data table should work.

Vince Faller - Predictum
ms
Super User (Alumni) ms
Super User (Alumni)

Re: get rows where and select where

An empty index appears to be needed to access the data of a column when the current row is implicit. Alternatively As Column() can be applied to a column name (as string) or a variable.

dt << Get Rows Where(Column("Sex")[] == "F"); // Works

col = Column("Sex"); //Works

dt << Get Rows Where(col[] == "F"); // Works

dt << Get Rows Where(As Column(col) == "F"); // Works

dt << Get Rows Where(As Column("sex") == "F"); // Works

vince_faller
Super User (Alumni)

Re: get rows where and select where

Yep.   Column("Sex")[row()] was how I was doing it before.

Thank you

Vince Faller - Predictum
pmroz
Super User

Re: get rows where and select where

One more wrinkle.  I use strings for the column names, rather than pointers to the column.  This works:

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

col = "Sex";

srows = dt << get rows Where(as column(dt, col) == "F");

This works too:

srows = dt << get rows Where(as column(col) == "F");

ram
ram
Level IV

Re: get rows where and select where

better solution;

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

col1="height"; val="61"; val2="95";

srows = dt << get rows Where(char(column(col1)[]) == char(val) );